From 2bb60364343f9746479aeb4644c0483de902be1d Mon Sep 17 00:00:00 2001 From: dd-baoshan Date: Thu, 30 May 2024 15:47:00 +0800 Subject: [PATCH 1/6] Fix issue of debug entry during test_done by preventing load instr uses same xreg that having print_port value Signed-off-by: dd-baoshan --- cv32e40p/env/corev-dv/cv32e40p_debug_rom_gen.sv | 2 ++ cv32e40p/env/corev-dv/cv32e40p_instr_test_pkg.sv | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/cv32e40p/env/corev-dv/cv32e40p_debug_rom_gen.sv b/cv32e40p/env/corev-dv/cv32e40p_debug_rom_gen.sv index e340cf4729..1e8fe5262d 100644 --- a/cv32e40p/env/corev-dv/cv32e40p_debug_rom_gen.sv +++ b/cv32e40p/env/corev-dv/cv32e40p_debug_rom_gen.sv @@ -72,6 +72,8 @@ class cv32e40p_debug_rom_gen extends riscv_debug_rom_gen; end // Need to save off GPRs to avoid modifying program flow push_gpr_to_debugger_stack(cfg_corev, debug_main); + // workaround to handle issue if debug entry during test_done by preventing load instr uses xreg with print_port value + rand_xreg_after_push_gpr_to_debugger_stack(cfg_corev, debug_main); // Need to save off FPRs incase f-extension instructions are used to avoid modifying program flow if(cfg.enable_floating_point && !cfg.enable_fp_in_x_regs) begin diff --git a/cv32e40p/env/corev-dv/cv32e40p_instr_test_pkg.sv b/cv32e40p/env/corev-dv/cv32e40p_instr_test_pkg.sv index 630548bce4..03247d2d29 100644 --- a/cv32e40p/env/corev-dv/cv32e40p_instr_test_pkg.sv +++ b/cv32e40p/env/corev-dv/cv32e40p_instr_test_pkg.sv @@ -140,6 +140,19 @@ package cv32e40p_instr_test_pkg; end endfunction : push_gpr_to_debugger_stack + // workaround for issue of debug entry during test_done by preventing load instr uses same xreg that having print_port value + // note: this function must be called after push_gpr_to_debugger_stack() + function automatic void rand_xreg_after_push_gpr_to_debugger_stack(cv32e40p_instr_gen_config cfg_corev, + ref string instr[$]); + int unsigned total_gpr = 32; + for(int i = 1; i < total_gpr; i++) begin + logic [3:0] rand_nibble = $urandom_range(0,15); + if (i inside {cfg_corev.reserved_regs}) continue; + // set the xregs into higher ram space (refer .map file) + instr.push_back($sformatf("lui x%0d, 0x003F%1h000 >> 12 # rand_xreg_after_push_gpr_to_debugger_stack ", i, rand_nibble)); + end + endfunction : rand_xreg_after_push_gpr_to_debugger_stack + // Push floating point registers to the debugger stack function automatic void push_fpr_to_debugger_stack(cv32e40p_instr_gen_config cfg_corev, ref string instr[$], From ed11c2f06125e8102cfe4330ac89b2e890c83324 Mon Sep 17 00:00:00 2001 From: dd-baoshan Date: Mon, 3 Jun 2024 14:35:55 +0800 Subject: [PATCH 2/6] Fix xreg init touches tp in fp stream generation Signed-off-by: dd-baoshan --- cv32e40p/env/corev-dv/instr_lib/cv32e40p_float_instr_lib.sv | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cv32e40p/env/corev-dv/instr_lib/cv32e40p_float_instr_lib.sv b/cv32e40p/env/corev-dv/instr_lib/cv32e40p_float_instr_lib.sv index 2c5aadb877..9188d208a6 100644 --- a/cv32e40p/env/corev-dv/instr_lib/cv32e40p_float_instr_lib.sv +++ b/cv32e40p/env/corev-dv/instr_lib/cv32e40p_float_instr_lib.sv @@ -393,7 +393,9 @@ class cv32e40p_float_zfinx_base_instr_stream extends cv32e40p_base_instr_stream; logic [31:0] i_imm; for (int i=1; i<32; i++) begin riscv_reg_t i_gpr = riscv_reg_t'(i); + // if (i_gpr inside {cfg.reserved_regs}) continue; if (i == int'(cfg.sp)) continue; // do not alter stack pointer + if (i == int'(cfg.tp)) continue; // do not alter thread pointer if (cfg.gen_debug_section) begin if (i == int'(cfg_cv32e40p.dp)) continue; // do not alter debug pointer end From 615a0f6cd22b3055726d6843e4515455dac937eb Mon Sep 17 00:00:00 2001 From: dd-baoshan Date: Mon, 3 Jun 2024 14:37:05 +0800 Subject: [PATCH 3/6] Fix hwloop cvg model miss hanlded on concurrent events for debug trigger and exception entry Signed-off-by: dd-baoshan --- cv32e40p/env/uvme/cov/uvme_rv32x_hwloop_covg.sv | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/cv32e40p/env/uvme/cov/uvme_rv32x_hwloop_covg.sv b/cv32e40p/env/uvme/cov/uvme_rv32x_hwloop_covg.sv index b4d56eac15..9678860afc 100644 --- a/cv32e40p/env/uvme/cov/uvme_rv32x_hwloop_covg.sv +++ b/cv32e40p/env/uvme/cov/uvme_rv32x_hwloop_covg.sv @@ -951,8 +951,7 @@ class uvme_rv32x_hwloop_covg # ( if (enter_hwloop_sub) begin enter_hwloop_sub_cnt++; if (is_trap && is_dbg_mode && !cv32e40p_rvvi_vif.csr_dcsr_step && enter_hwloop_sub_cnt == 1) begin : TRAP_DUETO_DBG_ENTRY // exception trap and debug are b2b cycles (except debug step) - has_pending_trap_due2_dbg = 1; is_trap = 0; - enter_hwloop_sub = 0; enter_hwloop_sub_cnt = 0; + has_pending_trap_due2_dbg = 1; end // TRAP_DUETO_DBG_ENTRY else if (pc_is_mtvec_addr() && !is_mcause_irq()) begin : EXCEPTION_ENTRY for (int i=0; i Date: Tue, 4 Jun 2024 10:53:24 +0800 Subject: [PATCH 4/6] Improve dly contraints Signed-off-by: dd-baoshan --- cv32e40p/env/uvme/vseq/uvme_cv32e40p_random_debug_vseq.sv | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cv32e40p/env/uvme/vseq/uvme_cv32e40p_random_debug_vseq.sv b/cv32e40p/env/uvme/vseq/uvme_cv32e40p_random_debug_vseq.sv index 3764bb2392..89d4e59fec 100644 --- a/cv32e40p/env/uvme/vseq/uvme_cv32e40p_random_debug_vseq.sv +++ b/cv32e40p/env/uvme/vseq/uvme_cv32e40p_random_debug_vseq.sv @@ -69,7 +69,7 @@ class uvme_cv32e40p_reduced_rand_debug_req_c extends uvme_cv32e40p_random_debug_ constraint default_dly_c { if (num_of_debug_req == 1) dly inside {[200:2000]}; - else dly inside {[500:10000]}; + else dly inside {[2500:10000]}; } constraint num_dgb_req_c { @@ -85,12 +85,13 @@ function uvme_cv32e40p_reduced_rand_debug_req_c::new(string name="uvme_cv32e40p_ super.new(name); if ($value$plusargs("num_debug_req=%0d",num_of_debug_req)) begin num_of_debug_req.rand_mode(0); + num_dgb_req_c.constraint_mode(0); end endfunction : new task uvme_cv32e40p_reduced_rand_debug_req_c::rand_delay(); - if (! std::randomize(dly) with { dly inside {[1:10000]}; } ) begin - `uvm_fatal("RAND_DEBUG_RAND_DELAY", "Cannot randomize dly") + if (!this.randomize()) begin + `uvm_fatal("RAND_DEBUG_RAND_DELAY", "Randomization Failed") end #(dly); endtask : rand_delay From f18479f2dfe5f6ddec8b72515d810f2ecccd131a Mon Sep 17 00:00:00 2001 From: dd-baoshan Date: Tue, 4 Jun 2024 10:55:08 +0800 Subject: [PATCH 5/6] Fix timeout issue due to massive dbg req events Signed-off-by: dd-baoshan --- .../programs/corev-dv/corev_rand_fp_instr_debug/test.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cv32e40p/tests/programs/corev-dv/corev_rand_fp_instr_debug/test.yaml b/cv32e40p/tests/programs/corev-dv/corev_rand_fp_instr_debug/test.yaml index 533e8dceed..f4a3333260 100644 --- a/cv32e40p/tests/programs/corev-dv/corev_rand_fp_instr_debug/test.yaml +++ b/cv32e40p/tests/programs/corev-dv/corev_rand_fp_instr_debug/test.yaml @@ -7,6 +7,7 @@ uvm_test: uvmt_$(CV_CORE_LC)_firmware_test_c description: > Random debug in fp instruction stream plusargs: > - +gen_random_debug - # +gen_reduced_rand_dbg_req -> produce not many dbg_req + +gen_reduced_rand_dbg_req + +num_debug_req=1000 + # +gen_reduced_rand_dbg_req -> produce not many dbg_req, use num_debug_req to indicate intended repetitive number # +gen_random_debug -> produce many dbg_req From 7c4a591901216eb36a75d2cf2c2c23b2c016d5fc Mon Sep 17 00:00:00 2001 From: dd-baoshan Date: Tue, 4 Jun 2024 16:34:44 +0800 Subject: [PATCH 6/6] Minor update on randomization Signed-off-by: dd-baoshan --- cv32e40p/env/uvme/vseq/uvme_cv32e40p_random_debug_vseq.sv | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cv32e40p/env/uvme/vseq/uvme_cv32e40p_random_debug_vseq.sv b/cv32e40p/env/uvme/vseq/uvme_cv32e40p_random_debug_vseq.sv index 89d4e59fec..dac2ad0c03 100644 --- a/cv32e40p/env/uvme/vseq/uvme_cv32e40p_random_debug_vseq.sv +++ b/cv32e40p/env/uvme/vseq/uvme_cv32e40p_random_debug_vseq.sv @@ -90,8 +90,8 @@ function uvme_cv32e40p_reduced_rand_debug_req_c::new(string name="uvme_cv32e40p_ endfunction : new task uvme_cv32e40p_reduced_rand_debug_req_c::rand_delay(); - if (!this.randomize()) begin - `uvm_fatal("RAND_DEBUG_RAND_DELAY", "Randomization Failed") + if (!std::randomize(dly) with {dly inside {[2500:10000]};}) begin + `uvm_fatal("RAND_DEBUG_RAND_DELAY", "Randomization dly Failed") end #(dly); endtask : rand_delay