Fixup mem_intf seq to update cosim mem on DMEM uninit accesses

Give the sequence a handle to the cosim_agent, upon which it can call a method
to update the cosim memory model directly.
This required a small restructure of the mem_intf packages to prevent a circular dependency.
This commit is contained in:
Harry Callahan 2022-10-19 15:35:49 +01:00
parent ee0fd38e7d
commit a44d9827d7
8 changed files with 39 additions and 11 deletions

View file

@ -44,4 +44,11 @@ class ibex_cosim_agent extends uvm_agent;
function void write_mem_byte(bit [31:0] addr, bit [7:0] d);
riscv_cosim_write_mem_byte(scoreboard.cosim_handle, addr, d);
endfunction
function void write_mem_word(bit [31:0] addr, bit [DATA_WIDTH-1:0] d);
for (int i = 0; i < DATA_WIDTH / 8; i++) begin
write_mem_byte(addr + i, d[7:0]);
d = d >> 8;
end
endfunction
endclass : ibex_cosim_agent

View file

@ -4,7 +4,7 @@
package ibex_cosim_agent_pkg;
import uvm_pkg::*;
import ibex_mem_intf_agent_pkg::*;
import ibex_mem_intf_pkg::*;
`include "uvm_macros.svh"

View file

@ -5,16 +5,11 @@
package ibex_mem_intf_agent_pkg;
import uvm_pkg::*;
import ibex_mem_intf_pkg::*;
import mem_model_pkg::*;
parameter int DATA_WIDTH = 32;
parameter int ADDR_WIDTH = 32;
parameter int INTG_WIDTH = 7;
typedef enum { READ, WRITE } rw_e;
import ibex_cosim_agent_pkg::*;
`include "uvm_macros.svh"
`include "ibex_mem_intf_seq_item.sv"
typedef uvm_sequencer#(ibex_mem_intf_seq_item) ibex_mem_intf_request_sequencer;

View file

@ -0,0 +1,18 @@
// Copyright lowRISC contributors.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
package ibex_mem_intf_pkg;
import uvm_pkg::*;
parameter int DATA_WIDTH = 32;
parameter int ADDR_WIDTH = 32;
parameter int INTG_WIDTH = 7;
typedef enum { READ, WRITE } rw_e;
`include "uvm_macros.svh"
`include "ibex_mem_intf_seq_item.sv"
endpackage

View file

@ -10,6 +10,7 @@ class ibex_mem_intf_response_seq extends uvm_sequence #(ibex_mem_intf_seq_item);
ibex_mem_intf_seq_item item;
mem_model m_mem;
ibex_cosim_agent cosim_agent;
bit enable_error = 1'b0;
// Used to ensure that whenever inject_error() is called, the very next transaction will inject an
// error, and that enable_error will not be flipped back to 0 immediately
@ -114,11 +115,12 @@ class ibex_mem_intf_response_seq extends uvm_sequence #(ibex_mem_intf_seq_item);
if (is_dmem_seq) begin
// DMEM
`DV_CHECK_STD_RANDOMIZE_FATAL(data)
// Update mem_model with the randomized data.
// Update mem_model(s) with the randomized data.
`uvm_info(`gfn,
$sformatf("Addr is uninit! DMEM seq, returning random data 0x%0h", data),
UVM_MEDIUM)
write(addr, data);
write(addr, data); // Update UVM mem_model
cosim_agent.write_mem_word(addr, data); // Update cosim mem_model
return data;
end else begin
// IMEM

View file

@ -129,13 +129,14 @@ ${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/ibex_mem_intf_agent/ibex_mem_intf_pkg.sv
${PRJ_DIR}/dv/uvm/core_ibex/common/irq_agent/irq_if.sv
${PRJ_DIR}/dv/uvm/core_ibex/common/irq_agent/irq_agent_pkg.sv
${PRJ_DIR}/dv/uvm/core_ibex/env/core_ibex_rvfi_if.sv
${PRJ_DIR}/dv/uvm/core_ibex/common/ibex_cosim_agent/core_ibex_ifetch_if.sv
${PRJ_DIR}/dv/uvm/core_ibex/common/ibex_cosim_agent/core_ibex_ifetch_pmp_if.sv
${PRJ_DIR}/dv/uvm/core_ibex/common/ibex_cosim_agent/ibex_cosim_agent_pkg.sv
${PRJ_DIR}/dv/uvm/core_ibex/common/ibex_mem_intf_agent/ibex_mem_intf_agent_pkg.sv
${PRJ_DIR}/dv/uvm/core_ibex/env/core_ibex_instr_monitor_if.sv
${PRJ_DIR}/dv/uvm/core_ibex/env/core_ibex_dut_probe_if.sv
${PRJ_DIR}/dv/uvm/core_ibex/env/core_ibex_csr_if.sv

View file

@ -149,6 +149,10 @@ class core_ibex_base_test extends uvm_test;
vseq = core_ibex_vseq::type_id::create("vseq");
vseq.mem = mem;
vseq.cfg = cfg;
// Connect the data memory seq to the cosim agent
// This allows the cosim memory to be updated to match when we generate random data in
// response to a read from uninit memory.
vseq.data_intf_seq.cosim_agent = env.cosim_agent;
endfunction
virtual function void connect_phase(uvm_phase phase);

View file

@ -9,6 +9,7 @@ package core_ibex_test_pkg;
import uvm_pkg::*;
import core_ibex_env_pkg::*;
import ibex_mem_intf_pkg::*;
import ibex_mem_intf_agent_pkg::*;
import irq_agent_pkg::*;
import riscv_signature_pkg::*;