Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions src/sysc/core2sc_adapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -65,7 +66,7 @@ template <typename PLAT> 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<void(unsigned)>::from<this_class, &this_class::_set_mhartid>(this);
this->set_irq_count = util::delegate<void(unsigned)>::from<this_class, &this_class::_set_irq_num>(this);
this->get_arch_if = util::delegate<iss::arch_if*()>::from<this_class, &this_class::_get_arch_if>(this);
this->get_mode = util::delegate<uint32_t()>::from<this_class, &this_class::_get_mode>(this);
this->get_state = util::delegate<uint64_t()>::from<this_class, &this_class::_get_state>(this);
this->get_interrupt_execution = util::delegate<bool()>::from<this_class, &this_class::_get_interrupt_execution>(this);
Expand All @@ -84,7 +85,7 @@ template <typename PLAT> class core2sc_adapter : public PLAT, public sc2core_if

void setup_mt() override {
this->set_hartid = util::delegate<void(unsigned)>::from<this_class, &this_class::_set_mhartid_mt>(this);
this->set_irq_count = util::delegate<void(unsigned)>::from<this_class, &this_class::_set_irq_num_mt>(this);
this->get_arch_if = util::delegate<iss::arch_if*(void)>::from<this_class, &this_class::_get_arch_if>(this);
this->get_mode = util::delegate<uint32_t()>::from<this_class, &this_class::_get_mode_mt>(this);
this->get_state = util::delegate<uint64_t()>::from<this_class, &this_class::_get_state_mt>(this);
this->get_interrupt_execution = util::delegate<bool()>::from<this_class, &this_class::_get_interrupt_execution_mt>(this);
Expand Down Expand Up @@ -260,11 +261,7 @@ template <typename PLAT> 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<mutex_t> 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() {
Expand Down
20 changes: 8 additions & 12 deletions src/sysc/core_complex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,14 @@ template <unsigned int BUSWIDTH, typename QK> void core_complex<BUSWIDTH, QK>::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);
Expand Down Expand Up @@ -250,18 +258,6 @@ template <unsigned int BUSWIDTH, typename QK> core_complex<BUSWIDTH, QK>::~core_
template <unsigned int BUSWIDTH, typename QK> void core_complex<BUSWIDTH, QK>::trace(sc_trace_file* trf) const {}

template <unsigned int BUSWIDTH, typename QK> void core_complex<BUSWIDTH, QK>::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<core_wrapper>(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)
Expand Down
4 changes: 1 addition & 3 deletions src/sysc/core_complex.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class core_complex : public sc_core::sc_module, public scc::traceable, public co

sc_core::sc_in<bool> rst_i{"rst_i"};

sc_core::sc_vector<irq_signal_t> clint_irq_i{"clint_irq_i", 32};
sc_core::sc_vector<irq_signal_t> clint_irq_i{"clint_irq_i"};

#ifndef CWR_SYSTEMC
sc_core::sc_in<sc_core::sc_time> clk_i{"clk_i"};
Expand All @@ -122,8 +122,6 @@ class core_complex : public sc_core::sc_module, public scc::traceable, public co

cci::cci_param<uint32_t> mhartid{"mhartid", 0};

cci::cci_param<uint32_t> local_irq_num{"local_irq_num", 0};

cci::cci_param<std::string> plugins{"plugins", ""};

cci::cci_param<bool> post_run_stats{"post_run_stats", false};
Expand Down
2 changes: 1 addition & 1 deletion src/sysc/sc2core_if.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ struct sc2core_if {

virtual void enable_disass(bool enable) = 0;
util::delegate<void(unsigned)> set_hartid;
util::delegate<void(unsigned)> set_irq_count;
util::delegate<iss::arch_if*()> get_arch_if;
util::delegate<uint32_t()> get_mode;
util::delegate<uint64_t()> get_state;
util::delegate<bool()> get_interrupt_execution;
Expand Down