mirror of
https://github.com/lowRISC/ibex.git
synced 2025-04-20 03:47:15 -04:00
[cosim] Pass PMP configuration through to spike
This commit is contained in:
parent
8282a0d244
commit
7e9eef2cf9
9 changed files with 46 additions and 11 deletions
|
@ -33,7 +33,8 @@
|
|||
|
||||
SpikeCosim::SpikeCosim(const std::string &isa_string, uint32_t start_pc,
|
||||
uint32_t start_mtvec, const std::string &trace_log_path,
|
||||
bool secure_ibex, bool icache_en)
|
||||
bool secure_ibex, bool icache_en,
|
||||
uint32_t pmp_num_regions, uint32_t pmp_granularity)
|
||||
: nmi_mode(false), pending_iside_error(false) {
|
||||
FILE *log_file = nullptr;
|
||||
if (trace_log_path.length() != 0) {
|
||||
|
@ -52,6 +53,8 @@ SpikeCosim::SpikeCosim(const std::string &isa_string, uint32_t start_pc,
|
|||
isa_parser.get(), DEFAULT_VARCH, this, 0, false, log_file, std::cerr);
|
||||
#endif
|
||||
|
||||
processor->set_pmp_num(pmp_num_regions);
|
||||
processor->set_pmp_granularity(1 << (pmp_granularity + 2));
|
||||
processor->set_ibex_flags(secure_ibex, icache_en);
|
||||
|
||||
processor->set_mmu_capability(IMPL_MMU_SBARE);
|
||||
|
|
|
@ -71,7 +71,8 @@ class SpikeCosim : public simif_t, public Cosim {
|
|||
public:
|
||||
SpikeCosim(const std::string &isa_string, uint32_t start_pc,
|
||||
uint32_t start_mtvec, const std::string &trace_log_path,
|
||||
bool secure_ibex, bool icache_en);
|
||||
bool secure_ibex, bool icache_en, uint32_t pmp_num_regions,
|
||||
uint32_t pmp_granularity);
|
||||
|
||||
// simif_t implementation
|
||||
virtual char *addr_to_mem(reg_t addr) override;
|
||||
|
|
|
@ -8,6 +8,8 @@ class core_ibex_cosim_cfg extends uvm_object;
|
|||
bit [31:0] start_mtvec;
|
||||
bit probe_imem_for_errs;
|
||||
string log_file;
|
||||
bit [31:0] pmp_num_regions;
|
||||
bit [31:0] pmp_granularity;
|
||||
|
||||
`uvm_object_utils_begin(core_ibex_cosim_cfg)
|
||||
`uvm_field_string(isa_string, UVM_DEFAULT)
|
||||
|
@ -15,6 +17,8 @@ class core_ibex_cosim_cfg extends uvm_object;
|
|||
`uvm_field_int(start_mtvec, UVM_DEFAULT)
|
||||
`uvm_field_int(probe_imem_for_errs, UVM_DEFAULT)
|
||||
`uvm_field_string(log_file, UVM_DEFAULT)
|
||||
`uvm_field_int(pmp_num_regions, UVM_DEFAULT)
|
||||
`uvm_field_int(pmp_granularity, UVM_DEFAULT)
|
||||
`uvm_object_utils_end
|
||||
|
||||
`uvm_object_new
|
||||
|
|
|
@ -61,7 +61,8 @@ class ibex_cosim_scoreboard extends uvm_scoreboard;
|
|||
cleanup_cosim();
|
||||
|
||||
// TODO: Ensure log file on reset gets append rather than overwrite?
|
||||
cosim_handle = spike_cosim_init(cfg.isa_string, cfg.start_pc, cfg.start_mtvec, cfg.log_file);
|
||||
cosim_handle = spike_cosim_init(cfg.isa_string, cfg.start_pc, cfg.start_mtvec, cfg.log_file,
|
||||
cfg.pmp_num_regions, cfg.pmp_granularity);
|
||||
|
||||
if (cosim_handle == null) begin
|
||||
`uvm_fatal(`gfn, "Could not initialise cosim")
|
||||
|
|
|
@ -10,8 +10,9 @@
|
|||
|
||||
extern "C" {
|
||||
void *spike_cosim_init(const char *isa_string, svBitVecVal *start_pc,
|
||||
svBitVecVal *start_mtvec,
|
||||
const char *log_file_path_cstr) {
|
||||
svBitVecVal *start_mtvec, const char *log_file_path_cstr,
|
||||
svBitVecVal *pmp_num_regions,
|
||||
svBitVecVal *pmp_granularity) {
|
||||
assert(isa_string);
|
||||
|
||||
std::string log_file_path;
|
||||
|
@ -20,8 +21,9 @@ void *spike_cosim_init(const char *isa_string, svBitVecVal *start_pc,
|
|||
log_file_path = log_file_path_cstr;
|
||||
}
|
||||
|
||||
SpikeCosim *cosim = new SpikeCosim(isa_string, start_pc[0], start_mtvec[0],
|
||||
log_file_path, false, true);
|
||||
SpikeCosim *cosim =
|
||||
new SpikeCosim(isa_string, start_pc[0], start_mtvec[0], log_file_path,
|
||||
false, true, pmp_num_regions[0], pmp_granularity[0]);
|
||||
cosim->add_memory(0x80000000, 0x80000000);
|
||||
cosim->add_memory(0x00000000, 0x80000000);
|
||||
return static_cast<Cosim *>(cosim);
|
||||
|
|
|
@ -9,7 +9,9 @@ import "DPI-C" function
|
|||
chandle spike_cosim_init(string isa_string,
|
||||
bit [31:0] start_pc,
|
||||
bit [31:0] start_mtvec,
|
||||
string log_file_path);
|
||||
string log_file_path,
|
||||
bit [31:0] pmp_num_regions,
|
||||
bit [31:0] pmp_granularity);
|
||||
|
||||
import "DPI-C" function void spike_cosim_release(chandle cosim_handle);
|
||||
|
||||
|
|
|
@ -289,6 +289,14 @@ module core_ibex_tb_top;
|
|||
uvm_config_db#(ibex_pkg::rv32m_e)::set(null, "*", "RV32M", RV32M);
|
||||
uvm_config_db#(ibex_pkg::rv32b_e)::set(null, "*", "RV32B", RV32B);
|
||||
|
||||
if (PMPEnable) begin
|
||||
uvm_config_db#(bit [31:0])::set(null, "*", "PMPNumRegions", PMPNumRegions);
|
||||
uvm_config_db#(bit [31:0])::set(null, "*", "PMPGranularity", PMPGranularity);
|
||||
end else begin
|
||||
uvm_config_db#(bit [31:0])::set(null, "*", "PMPNumRegions", 0);
|
||||
uvm_config_db#(bit [31:0])::set(null, "*", "PMPGranularity", 0);
|
||||
end
|
||||
|
||||
run_test();
|
||||
end
|
||||
|
||||
|
|
|
@ -81,6 +81,8 @@ class core_ibex_base_test extends uvm_test;
|
|||
|
||||
virtual function void build_phase(uvm_phase phase);
|
||||
string cosim_log_file;
|
||||
bit [31:0] pmp_num_regions;
|
||||
bit [31:0] pmp_granularity;
|
||||
|
||||
super.build_phase(phase);
|
||||
$value$plusargs("timeout_in_cycles=%0d", timeout_in_cycles);
|
||||
|
@ -112,6 +114,17 @@ class core_ibex_base_test extends uvm_test;
|
|||
void'($value$plusargs("cosim_log_file=%0s", cosim_log_file));
|
||||
cosim_cfg.log_file = cosim_log_file;
|
||||
|
||||
if (!uvm_config_db#(bit [31:0])::get(null, "", "PMPNumRegions", pmp_num_regions)) begin
|
||||
pmp_num_regions = '0;
|
||||
end
|
||||
|
||||
if (!uvm_config_db#(bit [31:0])::get(null, "", "PMPGranularity", pmp_granularity)) begin
|
||||
pmp_granularity = '0;
|
||||
end
|
||||
|
||||
cosim_cfg.pmp_num_regions = pmp_num_regions;
|
||||
cosim_cfg.pmp_granularity = pmp_granularity;
|
||||
|
||||
uvm_config_db#(core_ibex_cosim_cfg)::set(null, "*cosim_agent*", "cosim_cfg", cosim_cfg);
|
||||
`endif
|
||||
|
||||
|
|
|
@ -30,9 +30,10 @@ class SimpleSystemCosim : public SimpleSystem {
|
|||
return ret_code;
|
||||
}
|
||||
|
||||
_cosim =
|
||||
std::make_unique<SpikeCosim>(GetIsaString(), 0x100080, 0x100001,
|
||||
"simple_system_cosim.log", false, false);
|
||||
// TODO: Enable PMP in appropriate configurations
|
||||
_cosim = std::make_unique<SpikeCosim>(GetIsaString(), 0x100080, 0x100001,
|
||||
"simple_system_cosim.log", false,
|
||||
false, 0, 0);
|
||||
|
||||
_cosim->add_memory(0x100000, 1024 * 1024);
|
||||
_cosim->add_memory(0x20000, 4096);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue