[dv,core_ibex] Add push_pull agent for Scramble IF

This allows us to actually use Icache in our tests beecause
before this commit key_valid was tied to 0 which means everytime
we receive a FENCE.I instruction, we wouldn't be able to successfully
flag inval_done. Which means we weren't probably using ICache correctly.

Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
This commit is contained in:
Canberk Topal 2022-07-27 11:18:49 +01:00 committed by Canberk Topal
parent e242ef07ad
commit cc55c47c37
7 changed files with 69 additions and 19 deletions

View file

@ -15,6 +15,7 @@ class core_ibex_env extends uvm_env;
`endif
core_ibex_vseqr vseqr;
core_ibex_env_cfg cfg;
scrambling_key_agent scrambling_key_agent_h;
`uvm_component_utils(core_ibex_env)
`uvm_component_new
@ -38,6 +39,12 @@ class core_ibex_env extends uvm_env;
cosim_agent = null;
end
`endif
scrambling_key_agent_h = scrambling_key_agent::type_id::create("scrambling_key_agent_h", this);
uvm_config_db#(scrambling_key_agent_cfg)::set(this, "scrambling_key_agent_h", "cfg",
cfg.scrambling_key_cfg);
cfg.scrambling_key_cfg.agent_type = push_pull_agent_pkg::PullAgent;
cfg.scrambling_key_cfg.if_mode = dv_utils_pkg::Device;
// Create virtual sequencer
vseqr = core_ibex_vseqr::type_id::create("vseqr", this);
endfunction : build_phase

View file

