diff --git a/doc/project_mgt_hw.md b/doc/project_mgt_hw.md index 8cda2ec..76cddd6 100644 --- a/doc/project_mgt_hw.md +++ b/doc/project_mgt_hw.md @@ -135,7 +135,6 @@ Verification/Validation - [ ] https://github.com/chipsalliance/Surelog - [ ] https://stackoverflow.com/questions/65534532/how-to-estimation-a-chip-size-with-standard-cell-library - [ ] Core config - - [ ] Supporter des set de config du core en test bench. - [ ] Faire un test de synthèse selon les configs du core - [ ] Support cache disable in testbench - [ ] Error Logger Interface @@ -173,6 +172,8 @@ Hardware Tests # DONE +- [X] v1.6.0 + - [X] Supporter des set de config du core en test bench. - [X] v1.5.1: maintenance - [X] Preload jal even if processing is busy - [X] Print des tests qui ne marchent pas, un par un, dans le bash diff --git a/rtl/friscv_control.sv b/rtl/friscv_control.sv index 85caef1..df8f3a3 100644 --- a/rtl/friscv_control.sv +++ b/rtl/friscv_control.sv @@ -257,8 +257,10 @@ module friscv_control else if (cause=='h0) get_mcause_desc = "Instruction address misaligned"; else if (cause=='h4) get_mcause_desc = "LOAD address misaligned"; else if (cause=='h6) get_mcause_desc = "STORE address misaligned"; - else if (cause=='h2) get_mcause_desc = "Instruction decoding error"; - else if (cause=='hB) get_mcause_desc = "Environment call"; + else if (cause=='h10) get_mcause_desc = "Instruction decoding error"; + else if (cause=='h8) get_mcause_desc = "Environment call (U-mode)"; + else if (cause=='hB) get_mcause_desc = "Environment call (M-mode)"; + else if (cause=='h2) get_mcause_desc = "Illegal instruction"; // Asynchronous Trap else if (cause=='h80000003) get_mcause_desc = "Machine Software Interrupt"; else if (cause=='h80000007) get_mcause_desc = "Machine Timer Interrupt"; @@ -1094,7 +1096,7 @@ module friscv_control (sys[`IS_MRET]) ? inst_ready : (sys[`IS_CSR] && csr[9:8] != 2'b00) ? inst_ready : // Check if WFI must be trapped or not - (sys[`IS_WFI] ) ? inst_ready : + // (sys[`IS_WFI] ) ? inst_ready : '0; end else begin : NO_UMODE assign illegal_instruction = '0; @@ -1164,26 +1166,27 @@ module friscv_control (csr_sb[`MTIP]) ? {1'b1, {XLEN-5{1'b0}}, 4'h7} : (csr_sb[`MEIP]) ? {1'b1, {XLEN-5{1'b0}}, 4'hB} : // then follow sync exceptions - (illegal_instruction) ? {{XLEN-4{1'b0}}, 4'h2} : - (csr_ro_wr) ? {{XLEN-4{1'b0}}, 4'h2} : - (inst_dec_error) ? {{XLEN-4{1'b0}}, 4'h2} : - (inst_addr_misaligned) ? {XLEN{1'b0}} : - (ecall_umode) ? {{XLEN-4{1'b0}}, 4'h8} : - (ecall_mmode) ? {{XLEN-4{1'b0}}, 4'hB} : - (sys[`IS_EBREAK]) ? {{XLEN-4{1'b0}}, 4'h3} : - (store_misaligned) ? {{XLEN-4{1'b0}}, 4'h6} : - (load_misaligned) ? {{XLEN-4{1'b0}}, 4'h4} : - {XLEN{1'b0}}; + (illegal_instruction) ? {{XLEN-4{1'b0}}, 4'h2} : + (csr_ro_wr) ? {{XLEN-4{1'b0}}, 4'h2} : + (inst_addr_misaligned) ? '0 : + (ecall_umode) ? {{XLEN-4{1'b0}}, 4'h8} : + (ecall_mmode) ? {{XLEN-4{1'b0}}, 4'hB} : + (sys[`IS_EBREAK]) ? {{XLEN-4{1'b0}}, 4'h3} : + (store_misaligned) ? {{XLEN-4{1'b0}}, 4'h6} : + (load_misaligned) ? {{XLEN-4{1'b0}}, 4'h4} : + (inst_dec_error) ? {{XLEN-5{1'b0}}, 5'h18} : + '0; // MTVAL: exception-specific information assign mtval_info = (inst_dec_error) ? instruction : (wfi_not_allowed) ? instruction : (illegal_instruction) ? instruction : + (inst_dec_error) ? instruction : (csr_ro_wr) ? instruction : (inst_addr_misaligned) ? pc_reg : (sys[`IS_ECALL]) ? pc_reg : (sys[`IS_EBREAK]) ? pc_reg : - {XLEN{1'b0}}; + '0; // Trigger the trap handling execution in main FSM @@ -1194,8 +1197,7 @@ module friscv_control assign sync_trap_occuring = csr_ro_wr | inst_addr_misaligned | load_misaligned | - // wfi_not_allowed | - // illegal_instruction | + illegal_instruction | store_misaligned | inst_dec_error ; diff --git a/rtl/friscv_registers.sv b/rtl/friscv_registers.sv index b24e053..0a538e4 100644 --- a/rtl/friscv_registers.sv +++ b/rtl/friscv_registers.sv @@ -76,12 +76,65 @@ module friscv_registers input wire [XLEN -1:0] csr_rd_val ); + `ifdef TRACE_REGISTERS + //------------------------------------------------ + // Function to print register name and information + // @i: register number to get info + // @returns a string describing the register + //------------------------------------------------ + function string get_name(integer i); + get_name = "!?"; + if (i== 0) get_name = " zero (hardwired zero)"; + if (i== 1) get_name = " ra (return address)"; + if (i== 2) get_name = " sp (stack pointer)"; + if (i== 3) get_name = " gp (global pointer)"; + if (i== 4) get_name = " tp (thread pointer)"; + if (i== 5) get_name = " t0 (temporary register 0)"; + if (i== 6) get_name = " t1 (temporary register 0)"; + if (i== 7) get_name = " t2 (temporary register 0)"; + if (i== 8) get_name = " s0_fp (saved register 0 / frame pointer)"; + if (i== 9) get_name = " s1 (saved register 1)"; + if (i==10) get_name = " a0 (function argument 0 / return value 0)"; + if (i==11) get_name = " a1 (function argument 1 / return value 1)"; + if (i==12) get_name = " a2 (function argument 2)"; + if (i==13) get_name = " a3 (function argument 3)"; + if (i==14) get_name = " a4 (function argument 4)"; + if (i==15) get_name = " a5 (function argument 5)"; + if (i==16) get_name = " a6 (function argument 6)"; + if (i==17) get_name = " a7 (function argument 7)"; + if (i==18) get_name = " s2 (saved register 2)"; + if (i==19) get_name = " s3 (saved register 3)"; + if (i==20) get_name = " s4 (saved register 4)"; + if (i==21) get_name = " s5 (saved register 5)"; + if (i==22) get_name = " s6 (saved register 6)"; + if (i==23) get_name = " s7 (saved register 7)"; + if (i==24) get_name = " s8 (saved register 8)"; + if (i==25) get_name = " s9 (saved register 9)"; + if (i==26) get_name = " s10 (saved register 10)"; + if (i==27) get_name = " s11 (saved register 11)"; + if (i==28) get_name = " t3 (temporary register 3)"; + if (i==29) get_name = " t4 (temporary register 4)"; + if (i==30) get_name = " t5 (temporary register 5)"; + if (i==31) get_name = " t6 (temporary register 6)"; + endfunction + `endif + + // E extension limiting the register number to 16 localparam REGNUM = (RV32E) ? 16 : 32; // ISA registers 0-31 logic [XLEN-1:0] regs [REGNUM-1:0]; + // Tracer setup + `ifdef TRACE_REGISTERS + integer f; + string fname; + initial begin + $sformat(fname, "trace_%s.txt", "registers"); + f = $fopen(fname, "w"); + end + `endif generate @@ -120,7 +173,7 @@ module friscv_registers end else if (csr_rd_wr && csr_rd_addr==i) begin regs[i] = csr_rd_val; - // Access from data memory controller + // Access from processing units end else if (|proc_rd_wr) begin for (u=0;u> simulation.log rm -f tc.log @@ -264,7 +256,7 @@ run_tests() { cp ./friscv_testbench.vcd "./tests/$test_name.vcd" fi - # Create the trace of the C execution + # Create the trace of the C execution (function jumps) if [ -f "./trace_control.csv" ] && [ -f "tests/${test_name}.symbols" ]; then ../common/trace.py --itrace trace_control.csv \ --otrace "tests/${test_name}_trace.csv" \ @@ -323,6 +315,9 @@ check_status() { echo " - error count: $ec" echo " - testsuite status: $ts_ret" exit 1 + else + # OK, sounds good, exit gently + echo -e "${GREEN}SUCCESS: Testsuite successfully terminated ^^${NC}" fi } #------------------------------------------------------------------------------ @@ -336,18 +331,6 @@ get_args() { while [ "$1" != "" ]; do case $1 in - --cache_en ) - shift - CACHE_EN=$1 - ;; - --cache_block ) - shift - CACHE_BLOCK_W=$1 - ;; - -x | --xlen ) - shift - XLEN=$1 - ;; -c | --clean ) do_clean=1 ;; @@ -374,6 +357,10 @@ get_args() { shift SIM=$1 ;; + --cfg ) + shift + cfg_file=$1 + ;; --novcd ) shift NO_VCD=1 @@ -407,15 +394,13 @@ usage: bash ./run.sh ... -c | --clean Clean-up and exit -h | --help Brings up this menu --x | --xlen XLEN, 32 or 64 bits (32 bits by default) -t | --timeout Timeout in number of cycles before the simulation stops (10000 by default, 0 inactivate it) - --cache_en Enable instruction and data caches (Enabled by default) - --cache_block Cache line width in bits (128 bits by default) --tb 'core' or 'platform' ('core' by default) --tc A specific testcase to launch, can use wildcard if enclosed with ' (Run all by default) --simulator Choose between icarus or verilator (icarus is default) --novcd Don't dump VCD during simulation (Dump by default) --nocompile Don't try to compile C or assembler (CI tests only) + --cfg Pass a specific configuration files EOF } #------------------------------------------------------------------------------ diff --git a/test/common/run.sh b/test/common/run.sh deleted file mode 100755 index bec058d..0000000 --- a/test/common/run.sh +++ /dev/null @@ -1,62 +0,0 @@ -#!/usr/bin/env bash - -# distributed under the mit license -# https://opensource.org/licenses/mit-license.php - -# -e: exit if one command fails -# -o pipefail: causes a pipeline to fail if any command fails -# set -e -o pipefail - -#------------------------------------------------------------------------------ -# Variables and setup -#------------------------------------------------------------------------------ - -# Don't assert a testbench error if X31 is asserted -ERROR_STATUS_X31=1 - -source ../common/functions.sh - - -#------------------------------------------------------------------------------ -# Main -#------------------------------------------------------------------------------ - -main() { - - echo "INFO: Start RISCV Compliance Testsuite" - PID=$$ - echo "PID: $PID" - - get_args "$@" - - # Then clean temp files into testcase folders - if [ $do_clean -eq 1 ]; then clean; fi - - # Compile appplication if necessary - if [ $NO_COMPILE -eq 0 ]; then - if [ -n "$(find tests/ -maxdepth 1 -name \*.v -print -quit)" ] ; then - echo "INFO: Found compiled programs, execute ./run -C to rebuild from scratch" - else - set -e - make -C ./tests XLEN=$XLEN - set +e - fi - fi - - # If user specified a testcase, or a testsuite, use it - if [[ -n $TC ]]; then - run_testsuite "$TC" - # Else run all the supported testsuite - else - # Execute the testsuites - run_testsuite "./tests/rv32ui-p*.v" - if [[ -f "./tests/rv32um-p*.v" ]]; then run_testsuite "./tests/rv32um-p*.v"; fi - fi - - # OK, sounds good, exit gently - echo -e "${GREEN}SUCCESS: Testsuite successfully terminated ^^${NC}" - - exit 0 -} - -main "$@" diff --git a/test/priv_sec_testsuite/config.cfg b/test/priv_sec_testsuite/config.cfg new file mode 100644 index 0000000..17fb332 --- /dev/null +++ b/test/priv_sec_testsuite/config.cfg @@ -0,0 +1,6 @@ +XLEN,32 +CACHE_EN,1 +CACHE_BLOCK_W,128 +GEN_EIRQ,1 +ERROR_STATUS_X31,1 +USER_MODE,1 diff --git a/test/priv_sec_testsuite/run.sh b/test/priv_sec_testsuite/run.sh index 86974fc..eb74012 100755 --- a/test/priv_sec_testsuite/run.sh +++ b/test/priv_sec_testsuite/run.sh @@ -7,18 +7,10 @@ # -o pipefail: causes a pipeline to fail if any command fails # set -e -o pipefail -#------------------------------------------------------------------------------ -# Variables and setup -#------------------------------------------------------------------------------ - -# Don't assert a testbench error if X31 is asserted -ERROR_STATUS_X31=1 -# Generate an external IRQ on the EIRQ IO -GEN_EIRQ=1 +cfg_file="config.cfg" source ../common/functions.sh - #------------------------------------------------------------------------------ # Main #------------------------------------------------------------------------------ @@ -35,30 +27,24 @@ main() { if [ $do_clean -eq 1 ]; then clean; fi # Compile appplication if necessary - if [ $NO_COMPILE -eq 0 ]; then + if [ "$NO_COMPILE" -eq 0 ]; then if [ -n "$(find tests/ -maxdepth 1 -name \*.v -print -quit)" ] ; then echo "INFO: Found compiled programs, execute ./run -C to rebuild from scratch" else set -e - make -C ./tests XLEN=$XLEN + make -C ./tests XLEN=32 set +e fi fi # If user specified a testcase, or a testsuite, use it if [[ -n $TC ]]; then - run_testsuite "$TC" + run_testsuite "$TC" "$cfg_file" # Else run all the supported testsuite else # Execute the testsuites - run_testsuite "./tests/rv32ui-p*.v" - if [[ -f "./tests/rv32um-p*.v" ]]; then run_testsuite "./tests/rv32um-p*.v"; fi + run_testsuite "./tests/rv32ui-p*.v" "$cfg_file" fi - - # OK, sounds good, exit gently - echo -e "${GREEN}SUCCESS: Testsuite successfully terminated ^^${NC}" - - exit 0 } main "$@" diff --git a/test/riscv-tests/config.cfg b/test/riscv-tests/config.cfg new file mode 100644 index 0000000..dd5f6b4 --- /dev/null +++ b/test/riscv-tests/config.cfg @@ -0,0 +1,6 @@ +XLEN,32 +CACHE_EN,1 +CACHE_BLOCK_W,128 +GEN_EIRQ,1 +ERROR_STATUS_X31,1 +USER_MODE,0 diff --git a/test/riscv-tests/run.sh b/test/riscv-tests/run.sh deleted file mode 120000 index aee911b..0000000 --- a/test/riscv-tests/run.sh +++ /dev/null @@ -1 +0,0 @@ -../common/run.sh \ No newline at end of file diff --git a/test/riscv-tests/run.sh b/test/riscv-tests/run.sh new file mode 100755 index 0000000..7bd0eb1 --- /dev/null +++ b/test/riscv-tests/run.sh @@ -0,0 +1,58 @@ +#!/usr/bin/env bash + +# distributed under the mit license +# https://opensource.org/licenses/mit-license.php + +# -e: exit if one command fails +# -o pipefail: causes a pipeline to fail if any command fails +# set -e -o pipefail + +#------------------------------------------------------------------------------ +# Variables and setup +#------------------------------------------------------------------------------ + +cfg_file="config.cfg" +source ../common/functions.sh + + +#------------------------------------------------------------------------------ +# Main +#------------------------------------------------------------------------------ + +main() { + + echo "INFO: Start RISCV Compliance Testsuite" + PID=$$ + echo "PID: $PID" + + get_args "$@" + + # Then clean temp files into testcase folders + if [ $do_clean -eq 1 ]; then clean; fi + + # Compile appplication if necessary + if [ "$NO_COMPILE" -eq 0 ]; then + if [ -n "$(find tests/ -maxdepth 1 -name \*.v -print -quit)" ] ; then + echo "INFO: Found compiled programs, execute ./run -C to rebuild from scratch" + else + set -e + make -C ./tests + set +e + fi + fi + + # If user specified a testcase, or a testsuite, use it + if [[ -n $TC ]]; then + run_testsuite "$TC" "$cfg_file" + # Else run all the supported testsuite + else + # Execute the testsuites + run_testsuite "./tests/rv32ui-p*.v" "$cfg_file" + # Continue to execute if m extension tests exist + if [[ -f "./tests/rv32um-p*.v" ]]; then + run_testsuite "./tests/rv32um-p*.v" "$cfg_file" + fi + fi +} + +main "$@" diff --git a/test/wba_testsuite/config.cfg b/test/wba_testsuite/config.cfg new file mode 100644 index 0000000..dd5f6b4 --- /dev/null +++ b/test/wba_testsuite/config.cfg @@ -0,0 +1,6 @@ +XLEN,32 +CACHE_EN,1 +CACHE_BLOCK_W,128 +GEN_EIRQ,1 +ERROR_STATUS_X31,1 +USER_MODE,0 diff --git a/test/wba_testsuite/run.sh b/test/wba_testsuite/run.sh index 86974fc..eb74012 100755 --- a/test/wba_testsuite/run.sh +++ b/test/wba_testsuite/run.sh @@ -7,18 +7,10 @@ # -o pipefail: causes a pipeline to fail if any command fails # set -e -o pipefail -#------------------------------------------------------------------------------ -# Variables and setup -#------------------------------------------------------------------------------ - -# Don't assert a testbench error if X31 is asserted -ERROR_STATUS_X31=1 -# Generate an external IRQ on the EIRQ IO -GEN_EIRQ=1 +cfg_file="config.cfg" source ../common/functions.sh - #------------------------------------------------------------------------------ # Main #------------------------------------------------------------------------------ @@ -35,30 +27,24 @@ main() { if [ $do_clean -eq 1 ]; then clean; fi # Compile appplication if necessary - if [ $NO_COMPILE -eq 0 ]; then + if [ "$NO_COMPILE" -eq 0 ]; then if [ -n "$(find tests/ -maxdepth 1 -name \*.v -print -quit)" ] ; then echo "INFO: Found compiled programs, execute ./run -C to rebuild from scratch" else set -e - make -C ./tests XLEN=$XLEN + make -C ./tests XLEN=32 set +e fi fi # If user specified a testcase, or a testsuite, use it if [[ -n $TC ]]; then - run_testsuite "$TC" + run_testsuite "$TC" "$cfg_file" # Else run all the supported testsuite else # Execute the testsuites - run_testsuite "./tests/rv32ui-p*.v" - if [[ -f "./tests/rv32um-p*.v" ]]; then run_testsuite "./tests/rv32um-p*.v"; fi + run_testsuite "./tests/rv32ui-p*.v" "$cfg_file" fi - - # OK, sounds good, exit gently - echo -e "${GREEN}SUCCESS: Testsuite successfully terminated ^^${NC}" - - exit 0 } main "$@" diff --git a/test/wba_testsuite/tests/rv64ui/test5.S b/test/wba_testsuite/tests/rv64ui/test5.S index c50fd09..4f7d5e2 100644 --- a/test/wba_testsuite/tests/rv64ui/test5.S +++ b/test/wba_testsuite/tests/rv64ui/test5.S @@ -5,7 +5,7 @@ #include "test_macros.h" # Test 5: CSRs: Throttle execution by accessing the ISA CSRs -# +# # This testcase executes memory and arithmetic instructions break up by CSR # accesses. CSR instructions require several cycles to complete, thus could lead # to failure in control unit.