Skip to content

Commit 628471f

Browse files
committed
moves core creation back into eoe call to allow use of CCI for configuration
1 parent 82eef55 commit 628471f

File tree

2 files changed

+23
-28
lines changed

2 files changed

+23
-28
lines changed

src/sysc/core_complex.cpp

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -180,13 +180,13 @@ void core_complex<BUSWIDTH, QK>::create_cpu(std::string const& type, std::string
180180

181181
#ifndef CWR_SYSTEMC
182182
template <unsigned int BUSWIDTH, typename QK>
183-
core_complex<BUSWIDTH, QK>::core_complex(sc_module_name const& name)
183+
core_complex<BUSWIDTH, QK>::core_complex(sc_module_name const& name, size_t clint_irq_size)
184184
: sc_module(name) {
185-
init();
185+
init(clint_irq_size);
186186
}
187187
#endif
188188

189-
template <unsigned int BUSWIDTH, typename QK> void core_complex<BUSWIDTH, QK>::init() {
189+
template <unsigned int BUSWIDTH, typename QK> void core_complex<BUSWIDTH, QK>::init(size_t clint_irq_size) {
190190
core_complex_if::exec_on_sysc = util::delegate<void(std::function<void(void)>&)>::from<this_class, &this_class::exec_on_sysc<QK>>(this);
191191
ibus.register_invalidate_direct_mem_ptr([this](uint64_t start, uint64_t end) -> void {
192192
auto lut_entry = fetch_lut.getEntry(start);
@@ -209,14 +209,7 @@ template <unsigned int BUSWIDTH, typename QK> void core_complex<BUSWIDTH, QK>::i
209209
}
210210
});
211211

212-
auto& type = GET_PROP_VALUE(core_type);
213-
SCCDEBUG(SCMOD) << "instantiating core " << type << " with " << GET_PROP_VALUE(backend) << " backend";
214-
create_cpu(type, GET_PROP_VALUE(backend), GET_PROP_VALUE(gdb_server_port), GET_PROP_VALUE(mhartid));
215-
if(type != "?") {
216-
sc_assert(vm);
217-
}
218-
auto xlen = type == "?" ? 32 : core->get_arch_if()->get_instrumentation_if()->get_reg_size(/*x0*/ 0);
219-
clint_irq_i.init(xlen);
212+
clint_irq_i.init(clint_irq_size);
220213
SC_HAS_PROCESS(this_class); // NOLINT
221214
SC_THREAD(run);
222215
SC_METHOD(rst_cb);
@@ -263,8 +256,14 @@ template <unsigned int BUSWIDTH, typename QK> core_complex<BUSWIDTH, QK>::~core_
263256
template <unsigned int BUSWIDTH, typename QK> void core_complex<BUSWIDTH, QK>::trace(sc_trace_file* trf) const {}
264257

265258
template <unsigned int BUSWIDTH, typename QK> void core_complex<BUSWIDTH, QK>::before_end_of_elaboration() {
266-
if(!core)
259+
auto& type = GET_PROP_VALUE(core_type);
260+
SCCDEBUG(SCMOD) << "instantiating core " << type << " with " << GET_PROP_VALUE(backend) << " backend";
261+
create_cpu(type, GET_PROP_VALUE(backend), GET_PROP_VALUE(gdb_server_port), GET_PROP_VALUE(mhartid));
262+
if(type != "?") {
263+
if(!core || !vm)
264+
SCCFATAL(SCOBJ) << "Could not create core " << type;
267265
return;
266+
}
268267
auto instr_trace = GET_PROP_VALUE(enable_instr_trace) ? trc.init(this->name()) : false;
269268
auto disass = GET_PROP_VALUE(enable_disass);
270269
if(disass)
@@ -543,12 +542,7 @@ bool core_complex<BUSWIDTH, QK>::write_mem_dbg(const addr_t& addr, unsigned leng
543542
gp.set_extension(new sysc::memspace::tlm_memspace_extension<>(static_cast<memspace::common>(addr.space)));
544543
return dbus->transport_dbg(gp) == length;
545544
}
546-
template <unsigned int BUSWIDTH, typename QK> util::range_lut<tlm_dmi_ext>& core_complex<BUSWIDTH, QK>::get_read_lut(unsigned space) {
547-
return get_lut(dmi_read_luts, space);
548-
};
549-
template <unsigned int BUSWIDTH, typename QK> util::range_lut<tlm_dmi_ext>& core_complex<BUSWIDTH, QK>::get_write_lut(unsigned space) {
550-
return get_lut(dmi_write_luts, space);
551-
};
545+
552546
template <unsigned int BUSWIDTH, typename QK>
553547
util::range_lut<tlm_dmi_ext>& core_complex<BUSWIDTH, QK>::get_lut(lut_vec_t& luts, unsigned space) {
554548
if(space >= luts.size()) {

src/sysc/core_complex.h

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ class core_complex : public sc_core::sc_module, public scc::traceable, public co
130130

131131
cci::cci_param<bool> post_run_stats{"post_run_stats", false};
132132

133-
core_complex(sc_core::sc_module_name const& name);
133+
core_complex(sc_core::sc_module_name const& name, size_t clint_irq_size = 32);
134134

135135
#else
136136
sc_core::sc_in<bool> clk_i{"clk_i"};
@@ -159,7 +159,7 @@ class core_complex : public sc_core::sc_module, public scc::traceable, public co
159159

160160
scml_property<bool> post_run_stats{"post_run_stats", false};
161161

162-
core_complex(sc_core::sc_module_name const& name)
162+
core_complex(sc_core::sc_module_name const& name, size_t clint_irq_size = 32)
163163
: sc_module(name)
164164
, local_irq_i{"local_irq_i", 16}
165165
, elf_file{"elf_file", ""}
@@ -170,11 +170,8 @@ class core_complex : public sc_core::sc_module, public scc::traceable, public co
170170
, gdb_server_port{"gdb_server_port", 0}
171171
, dump_ir{"dump_ir", false}
172172
, mhartid{"mhartid", 0}
173-
, plugins{"plugins", ""}
174-
, fetch_lut(tlm_dmi_ext())
175-
, read_lut(tlm_dmi_ext())
176-
, write_lut(tlm_dmi_ext()) {
177-
init();
173+
, plugins{"plugins", ""} {
174+
init(clint_irq_size);
178175
}
179176

180177
#endif
@@ -304,8 +301,12 @@ class core_complex : public sc_core::sc_module, public scc::traceable, public co
304301
///////////////////////////////////////////////////////////////////////////////
305302
uint64_t last_sync_cycle = 0;
306303
util::range_lut<tlm_dmi_ext> fetch_lut{tlm_dmi_ext()};
307-
inline util::range_lut<tlm_dmi_ext>& get_read_lut(unsigned space);
308-
inline util::range_lut<tlm_dmi_ext>& get_write_lut(unsigned space);
304+
util::range_lut<tlm_dmi_ext>& get_read_lut(unsigned space) {
305+
return space < dmi_read_luts.size() ? dmi_read_luts[space] : get_lut(dmi_read_luts, space);
306+
};
307+
util::range_lut<tlm_dmi_ext>& get_write_lut(unsigned space) {
308+
return space < dmi_write_luts.size() ? dmi_write_luts[space] : get_lut(dmi_write_luts, space);
309+
};
309310

310311
QK quantum_keeper;
311312
std::vector<uint8_t> write_buf;
@@ -320,7 +321,7 @@ class core_complex : public sc_core::sc_module, public scc::traceable, public co
320321
bool finish_evt_inuse{false};
321322

322323
private:
323-
void init();
324+
void init(size_t clint_irq_size);
324325
// we reserve for 8 memory spaces
325326
using lut_vec_t = std::vector<util::range_lut<tlm_dmi_ext>>;
326327
lut_vec_t dmi_read_luts{8, util::range_lut<tlm_dmi_ext>(tlm_dmi_ext())};

0 commit comments

Comments
 (0)