Skip to content

Commit

Permalink
Merge pull request #2314 from MikeOpenHWGroup/cv32e40s/vsim-take2
Browse files Browse the repository at this point in the history
Restore Questasim (vsim) simulations for cv32e40s (take 2)
  • Loading branch information
silabs-robin authored Jan 2, 2024
2 parents 84f314b + 007c77d commit 22a40ee
Show file tree
Hide file tree
Showing 18 changed files with 333 additions and 179 deletions.
4 changes: 3 additions & 1 deletion cv32e40s/env/corev-dv/cv32e40s_pma_cfg.sv
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ class cv32e40s_pma_cfg extends uvm_object;

`uvm_object_utils(cv32e40s_pma_cfg)

function new(string name="cv32e40s_pma_cfg");
function new(string name = "cv32e40s_pma_cfg");

pma_adapted_memory_regions_c pma_memory;

super.new(name);
pma_memory = new(CORE_PARAM_PMA_CFG);
foreach (pma_memory.region[i]) begin
Expand Down
2 changes: 1 addition & 1 deletion cv32e40s/env/corev-dv/ldgen/cv32e40s_ldgen.sv
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ function void cv32e40s_ldgen_c::create_memory_layout_file(string filepath);
$fdisplay(fhandle_mem, { "REGION_ALIAS(\"rom\", region_", $sformatf("%0d", boot_region), ");" });
$fdisplay(fhandle_mem, { "REGION_ALIAS(\"ram\", region_", $sformatf("%0d", writable_region_idx >= 0 ? writable_region_idx : 0), ");" });
end else begin
$fdisplay(fhandle_mem, { "REGION_ALIAS(\"rom\", ram);" });
$fdisplay(fhandle_mem, "REGION_ALIAS(\"rom\", ram);");
end

$fclose(fhandle_mem);
Expand Down
2 changes: 1 addition & 1 deletion cv32e40s/sim/tools/vsim/waves.tcl
Original file line number Diff line number Diff line change
@@ -1 +1 @@
log -r /uvmt_cv32_tb/*
log -r /uvmt_cv32e40s_tb/*
16 changes: 13 additions & 3 deletions cv32e40s/tb/assertions/uvmt_cv32e40s_umode_assert.sv
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@


module uvmt_cv32e40s_umode_assert
import uvm_pkg::*;
import cv32e40s_pkg::*;
import uvmt_cv32e40s_base_test_pkg::*;
import cv32e40s_rvfi_pkg::*;
import uvm_pkg::*;
import uvmt_cv32e40s_pkg::*;
#(
parameter bit CLIC
)(
Expand Down Expand Up @@ -932,6 +934,7 @@ module uvmt_cv32e40s_umode_assert

// vplan:InstrProt

`ifndef QUESTA_VSIM
a_rvfi_instr_prot: assert property (
rvfi_valid
|->
Expand All @@ -951,10 +954,12 @@ module uvmt_cv32e40s_umode_assert
a_prot_iside_legal: assert property (
obi_iside_prot inside {3'b 000, 3'b 110}
) else `uvm_error(info_tag, "the prot on fetch must be legal");
`endif // QUESTA_VSIM


// vplan:DataProt

`ifndef QUESTA_VSIM
// Questa cannot find rvfi_mem_prot
a_data_prot: assert property (
rvfi_valid &&
(rvfi_if.rvfi_mem_rmask || rvfi_if.rvfi_mem_wmask)
Expand All @@ -981,7 +986,10 @@ module uvmt_cv32e40s_umode_assert
mem_act[i] = |rvfi_if.check_mem_act(i);
end
end
`endif // QUESTA_VSIM

`ifndef QUESTA_VSIM
// Questa cannot find data_prot_equals & mem_act
a_data_prot_equal: assert property (
rvfi_valid &&
(|rvfi_if.rvfi_mem_rmask || |rvfi_if.rvfi_mem_wmask)
Expand All @@ -1000,10 +1008,11 @@ module uvmt_cv32e40s_umode_assert
($countones(mem_act) > 1) &&
(|rvfi_if.rvfi_mem_wmask)
);
`endif // QUESTA_VSIM


// vplan:DbgProt

`ifndef QUESTA_VSIM
a_dbg_prot_iside: assert property (
rvfi_if.rvfi_valid &&
rvfi_if.rvfi_dbg_mode
Expand All @@ -1019,6 +1028,7 @@ module uvmt_cv32e40s_umode_assert
|->
(rvfi_if.rvfi_mem_prot[2:1] == effective_rvfi_privmode)
) else `uvm_error(info_tag, "dmode should fetch as effective mode");
`endif // QUESTA_VSIM


endmodule : uvmt_cv32e40s_umode_assert
Expand Down
5 changes: 4 additions & 1 deletion cv32e40s/tb/uvmt/uvmt_cv32e40s_imperas_dummy_pkg.sv
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@

`ifndef __UVMT_CV32E40S_IMPERAS_DUMMY_PKG_SV__
`define __UVMT_CV32E40S_IMPERAS_DUMMY_PKG_SV__
import uvm_pkg::*;

package rvviApiPkg;
import uvm_pkg::*;

function int rvviRefShutdown();
`uvm_error("ISS_DUMMY", "USE_ISS=1 set but no ISS installation is available");
return 0;
Expand Down Expand Up @@ -52,6 +53,8 @@ module uvmt_cv32e40s_imperas_dv_wrap
endmodule : uvmt_cv32e40s_imperas_dv_wrap

interface uvmt_imperas_dv_if_t;
import uvm_pkg::*;

task ref_init;
`uvm_info("ISS_DUMMY", "ref_init called from uvmt_cv32e40s_imperas_dummy_pkg.sv", UVM_LOW);
endtask : ref_init
Expand Down
14 changes: 9 additions & 5 deletions cv32e40s/tb/uvmt/uvmt_cv32e40s_triggers_assert_cov.sv
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ module uvmt_cv32e40s_triggers_assert_cov
default clocking @(posedge clknrst_if.clk); endclocking
default disable iff !(clknrst_if.reset_n);

string info_tag = "TRIGGER ASSERT: ";
string info_tag = "TRIGGER_ASSERT";

/////////// Local Parameters ///////////

Expand Down Expand Up @@ -452,11 +452,15 @@ module uvmt_cv32e40s_triggers_assert_cov
//3) see a_dt_instr_trigger_hit_*, a_dt_load_trigger_hit_*, a_dt_store_trigger_hit_*, a_dt_exception_trigger_hit_*, a_dt_enter_dbg_reason

//4)
// MIKET: this assertion fires, and I think it should (so maybe that's an error?).
a_dt_tselect_higher_than_dbg_num_triggers: assert property(
rvfi_if.is_csr_instr(ADDR_TSELECT)
|->
rvfi_if.rvfi_rd1_wdata < CORE_PARAM_DBG_NUM_TRIGGERS
) else `uvm_error(info_tag, "The CSR tselect is set to equal or higher than the number of trigger.\n");
) else `uvm_error(info_tag,
$sformatf("The CSR tselect (0x%0x) is set to equal or higher than the number of trigger (0x%0x).\n",
$sampled(rvfi_if.rvfi_rd1_wdata), CORE_PARAM_DBG_NUM_TRIGGERS)
);


// Make sure the tdata1 array corresponds with the tdata1 csr.
Expand Down Expand Up @@ -941,6 +945,7 @@ module uvmt_cv32e40s_triggers_assert_cov


//1)
// MIKET: how does this property work?
a_dt_no_actions_on_trigger_matches_in_debug_dcsr: assert property (
rvfi_if.rvfi_valid
&& rvfi_if.rvfi_dbg_mode
Expand All @@ -949,6 +954,7 @@ module uvmt_cv32e40s_triggers_assert_cov
rvfi_if.is_csr_write(ADDR_DCSR)
) else `uvm_error(info_tag, "Action is taken when there is a trigger match while in debug mode (dcsr is changed even though we dont do a dcsr write operation).\n");

// MIKET: how does this property work?
a_dt_no_actions_on_trigger_matches_in_debug_dpc: assert property (
rvfi_if.rvfi_valid
&& rvfi_if.rvfi_dbg_mode
Expand Down Expand Up @@ -1316,20 +1322,18 @@ module uvmt_cv32e40s_triggers_assert_cov

//1)
a_dt_write_tdata2_random_in_dmode_type_2_6_15: assert property (

(seq_csr_write_dmode(ADDR_TDATA2)
##0 (tdata1_pre_state[MSB_TYPE:LSB_TYPE] == 2
|| tdata1_pre_state[MSB_TYPE:LSB_TYPE] == 6
|| tdata1_pre_state[MSB_TYPE:LSB_TYPE] == 15))

|->
(is_csrrw && (tdata2_post_state == rvfi_if.rvfi_rs1_rdata))
|| (is_csrrs && (tdata2_post_state == (tdata2_pre_state | rvfi_if.rvfi_rs1_rdata)))
|| (is_csrrc && (tdata2_post_state == (tdata2_pre_state & (~rvfi_if.rvfi_rs1_rdata))))
|| (is_csrrwi && (tdata2_post_state == csri_uimm))
|| (is_csrrsi && (tdata2_post_state == (tdata2_pre_state | csri_uimm)))
|| (is_csrrci && (tdata2_post_state == (tdata2_pre_state & (~csri_uimm))))

) else `uvm_error(info_tag, "Random values for tdata2 type 2/6/15 in debug mode, is not accepted.\n");


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ module uvmt_cv32e40s_xsecure_data_independent_timing_assert
//second branch instruction is retired.
//There is therefor only 1 empty cycle after a branch instruction.

`ifndef QUESTA_VSIM
// Questasim says: "Use of a method on an unclocked sequence is illegal"
sequence seq_no_mem_instr_for_cycles(x);
(!rvfi_if.is_mem_act)[*x];
endsequence
Expand Down Expand Up @@ -152,6 +154,7 @@ module uvmt_cv32e40s_xsecure_data_independent_timing_assert
//Make sure the DIV or REM can be calculated in one cycle only (indicating that data independent timing is off)
&& $past(rvfi_if.rvfi_valid)
);
`endif // QUESTA_VSIM

endmodule : uvmt_cv32e40s_xsecure_data_independent_timing_assert

2 changes: 1 addition & 1 deletion cv32e40s/tb/uvmt/uvmt_cv32e40s_zc_assert.sv
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ module uvmt_cv32e40s_zc_assert
// no subsequent suboperation of the instruction causes
// any activity on the data bus
property p_multiop_exception_stop_dbus(logic[31:0] ins_mask, logic[31:0] ins_ref);
(rvfi.rvfi_valid && rvfi.rvfi_trap[0] && rvfi.match_instr(ins_ref, ins_mask))
(rvfi.rvfi_valid && rvfi.rvfi_trap[0] && rvfi.rvfi_match_instr(ins_ref, ins_mask))
|->
support_if.req_after_exception == 0;

Expand Down
5 changes: 4 additions & 1 deletion cv32e40s/tests/uvmt/base-tests/uvmt_cv32e40s_base_test.sv
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class uvmt_cv32e40s_base_test_c extends uvm_test;
}

// Additional, temporary constraints to get around known design bugs/constraints
`include "uvmt_cv32e40s_base_test_workarounds.sv"
`include "uvmt_cv32e40s_base_test_constraint_workarounds.sv"


/**
Expand Down Expand Up @@ -250,6 +250,9 @@ function void uvmt_cv32e40s_base_test_c::end_of_elaboration_phase(uvm_phase phas
`uvm_info("BASE TEST", $sformatf("Top-level environment configuration:\n%s", env_cfg.sprint()), UVM_NONE)
`uvm_info("BASE TEST", $sformatf("Testcase configuration:\n%s", test_cfg.sprint()), UVM_NONE)

// Temporary hacks to get around known design bugs/constraints
`include "uvmt_cv32e40s_base_test_elaboration_workarounds.sv"

