Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add riscv tests to the project #108

Merged
merged 9 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ add_dependency(ECAP5_DTLIB
GIT ecap5/ecap5-dtlib
TAG 2-implement-an-instrumented-wishbone-slave)

add_dependency(riscv-tests
GIT ecap5/riscv-tests
TAG master)

# Configure dependencies

include(${CMAKE_CURRENT_LIST_DIR}/cmake/ecap5-treq.cmake)
Expand Down
2 changes: 1 addition & 1 deletion cmake/FindSphinx.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
include(FindPackageHandleStandardArgs)

find_package(PythonInterp)
find_package(Python3)
if(PYTHONINTERP_FOUND)
get_filename_component(_PYTHON_DIR "${PYTHON_EXECUTABLE}" DIRECTORY)
set(
Expand Down
69 changes: 69 additions & 0 deletions cmake/riscv.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#include(CMakeForceCompiler)

# usage
# cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/rv32imac.cmake ../

# Look for GCC in path
# https://xpack.github.io/riscv-none-embed-gcc/
FIND_FILE( RISCV_XPACK_GCC_COMPILER_EXE "riscv-none-embed-gcc.exe" PATHS ENV INCLUDE)
FIND_FILE( RISCV_XPACK_GCC_COMPILER "riscv-none-embed-gcc" PATHS ENV INCLUDE)
# New versions of xpack
FIND_FILE( RISCV_XPACK_NEW_GCC_COMPILER_EXE "riscv-none-elf-gcc.exe" PATHS ENV INCLUDE)
FIND_FILE( RISCV_XPACK_NEW_GCC_COMPILER "riscv-none-elf-gcc" PATHS ENV INCLUDE)

# Look for RISC-V github GCC
# https://github.com/riscv/riscv-gnu-toolchain
FIND_FILE( RISCV_XPACK_GCC_COMPILER_EXT "riscv64-unknown-elf-gcc.exe" PATHS ENV INCLUDE)
FIND_FILE( RISCV_XPACK_GCC_COMPILER "riscv64-unknown-elf-gcc" PATHS ENV INCLUDE)

# Select which is found
if (EXISTS ${RISCV_XPACK_NEW_GCC_COMPILER})
set( RISCV_GCC_COMPILER ${RISCV_XPACK_NEW_GCC_COMPILER})
elseif (EXISTS ${RISCV_XPACK_GCC_NEW_COMPILER_EXE})
set( RISCV_GCC_COMPILER ${RISCV_XPACK_NEW_GCC_COMPILER_EXE})
elseif (EXISTS ${RISCV_XPACK_GCC_COMPILER})
set( RISCV_GCC_COMPILER ${RISCV_XPACK_GCC_COMPILER})
elseif (EXISTS ${RISCV_XPACK_GCC_COMPILER_EXE})
set( RISCV_GCC_COMPILER ${RISCV_XPACK_GCC_COMPILER_EXE})
elseif (EXISTS ${RISCV_GITHUB_GCC_COMPILER})
set( RISCV_GCC_COMPILER ${RISCV_GITHUB_GCC_COMPILER})
elseif (EXISTS ${RISCV_GITHUB_GCC_COMPILER_EXE})
set( RISCV_GCC_COMPILER ${RISCV_GITHUB_GCC_COMPILER_EXE})
else()
message(FATAL_ERROR "RISC-V GCC not found. ${RISCV_GITHUB_GCC_COMPILER} ${RISCV_XPACK_GCC_COMPILER} ${RISCV_GITHUB_GCC_COMPILER_EXE} ${RISCV_XPACK_GCC_COMPILER_EXE}")
endif()

message(STATUS "RISC-V GCC found: ${RISCV_GCC_COMPILER}")

get_filename_component(RISCV_TOOLCHAIN_BIN_PATH ${RISCV_GCC_COMPILER} DIRECTORY)
get_filename_component(RISCV_TOOLCHAIN_BIN_GCC ${RISCV_GCC_COMPILER} NAME_WE)
get_filename_component(RISCV_TOOLCHAIN_BIN_EXT ${RISCV_GCC_COMPILER} EXT)

message(STATUS "RISC-V GCC Path: ${RISCV_TOOLCHAIN_BIN_PATH}" )

STRING(REGEX REPLACE "\-gcc" "-" CROSS_COMPILE ${RISCV_TOOLCHAIN_BIN_GCC})
message(STATUS "RISC-V Cross Compile: ${CROSS_COMPILE}" )

# The Generic system name is used for embedded targets (targets without OS) in
# CMake
set( CMAKE_SYSTEM_NAME Generic )

# specify the cross compiler. We force the compiler so that CMake doesn't
# attempt to build a simple test program as this will fail without us using
# the -nostartfiles option on the command line
#CMAKE_FORCE_C_COMPILER( "${RISCV_TOOLCHAIN_BIN_PATH}/${CROSS_COMPILE}gcc${RISCV_TOOLCHAIN_BIN_EXT}" GNU )
#CMAKE_FORCE_CXX_COMPILER( "${RISCV_TOOLCHAIN_BIN_PATH}/${CROSS_COMPILE}g++${RISCV_TOOLCHAIN_BIN_EXT}" GNU )
set(CMAKE_ASM_COMPILER {CROSS_COMPILE}gcc )
set(CMAKE_AR ${CROSS_COMPILE}ar)
set(CMAKE_ASM_COMPILER ${CROSS_COMPILE}gcc)
set(CMAKE_C_COMPILER ${CROSS_COMPILE}gcc)
set(CMAKE_CXX_COMPILER ${CROSS_COMPILE}g++)

# We must set the OBJCOPY setting into cache so that it's available to the
# whole project. Otherwise, this does not get set into the CACHE and therefore
# the build doesn't know what the OBJCOPY filepath is
set( CMAKE_OBJCOPY ${RISCV_TOOLCHAIN_BIN_PATH}/${CROSS_COMPILE}objcopy
CACHE FILEPATH "The toolchain objcopy command " FORCE )

set( CMAKE_OBJDUMP ${RISCV_TOOLCHAIN_BIN_PATH}/${CROSS_COMPILE}objdump
CACHE FILEPATH "The toolchain objdump command " FORCE )
14 changes: 8 additions & 6 deletions config/gtkwave/config/decode.gtkw
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
[*]
[*] GTKWave Analyzer v3.4.0 (w)1999-2022 BSI
[*] Mon Apr 1 14:48:23 2024
[*] Thu May 2 06:35:18 2024
[*]
[dumpfile] "/Users/cchaine/Desktop/Documents/projects/.ecap5.nosync/design/proc/build/tests/waves/decode.vcd"
[dumpfile_mtime] "Mon Apr 1 14:47:51 2024"
[dumpfile_size] 56106
[dumpfile_mtime] "Thu May 2 06:34:18 2024"
[dumpfile_size] 65913
[savefile] "/Users/cchaine/Desktop/Documents/projects/.ecap5.nosync/design/proc/config/gtkwave/config/decode.gtkw"
[timestart] 887
[size] 2160 829
[timestart] 2274
[size] 2320 1043
[pos] -1 -1
*-4.654594 963 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
*-4.654594 2440 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
[markername] AA
[markername] BB
[markername] CC
Expand Down Expand Up @@ -51,6 +51,8 @@ TOP.tb_decode.clk_i
TOP.tb_decode.rst_i
@200
-Input
@29
TOP.tb_decode.stall_request_i
@28
TOP.tb_decode.input_valid_i
TOP.tb_decode.input_ready_o
Expand Down
252 changes: 252 additions & 0 deletions config/gtkwave/config/riscv-tests.gtkw
Original file line number Diff line number Diff line change
@@ -0,0 +1,252 @@
[*]
[*] GTKWave Analyzer v3.4.0 (w)1999-2022 BSI
[*] Thu May 2 09:56:53 2024
[*]
[dumpfile] "/Users/cchaine/Desktop/Documents/projects/.ecap5.nosync/design/proc/build/tests/waves/riscv-tests-lb.vcd"
[dumpfile_mtime] "Thu May 2 09:49:29 2024"
[dumpfile_size] 160338
[savefile] "/Users/cchaine/Desktop/Documents/projects/.ecap5.nosync/design/proc/config/gtkwave/config/riscv-tests.gtkw"
[timestart] 1134
[size] 2320 1043
[pos] -1 -1
*-5.572440 1440 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
[markername] AA
[markername] BB
[markername] CC
[markername] DD
[markername] EE
[markername] FF
[markername] GG
[markername] HH
[markername] II
[markername] JJ
[markername] KK
[markername] LL
[markername] MM
[markername] NN
[markername] OO
[markername] PP
[markername] QQ
[markername] RR
[markername] SS
[markername] TT
[markername] UU
[markername] VV
[markername] WW
[markername] XX
[markername] YY
[markername] ZZ
[treeopen] TOP.
[treeopen] TOP.ecap5_dproc.
[sst_width] 253
[signals_width] 285
[sst_expanded] 1
[sst_vpaned_height] 293
@28
TOP.clk_i
TOP.drq_i
TOP.irq_i
TOP.rst_i
@800200
-Master Wishbone
@22
[color] 2
TOP.wb_adr_o[31:0]
[color] 2
TOP.wb_dat_i[31:0]
[color] 2
TOP.wb_dat_o[31:0]
@28
[color] 2
TOP.wb_we_o
@22
[color] 2
TOP.wb_sel_o[3:0]
@28
[color] 2
TOP.wb_stb_o
[color] 2
TOP.wb_ack_i
[color] 2
TOP.wb_cyc_o
[color] 2
TOP.wb_stall_i
@1000200
-Master Wishbone
@800200
-IFM
@28
[color] 2
TOP.ecap5_dproc.branch
@22
[color] 2
TOP.ecap5_dproc.branch_target[31:0]
@800201
-IFM Wishbone
@23
TOP.ecap5_dproc.if_wb_adr_o[31:0]
TOP.ecap5_dproc.if_wb_dat_i[31:0]
@29
TOP.ecap5_dproc.if_wb_we_o
@23
TOP.ecap5_dproc.if_wb_sel_o[3:0]
@29
TOP.ecap5_dproc.if_wb_stb_o
TOP.ecap5_dproc.if_wb_ack_i
TOP.ecap5_dproc.if_wb_cyc_o
TOP.ecap5_dproc.if_wb_stall_i
@1000201
-IFM Wishbone
@2028
^1 /Users/cchaine/Desktop/Documents/projects/.ecap5.nosync/design/proc/config/gtkwave/filters/fetch_state_filter.gtkw
TOP.ecap5_dproc.fetch_inst.state_q[2:0]
@28
TOP.ecap5_dproc.fetch_inst.fetch_request
@4022
[color] 2
^>1 /Users/cchaine/Desktop/Documents/projects/.ecap5.nosync/design/proc/config/gtkwave/filters/decode_instr_filter_process.py
TOP.ecap5_dproc.if_instr[31:0]
@22
[color] 2
TOP.ecap5_dproc.if_pc[31:0]
@1000200
-IFM
@28
TOP.ecap5_dproc.if_dec_valid
TOP.ecap5_dproc.if_dec_ready
@c00200
-DECM
@22
[color] 5
TOP.ecap5_dproc.dec_alu_operand1[31:0]
[color] 5
TOP.ecap5_dproc.dec_alu_operand2[31:0]
@2028
[color] 5
^2 /Users/cchaine/Desktop/Documents/projects/.ecap5.nosync/design/proc/config/gtkwave/filters/execute_alu_op_filter.gtkw
TOP.ecap5_dproc.dec_alu_op[2:0]
@28
[color] 5
TOP.ecap5_dproc.dec_alu_sub
[color] 5
TOP.ecap5_dproc.dec_alu_shift_left
[color] 5
TOP.ecap5_dproc.dec_alu_signed_shift
@2028
[color] 5
^3 /Users/cchaine/Desktop/Documents/projects/.ecap5.nosync/design/proc/config/gtkwave/filters/execute_branch_cond_filter.gtkw
TOP.ecap5_dproc.dec_branch_cond[2:0]
@22
[color] 5
TOP.ecap5_dproc.dec_branch_offset[19:0]
@28
[color] 5
TOP.ecap5_dproc.dec_ls_enable
@22
[color] 5
TOP.ecap5_dproc.dec_ls_sel[3:0]
@28
[color] 5
TOP.ecap5_dproc.dec_ls_unsigned_load
[color] 5
TOP.ecap5_dproc.dec_ls_write
@22
[color] 5
TOP.ecap5_dproc.dec_ls_write_data[31:0]
[color] 5
TOP.ecap5_dproc.dec_pc[31:0]
[color] 5
TOP.ecap5_dproc.dec_reg_addr[4:0]
@28
[color] 5
TOP.ecap5_dproc.dec_reg_write
@1401200
-DECM
@28
TOP.ecap5_dproc.dec_ex_valid
TOP.ecap5_dproc.dec_ex_ready
@c00200
-EXM
@28
[color] 3
TOP.ecap5_dproc.ex_ls_enable
@22
[color] 3
TOP.ecap5_dproc.ex_ls_sel[3:0]
@28
[color] 3
TOP.ecap5_dproc.ex_ls_unsigned_load
[color] 3
TOP.ecap5_dproc.ex_ls_write
@22
[color] 3
TOP.ecap5_dproc.ex_ls_write_data[31:0]
[color] 3
TOP.ecap5_dproc.ex_reg_addr[4:0]
@28
[color] 3
TOP.ecap5_dproc.ex_reg_write
@22
[color] 3
TOP.ecap5_dproc.ex_result[31:0]
@1401200
-EXM
@28
TOP.ecap5_dproc.ex_ls_valid
TOP.ecap5_dproc.ex_ls_ready
@800200
-LSM
-LSM Wishbone
@28
TOP.ecap5_dproc.ls_wb_ack_i
@22
TOP.ecap5_dproc.ls_wb_adr_o[31:0]
@28
TOP.ecap5_dproc.ls_wb_cyc_o
@22
TOP.ecap5_dproc.ls_wb_dat_i[31:0]
TOP.ecap5_dproc.ls_wb_dat_o[31:0]
TOP.ecap5_dproc.ls_wb_sel_o[3:0]
@28
TOP.ecap5_dproc.ls_wb_stall_i
TOP.ecap5_dproc.ls_wb_stb_o
TOP.ecap5_dproc.ls_wb_we_o
@1000200
-LSM Wishbone
@28
[color] 7
TOP.ecap5_dproc.ls_reg_write
@22
[color] 7
TOP.ecap5_dproc.ls_reg_addr[4:0]
[color] 7
TOP.ecap5_dproc.ls_reg_data[31:0]
@1000200
-LSM
@28
TOP.ecap5_dproc.ls_valid
@c00200
-REGM
@22
[color] 1
TOP.ecap5_dproc.reg_raddr1[4:0]
[color] 1
TOP.ecap5_dproc.reg_raddr2[4:0]
[color] 1
TOP.ecap5_dproc.reg_rdata1[31:0]
[color] 1
TOP.ecap5_dproc.reg_rdata2[31:0]
[color] 1
TOP.ecap5_dproc.reg_waddr[4:0]
[color] 1
TOP.ecap5_dproc.reg_wdata[31:0]
@28
[color] 1
TOP.ecap5_dproc.reg_write
@1401200
-REGM
@28
TOP.ecap5_dproc.hzd_dec_stall_request
TOP.ecap5_dproc.hzd_ex_discard_request
[pattern_trace] 1
[pattern_trace] 0
2 changes: 1 addition & 1 deletion config/gtkwave/filters/fetch_state_filter.gtkw
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
010 MEMORY_WAIT
011 DONE
100 MEMORY_STALL
101 PIPELINE_STALL
101 OUTPUT
Loading
Loading