diff --git a/src/sysc/core2sc_adapter.h b/src/sysc/core2sc_adapter.h index 3118495..e8a3948 100644 --- a/src/sysc/core2sc_adapter.h +++ b/src/sysc/core2sc_adapter.h @@ -35,6 +35,7 @@ #ifndef _SYSC_CORE2SC_ADAPTER_H_ #define _SYSC_CORE2SC_ADAPTER_H_ +#include "iss/arch_if.h" #include "sc2core_if.h" #include "util/delegate.h" #include "util/logging.h" @@ -65,7 +66,7 @@ template class core2sc_adapter : public PLAT, public sc2core_if this->csr_rd_cb[iss::arch::timeh] = MK_CSR_RD_CB(read_time); this->memories.replace_last(*this); this->set_hartid = util::delegate::from(this); - this->set_irq_count = util::delegate::from(this); + this->get_arch_if = util::delegate::from(this); this->get_mode = util::delegate::from(this); this->get_state = util::delegate::from(this); this->get_interrupt_execution = util::delegate::from(this); @@ -84,7 +85,7 @@ template class core2sc_adapter : public PLAT, public sc2core_if void setup_mt() override { this->set_hartid = util::delegate::from(this); - this->set_irq_count = util::delegate::from(this); + this->get_arch_if = util::delegate::from(this); this->get_mode = util::delegate::from(this); this->get_state = util::delegate::from(this); this->get_interrupt_execution = util::delegate::from(this); @@ -260,11 +261,7 @@ template class core2sc_adapter : public PLAT, public sc2core_if PLAT::set_mhartid(id); } - void _set_irq_num(unsigned num) { PLAT::set_irq_num(num); } - void _set_irq_num_mt(unsigned num) { - std::unique_lock lock(sync_mtx); - PLAT::set_irq_num(num); - } + iss::arch_if* _get_arch_if() { return this; } uint32_t _get_mode() { return this->reg.PRIV; } uint32_t _get_mode_mt() { diff --git a/src/sysc/core_complex.cpp b/src/sysc/core_complex.cpp index 5294046..0b673f3 100644 --- a/src/sysc/core_complex.cpp +++ b/src/sysc/core_complex.cpp @@ -209,6 +209,14 @@ template void core_complex::i } }); + auto& type = GET_PROP_VALUE(core_type); + SCCDEBUG(SCMOD) << "instantiating core " << type << " with " << GET_PROP_VALUE(backend) << " backend"; + create_cpu(type, GET_PROP_VALUE(backend), GET_PROP_VALUE(gdb_server_port), GET_PROP_VALUE(mhartid)); + if(type == "?") + return; + sc_assert(vm); + auto xlen = core->get_arch_if()->get_instrumentation_if()->get_reg_size(/*x0*/ 0); + clint_irq_i.init(xlen); SC_HAS_PROCESS(this_class); // NOLINT SC_THREAD(run); SC_METHOD(rst_cb); @@ -250,18 +258,6 @@ template core_complex::~core_ template void core_complex::trace(sc_trace_file* trf) const {} template void core_complex::before_end_of_elaboration() { - auto& type = GET_PROP_VALUE(core_type); - SCCDEBUG(SCMOD) << "instantiating core " << type << " with " << GET_PROP_VALUE(backend) << " backend"; - // cpu = scc::make_unique(this); - create_cpu(type, GET_PROP_VALUE(backend), GET_PROP_VALUE(gdb_server_port), GET_PROP_VALUE(mhartid)); - if(type == "?") - return; -#ifndef CWR_SYSTEMC - if(!local_irq_num.is_default_value()) { - core->set_irq_count(16 + local_irq_num); - } -#endif - sc_assert(vm); auto instr_trace = GET_PROP_VALUE(enable_instr_trace) ? trc.init(this->name()) : false; auto disass = GET_PROP_VALUE(enable_disass); if(disass) diff --git a/src/sysc/core_complex.h b/src/sysc/core_complex.h index 8fcc37e..6693e3f 100644 --- a/src/sysc/core_complex.h +++ b/src/sysc/core_complex.h @@ -97,7 +97,7 @@ class core_complex : public sc_core::sc_module, public scc::traceable, public co sc_core::sc_in rst_i{"rst_i"}; - sc_core::sc_vector clint_irq_i{"clint_irq_i", 32}; + sc_core::sc_vector clint_irq_i{"clint_irq_i"}; #ifndef CWR_SYSTEMC sc_core::sc_in clk_i{"clk_i"}; @@ -122,8 +122,6 @@ class core_complex : public sc_core::sc_module, public scc::traceable, public co cci::cci_param mhartid{"mhartid", 0}; - cci::cci_param local_irq_num{"local_irq_num", 0}; - cci::cci_param plugins{"plugins", ""}; cci::cci_param post_run_stats{"post_run_stats", false}; diff --git a/src/sysc/sc2core_if.h b/src/sysc/sc2core_if.h index 44574ee..54b0a29 100644 --- a/src/sysc/sc2core_if.h +++ b/src/sysc/sc2core_if.h @@ -52,7 +52,7 @@ struct sc2core_if { virtual void enable_disass(bool enable) = 0; util::delegate set_hartid; - util::delegate set_irq_count; + util::delegate get_arch_if; util::delegate get_mode; util::delegate get_state; util::delegate get_interrupt_execution;