endfunction : end_of_elaboration_phase

task uvmt_cv32e40s_base_test_c::run_phase(uvm_phase phase);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// Copyright 2023 OpenHW Group
// SPDX-License-Identifier: Apache-2.0 WITH SHL-2.0
//
// Licensed under the Solderpad Hardware Licence, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://solderpad.org/licenses/
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

`ifndef __UVMT_CV32E40S_BASE_TEST_CONSTRAINT_WORKAROUNDS_SV__
`define __UVMT_CV32E40S_BASE_TEST_CONSTRAINT_WORKAROUNDS_SV__


// This file should be empty by the end of the project

`endif // __UVMT_CV32E40S_BASE_TEST_CONSTRAINT_WORKAROUNDS_SV__
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//
// Copyright 2023 OpenHW Group
// SPDX-License-Identifier: Apache-2.0 WITH SHL-2.1
//

`ifndef __UVMT_CV32E40S_BASE_TEST_ELABORATION_WORKAROUNDS_SV__
`define __UVMT_CV32E40S_BASE_TEST_ELABORATION_WORKAROUNDS_SV__


// This file is "`included" into the base-test end_of_elaboration function.
// This is a good place to add in hacks and workarounds during development.
// It should be empty by the end of the project.

////////////////////////////////////////////////////////////////////////////////
// Example things that you might find useful to be running immediately following elaboration:
//
// uvm_root::get().print_topology();
// uvm_root::get().set_report_verbosity_level_hier(UVM_HIGH);

////////////////////////////////////////////////////////////////////////////////
// Depreciate select errors to warnings.
//
// function void set_report_severity_id_override(uvm_severity cur_severity, string id, uvm_severity new_severity);
// Note that "id" is the first argument in `uvm_error(), `uvm_warning(), etc.

// A bunch of assertions in cv32e40s/tb/uvmt/uvmt_cv32e40s_triggers_assert_cov.sv
// are firing with Questasim (do they fire with other simulators?).
`ifdef QUESTA_VSIM
uvm_root::get().set_report_severity_id_override(UVM_ERROR,"TRIGGER_ASSERT",UVM_WARNING);
`endif // QUESTA_VSIM


`endif // __UVMT_CV32E40S_BASE_TEST_ELABORATION_WORKAROUNDS_SV__

This file was deleted.

Binary file modified cv32e40s/vendor_lib/verilab/svlib_dpi.so
Binary file not shown.
3 changes: 3 additions & 0 deletions lib/isa_decoder/isa_decoder.sv
Original file line number Diff line number Diff line change
Expand Up @@ -1534,9 +1534,12 @@
// ---------------------------------------------------------------------------
// Identify if a given instruction matches an expected instruction name
// ---------------------------------------------------------------------------
// FIXME: is this a redundant declaration of match_instr?
`ifndef QUESTA_VSIM
function automatic match_instr(instr_t instr, instr_name_e instr_type);
match_instr = (decode_instr(instr).instr == instr_type);
endfunction : match_instr
`endif // QUESTA_VSIM


//endpackage
Expand Down
Loading

0 comments on commit 22a40ee

Please sign in to comment.