@ -4,16 +4,17 @@
class core_ibex_env_cfg extends uvm_object;
bit enable_irq_single_seq;
bit enable_irq_multiple_seq;
bit enable_irq_nmi_seq;
bit enable_nested_irq;
bit enable_debug_seq;
bit disable_cosim;
bit[31:0] max_interval;
bit require_signature_addr;
string signature_addr_str;
bit[31:0] signature_addr;
bit enable_irq_single_seq;
bit enable_irq_multiple_seq;
bit enable_irq_nmi_seq;
bit enable_nested_irq;
bit enable_debug_seq;
bit disable_cosim;
bit[31:0] max_interval;
bit require_signature_addr;
string signature_addr_str;
bit[31:0] signature_addr;
rand scrambling_key_agent_cfg scrambling_key_cfg;
`uvm_object_utils_begin(core_ibex_env_cfg)
`uvm_field_int(enable_irq_single_seq, UVM_DEFAULT)
@ -25,6 +26,7 @@ class core_ibex_env_cfg extends uvm_object;
`uvm_field_int(max_interval, UVM_DEFAULT)
`uvm_field_int(require_signature_addr, UVM_DEFAULT)
`uvm_field_int(signature_addr, UVM_DEFAULT)
`uvm_field_object(scrambling_key_cfg, UVM_DEFAULT)
`uvm_object_utils_end
function new(string name = "");
@ -39,6 +41,7 @@ class core_ibex_env_cfg extends uvm_object;
void'($value$plusargs("require_signature_addr=%0d", require_signature_addr));
void'($value$plusargs("signature_addr=%s", signature_addr_str));
signature_addr = signature_addr_str.atohex();
scrambling_key_cfg = scrambling_key_agent_cfg::type_id::create("scrambling_key_cfg");
endfunction
endclass

View file

@ -12,6 +12,14 @@ package core_ibex_env_pkg;
import ibex_mem_intf_agent_pkg::*;
import irq_agent_pkg::*;
import ibex_cosim_agent_pkg::*;
import push_pull_agent_pkg::*;
typedef push_pull_agent#(
.DeviceDataWidth(ibex_pkg::SCRAMBLE_NONCE_W + ibex_pkg::SCRAMBLE_KEY_W)
) scrambling_key_agent;
typedef push_pull_agent_cfg#(
.DeviceDataWidth(ibex_pkg::SCRAMBLE_NONCE_W + ibex_pkg::SCRAMBLE_KEY_W)
) scrambling_key_agent_cfg;
`include "core_ibex_vseqr.sv"
`include "core_ibex_env_cfg.sv"

View file

@ -12,6 +12,7 @@
+define+BOOT_ADDR=8000_0000
+define+TRACE_EXECUTION
+define+RVFI
+define+UVM
// Shared lowRISC code
+incdir+${LOWRISC_IP_DIR}/ip/prim/rtl
@ -33,6 +34,7 @@ ${LOWRISC_IP_DIR}/ip/prim/rtl/prim_secded_39_32_dec.sv
${LOWRISC_IP_DIR}/ip/prim/rtl/prim_secded_72_64_enc.sv
${LOWRISC_IP_DIR}/ip/prim/rtl/prim_secded_72_64_dec.sv
${LOWRISC_IP_DIR}/ip/prim/rtl/prim_onehot_check.sv
${LOWRISC_IP_DIR}/ip/prim/rtl/prim_mubi_pkg.sv
// Until this list is generated by FuseSoC, we have to use manually generated
// wrappers around the prim_* modules to instantiate the prim_generic_* ones,
@ -99,15 +101,20 @@ ${PRJ_DIR}/rtl/ibex_top_tracing.sv
// Core DV files
${PRJ_DIR}/vendor/google_riscv-dv/src/riscv_signature_pkg.sv
+incdir+${LOWRISC_IP_DIR}/dv/sv/dv_utils
+incdir+${LOWRISC_IP_DIR}/dv/sv/dv_base_reg
+incdir+${LOWRISC_IP_DIR}/dv/sv/csr_utils
+incdir+${LOWRISC_IP_DIR}/dv/sv/dv_lib
+incdir+${LOWRISC_IP_DIR}/dv/sv/mem_model
+incdir+${LOWRISC_IP_DIR}/dv/sv/push_pull_agent
+incdir+${LOWRISC_IP_DIR}/dv/sv/push_pull_agent/seq_lib
+incdir+${LOWRISC_IP_DIR}/dv/sv/str_utils
+incdir+${PRJ_DIR}/dv/uvm/core_ibex/env
+incdir+${PRJ_DIR}/dv/uvm/core_ibex/fcov
+incdir+${PRJ_DIR}/dv/uvm/core_ibex/tests
+incdir+${PRJ_DIR}/dv/uvm/core_ibex/common/ibex_mem_intf_agent
+incdir+${PRJ_DIR}/dv/uvm/core_ibex/common/irq_agent
+incdir+${PRJ_DIR}/dv/uvm/core_ibex/common/ibex_cosim_agent
+incdir+${LOWRISC_IP_DIR}/dv/sv/mem_model
+incdir+${LOWRISC_IP_DIR}/dv/sv/dv_utils
+incdir+${LOWRISC_IP_DIR}/dv/sv/str_utils
+incdir+${PRJ_DIR}/dv/cosim
${PRJ_DIR}/dv/uvm/bus_params_pkg/bus_params_pkg.sv
${LOWRISC_IP_DIR}/dv/sv/common_ifs/clk_rst_if.sv
@ -115,7 +122,12 @@ ${LOWRISC_IP_DIR}/dv/sv/common_ifs/pins_if.sv
${LOWRISC_IP_DIR}/dv/sv/str_utils/str_utils_pkg.sv
${LOWRISC_IP_DIR}/dv/sv/dv_utils/dv_test_status_pkg.sv
${LOWRISC_IP_DIR}/dv/sv/dv_utils/dv_utils_pkg.sv
${LOWRISC_IP_DIR}/dv/sv/dv_base_reg/dv_base_reg_pkg.sv
${LOWRISC_IP_DIR}/dv/sv/csr_utils/csr_utils_pkg.sv
${LOWRISC_IP_DIR}/dv/sv/dv_lib/dv_lib_pkg.sv
${LOWRISC_IP_DIR}/dv/sv/mem_model/mem_model_pkg.sv
${LOWRISC_IP_DIR}/dv/sv/push_pull_agent/push_pull_if.sv
${LOWRISC_IP_DIR}/dv/sv/push_pull_agent/push_pull_agent_pkg.sv
${PRJ_DIR}/dv/uvm/core_ibex/common/ibex_mem_intf_agent/ibex_mem_intf.sv
${PRJ_DIR}/dv/uvm/core_ibex/common/ibex_mem_intf_agent/ibex_mem_intf_agent_pkg.sv
${PRJ_DIR}/dv/uvm/core_ibex/common/irq_agent/irq_if.sv

View file

@ -10,7 +10,6 @@ module core_ibex_tb_top;
import core_ibex_test_pkg::*;
wire clk;
wire scramble_req;
wire rst_n;
clk_rst_if ibex_clk_if(.clk(clk), .rst_n(rst_n));
@ -69,6 +68,20 @@ module core_ibex_tb_top;
parameter bit ICacheScramble = 1'b0;
parameter bit DbgTriggerEn = 1'b0;
// Scrambling interface instantiation
logic [ibex_pkg::SCRAMBLE_KEY_W-1:0] scramble_key;
logic [ibex_pkg::SCRAMBLE_NONCE_W-1:0] scramble_nonce;
// Initiate push pull interface for connection between Ibex and a scrambling key provider.
push_pull_if #(
.DeviceDataWidth(ibex_pkg::SCRAMBLE_NONCE_W + ibex_pkg::SCRAMBLE_KEY_W)
) scrambling_key_if (
.clk(clk),
.rst_n(rst_n)
);
// key and nonce are driven by push_pull Device interface
assign {scramble_key, scramble_nonce} = scrambling_key_if.d_data;
ibex_top_tracing #(
.DmHaltAddr (32'h`BOOT_ADDR + 'h0 ),
@ -128,10 +141,10 @@ module core_ibex_tb_top;
.irq_fast_i (irq_vif.irq_fast ),
.irq_nm_i (irq_vif.irq_nm ),
.scramble_key_valid_i ('0 ),
.scramble_key_i ('0 ),
.scramble_nonce_i ('0 ),
.scramble_req_o ( ),
.scramble_key_valid_i (scrambling_key_if.ack ),
.scramble_key_i (scramble_key ),
.scramble_nonce_i (scramble_nonce ),
.scramble_req_o (scrambling_key_if.req ),
.debug_req_i (dut_if.debug_req ),
.crash_dump_o ( ),
@ -267,6 +280,8 @@ module core_ibex_tb_top;
uvm_config_db#(virtual irq_if)::set(null, "*", "vif", irq_vif);
uvm_config_db#(virtual core_ibex_ifetch_if)::set(null, "*", "ifetch_if", ifetch_if);
uvm_config_db#(virtual core_ibex_ifetch_pmp_if)::set(null, "*", "ifetch_pmp_if", ifetch_pmp_if);
uvm_config_db#(scrambling_key_vif)::set(
null, "*.env.scrambling_key_agent*", "vif", scrambling_key_if);
// Expose ISA config parameters to UVM DB
uvm_config_db#(bit)::set(null, "*", "RV32E", RV32E);

View file

@ -14,6 +14,7 @@ package core_ibex_test_pkg;
import riscv_signature_pkg::*;
import ibex_pkg::*;
import ibex_cosim_agent_pkg::*;
import push_pull_agent_pkg::*;
typedef struct {
ibex_pkg::opcode_e opcode;
@ -38,6 +39,10 @@ package core_ibex_test_pkg;
PickErr // Pick which memory to inject error in.
} error_type_e;
typedef virtual push_pull_if#(
.DeviceDataWidth(ibex_pkg::SCRAMBLE_NONCE_W + ibex_pkg::SCRAMBLE_KEY_W)
) scrambling_key_vif;
`include "core_ibex_report_server.sv"
`include "core_ibex_seq_lib.sv"
`include "core_ibex_new_seq_lib.sv"

View file

@ -198,7 +198,7 @@ module tb #(
end
// Initiate push pull interface for the OTP<->OTBN connections
// Initiate push pull interface for connection between Icache and a scrambling key provider.
push_pull_if #(
.DeviceDataWidth(194)
) scrambling_key_if (