mirror of
https://github.com/lowRISC/ibex.git
synced 2025-04-22 04:47:25 -04:00
[cosim] Pass Ibex config through for verilator cosim
This commit is contained in:
parent
7b1be3354d
commit
a788593842
3 changed files with 44 additions and 13 deletions
|
@ -2,7 +2,13 @@
|
|||
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
module ibex_simple_system_cosim_checker (
|
||||
module ibex_simple_system_cosim_checker #(
|
||||
parameter bit SecureIbex = 1'b0,
|
||||
parameter bit ICache = 1'b0,
|
||||
parameter bit PMPEnable = 1'b0,
|
||||
parameter int unsigned PMPGranularity = 0,
|
||||
parameter int unsigned PMPNumRegions = 4
|
||||
) (
|
||||
input clk_i,
|
||||
input rst_ni,
|
||||
|
||||
|
@ -18,11 +24,18 @@ module ibex_simple_system_cosim_checker (
|
|||
input logic host_dmem_err
|
||||
);
|
||||
import "DPI-C" function chandle get_spike_cosim;
|
||||
import "DPI-C" function void create_cosim(bit secure_ibex, bit icache_en,
|
||||
bit [31:0] pmp_num_regions, bit [31:0] pmp_granularity);
|
||||
|
||||
import ibex_pkg::*;
|
||||
|
||||
chandle cosim_handle;
|
||||
|
||||
initial begin
|
||||
localparam int unsigned LocalPMPGranularity = PMPEnable ? PMPGranularity : 0;
|
||||
localparam int unsigned LocalPMPNumRegions = PMPEnable ? PMPNumRegions : 0;
|
||||
|
||||
create_cosim(SecureIbex, ICache, LocalPMPNumRegions, LocalPMPGranularity);
|
||||
cosim_handle = get_spike_cosim();
|
||||
end
|
||||
|
||||
|
|
|
@ -3,8 +3,13 @@
|
|||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
module ibex_simple_system_cosim_checker_bind;
|
||||
bind ibex_simple_system ibex_simple_system_cosim_checker
|
||||
u_ibex_simple_system_cosim_checker_bind (
|
||||
bind ibex_simple_system ibex_simple_system_cosim_checker#(
|
||||
.SecureIbex,
|
||||
.ICache,
|
||||
.PMPEnable,
|
||||
.PMPGranularity,
|
||||
.PMPNumRegions
|
||||
) u_ibex_simple_system_cosim_checker_bind (
|
||||
.clk_i (IO_CLK),
|
||||
.rst_ni (IO_RST_N),
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
#include <svdpi.h>
|
||||
#include <cassert>
|
||||
#include <memory>
|
||||
#include "cosim.h"
|
||||
|
@ -18,6 +19,18 @@ class SimpleSystemCosim : public SimpleSystem {
|
|||
|
||||
~SimpleSystemCosim() {}
|
||||
|
||||
void CreateCosim(bool secure_ibex, bool icache_en, uint32_t pmp_num_regions,
|
||||
uint32_t pmp_granularity) {
|
||||
_cosim = std::make_unique<SpikeCosim>(
|
||||
GetIsaString(), 0x100080, 0x100001, "simple_system_cosim.log",
|
||||
secure_ibex, icache_en, pmp_num_regions, pmp_granularity);
|
||||
|
||||
_cosim->add_memory(0x100000, 1024 * 1024);
|
||||
_cosim->add_memory(0x20000, 4096);
|
||||
|
||||
CopyMemAreaToCosim(&_ram, 0x100000);
|
||||
}
|
||||
|
||||
protected:
|
||||
void CopyMemAreaToCosim(MemArea *area, uint32_t base_addr) {
|
||||
auto mem_data = area->Read(0, area->GetSizeWords());
|
||||
|
@ -30,16 +43,6 @@ class SimpleSystemCosim : public SimpleSystem {
|
|||
return ret_code;
|
||||
}
|
||||
|
||||
// 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);
|
||||
|
||||
CopyMemAreaToCosim(&_ram, 0x100000);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -58,8 +61,18 @@ SimpleSystemCosim *simple_system_cosim;
|
|||
extern "C" {
|
||||
void *get_spike_cosim() {
|
||||
assert(simple_system_cosim);
|
||||
assert(simple_system_cosim->_cosim);
|
||||
|
||||
return static_cast<Cosim *>(simple_system_cosim->_cosim.get());
|
||||
}
|
||||
|
||||
void create_cosim(svBit secure_ibex, svBit icache_en,
|
||||
const svBitVecVal *pmp_num_regions,
|
||||
const svBitVecVal *pmp_granularity) {
|
||||
assert(simple_system_cosim);
|
||||
simple_system_cosim->CreateCosim(secure_ibex, icache_en, pmp_num_regions[0],
|
||||
pmp_granularity[0]);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue