Compare commits
9 Commits
a45fcd28db
...
76ea0db25d
Author | SHA1 | Date | |
---|---|---|---|
76ea0db25d | |||
ec1b820c18 | |||
64329cf0f6 | |||
9de0aed84d | |||
bb4e2766d1 | |||
0996d15bd4 | |||
6305efa7c2 | |||
de79adc50d | |||
0473aa5344 |
@ -20,6 +20,7 @@ set(LIB_SOURCES
|
|||||||
src/iss/arch/tgc5c.cpp
|
src/iss/arch/tgc5c.cpp
|
||||||
src/vm/interp/vm_tgc5c.cpp
|
src/vm/interp/vm_tgc5c.cpp
|
||||||
src/vm/fp_functions.cpp
|
src/vm/fp_functions.cpp
|
||||||
|
src/iss/debugger/csr_names.cpp
|
||||||
src/iss/semihosting/semihosting.cpp
|
src/iss/semihosting/semihosting.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -257,10 +257,14 @@ typename vm_base<ARCH>::virt_addr_t vm_impl<ARCH>::execute_inst(finish_cond_e co
|
|||||||
while(!this->core.should_stop() &&
|
while(!this->core.should_stop() &&
|
||||||
!(is_icount_limit_enabled(cond) && icount >= count_limit) &&
|
!(is_icount_limit_enabled(cond) && icount >= count_limit) &&
|
||||||
!(is_fcount_limit_enabled(cond) && fetch_count >= count_limit)){
|
!(is_fcount_limit_enabled(cond) && fetch_count >= count_limit)){
|
||||||
fetch_count++;
|
if(this->debugging_enabled())
|
||||||
|
this->tgt_adapter->check_continue(*PC);
|
||||||
|
pc.val=*PC;
|
||||||
if(fetch_ins(pc, data)!=iss::Ok){
|
if(fetch_ins(pc, data)!=iss::Ok){
|
||||||
this->do_sync(POST_SYNC, std::numeric_limits<unsigned>::max());
|
if(this->sync_exec && PRE_SYNC) this->do_sync(PRE_SYNC, std::numeric_limits<unsigned>::max());
|
||||||
pc.val = super::core.enter_trap(std::numeric_limits<uint64_t>::max(), pc.val, 0);
|
process_spawn_blocks();
|
||||||
|
if(this->sync_exec && POST_SYNC) this->do_sync(PRE_SYNC, std::numeric_limits<unsigned>::max());
|
||||||
|
pc.val = super::core.enter_trap(arch::traits<ARCH>::RV_CAUSE_FETCH_ACCESS<<16, pc.val, 0);
|
||||||
} else {
|
} else {
|
||||||
if (is_jump_to_self_enabled(cond) &&
|
if (is_jump_to_self_enabled(cond) &&
|
||||||
(instr == 0x0000006f || (instr&0xffff)==0xa001)) throw simulation_stopped(0); // 'J 0' or 'C.J 0'
|
(instr == 0x0000006f || (instr&0xffff)==0xa001)) throw simulation_stopped(0); // 'J 0' or 'C.J 0'
|
||||||
@ -311,11 +315,11 @@ typename vm_base<ARCH>::virt_addr_t vm_impl<ARCH>::execute_inst(finish_cond_e co
|
|||||||
icount++;
|
icount++;
|
||||||
instret++;
|
instret++;
|
||||||
}
|
}
|
||||||
cycle++;
|
*PC = *NEXT_PC;
|
||||||
pc.val=*NEXT_PC;
|
|
||||||
this->core.reg.PC = this->core.reg.NEXT_PC;
|
|
||||||
this->core.reg.trap_state = this->core.reg.pending_trap;
|
this->core.reg.trap_state = this->core.reg.pending_trap;
|
||||||
}
|
}
|
||||||
|
fetch_count++;
|
||||||
|
cycle++;
|
||||||
}
|
}
|
||||||
return pc;
|
return pc;
|
||||||
}
|
}
|
||||||
|
@ -204,7 +204,7 @@ private:
|
|||||||
};
|
};
|
||||||
this->builder.CreateCall(this->mod->getFunction("print_disass"), args);
|
this->builder.CreateCall(this->mod->getFunction("print_disass"), args);
|
||||||
}
|
}
|
||||||
this->gen_sync(iss::PRE_SYNC, instr_descr.size());
|
this->gen_sync(iss::PRE_SYNC, instr_descr.size());
|
||||||
this->builder.CreateStore(this->builder.CreateLoad(this->get_typeptr(traits::NEXT_PC), get_reg_ptr(traits::NEXT_PC), true),
|
this->builder.CreateStore(this->builder.CreateLoad(this->get_typeptr(traits::NEXT_PC), get_reg_ptr(traits::NEXT_PC), true),
|
||||||
get_reg_ptr(traits::PC), true);
|
get_reg_ptr(traits::PC), true);
|
||||||
this->builder.CreateStore(
|
this->builder.CreateStore(
|
||||||
|
@ -278,7 +278,7 @@ public:
|
|||||||
|
|
||||||
void disass_output(uint64_t pc, const std::string instr) override {
|
void disass_output(uint64_t pc, const std::string instr) override {
|
||||||
NSCLOG(INFO, LOGCAT) << fmt::format("0x{:016x} {:40} [s:0x{:x};c:{}]", pc, instr, (reg_t)state.mstatus,
|
NSCLOG(INFO, LOGCAT) << fmt::format("0x{:016x} {:40} [s:0x{:x};c:{}]", pc, instr, (reg_t)state.mstatus,
|
||||||
this->reg.icount + cycle_offset);
|
this->reg.cycle + cycle_offset);
|
||||||
};
|
};
|
||||||
|
|
||||||
iss::instrumentation_if* get_instrumentation_if() override { return &instr_if; }
|
iss::instrumentation_if* get_instrumentation_if() override { return &instr_if; }
|
||||||
@ -311,7 +311,7 @@ protected:
|
|||||||
|
|
||||||
uint64_t get_pendig_traps() override { return arch.reg.trap_state; }
|
uint64_t get_pendig_traps() override { return arch.reg.trap_state; }
|
||||||
|
|
||||||
uint64_t get_total_cycles() override { return arch.reg.icount + arch.cycle_offset; }
|
uint64_t get_total_cycles() override { return arch.reg.cycle + arch.cycle_offset; }
|
||||||
|
|
||||||
void update_last_instr_cycles(unsigned cycles) override { arch.cycle_offset += cycles - 1; }
|
void update_last_instr_cycles(unsigned cycles) override { arch.cycle_offset += cycles - 1; }
|
||||||
|
|
||||||
@ -602,7 +602,7 @@ std::pair<uint64_t, bool> riscv_hart_m_p<BASE, FEAT, LOGCAT>::load_file(std::str
|
|||||||
if(reader.get_machine() != EM_RISCV)
|
if(reader.get_machine() != EM_RISCV)
|
||||||
throw std::runtime_error("wrong elf machine in file");
|
throw std::runtime_error("wrong elf machine in file");
|
||||||
auto entry = reader.get_entry();
|
auto entry = reader.get_entry();
|
||||||
for(const auto pseg : reader.segments) {
|
for(const auto& pseg : reader.segments) {
|
||||||
const auto fsize = pseg->get_file_size(); // 0x42c/0x0
|
const auto fsize = pseg->get_file_size(); // 0x42c/0x0
|
||||||
const auto seg_data = pseg->get_data();
|
const auto seg_data = pseg->get_data();
|
||||||
const auto type = pseg->get_type();
|
const auto type = pseg->get_type();
|
||||||
@ -689,8 +689,10 @@ iss::status riscv_hart_m_p<BASE, FEAT, LOGCAT>::read(const address_type type, co
|
|||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
} catch(trap_access& ta) {
|
} catch(trap_access& ta) {
|
||||||
this->reg.trap_state = (1UL << 31) | ta.id;
|
if((access & access_type::DEBUG) == 0) {
|
||||||
fault_data = ta.addr;
|
this->reg.trap_state = (1UL << 31) | ta.id;
|
||||||
|
fault_data = ta.addr;
|
||||||
|
}
|
||||||
return iss::Err;
|
return iss::Err;
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
@ -717,8 +719,10 @@ iss::status riscv_hart_m_p<BASE, FEAT, LOGCAT>::read(const address_type type, co
|
|||||||
}
|
}
|
||||||
return iss::Ok;
|
return iss::Ok;
|
||||||
} catch(trap_access& ta) {
|
} catch(trap_access& ta) {
|
||||||
this->reg.trap_state = (1UL << 31) | ta.id;
|
if((access & access_type::DEBUG) == 0) {
|
||||||
fault_data = ta.addr;
|
this->reg.trap_state = (1UL << 31) | ta.id;
|
||||||
|
fault_data = ta.addr;
|
||||||
|
}
|
||||||
return iss::Err;
|
return iss::Err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -848,8 +852,10 @@ iss::status riscv_hart_m_p<BASE, FEAT, LOGCAT>::write(const address_type type, c
|
|||||||
}
|
}
|
||||||
return iss::Ok;
|
return iss::Ok;
|
||||||
} catch(trap_access& ta) {
|
} catch(trap_access& ta) {
|
||||||
this->reg.trap_state = (1UL << 31) | ta.id;
|
if((access & access_type::DEBUG) == 0) {
|
||||||
fault_data = ta.addr;
|
this->reg.trap_state = (1UL << 31) | ta.id;
|
||||||
|
fault_data = ta.addr;
|
||||||
|
}
|
||||||
return iss::Err;
|
return iss::Err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -902,7 +908,7 @@ iss::status riscv_hart_m_p<BASE, FEAT, LOGCAT>::write_plain(unsigned addr, reg_t
|
|||||||
|
|
||||||
template <typename BASE, features_e FEAT, typename LOGCAT>
|
template <typename BASE, features_e FEAT, typename LOGCAT>
|
||||||
iss::status riscv_hart_m_p<BASE, FEAT, LOGCAT>::read_cycle(unsigned addr, reg_t& val) {
|
iss::status riscv_hart_m_p<BASE, FEAT, LOGCAT>::read_cycle(unsigned addr, reg_t& val) {
|
||||||
auto cycle_val = this->reg.icount + cycle_offset;
|
auto cycle_val = this->reg.cycle + cycle_offset;
|
||||||
if(addr == mcycle) {
|
if(addr == mcycle) {
|
||||||
val = static_cast<reg_t>(cycle_val);
|
val = static_cast<reg_t>(cycle_val);
|
||||||
} else if(addr == mcycleh) {
|
} else if(addr == mcycleh) {
|
||||||
@ -922,7 +928,7 @@ iss::status riscv_hart_m_p<BASE, FEAT, LOGCAT>::write_cycle(unsigned addr, reg_t
|
|||||||
mcycle_csr = (static_cast<uint64_t>(val) << 32) + (mcycle_csr & 0xffffffff);
|
mcycle_csr = (static_cast<uint64_t>(val) << 32) + (mcycle_csr & 0xffffffff);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cycle_offset = mcycle_csr - this->reg.icount; // TODO: relying on wrap-around
|
cycle_offset = mcycle_csr - this->reg.cycle; // TODO: relying on wrap-around
|
||||||
return iss::Ok;
|
return iss::Ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -953,7 +959,7 @@ iss::status riscv_hart_m_p<BASE, FEAT, LOGCAT>::write_instret(unsigned addr, reg
|
|||||||
|
|
||||||
template <typename BASE, features_e FEAT, typename LOGCAT>
|
template <typename BASE, features_e FEAT, typename LOGCAT>
|
||||||
iss::status riscv_hart_m_p<BASE, FEAT, LOGCAT>::read_time(unsigned addr, reg_t& val) {
|
iss::status riscv_hart_m_p<BASE, FEAT, LOGCAT>::read_time(unsigned addr, reg_t& val) {
|
||||||
uint64_t time_val = this->reg.icount / (100000000 / 32768 - 1); //-> ~3052;
|
uint64_t time_val = this->reg.cycle / (100000000 / 32768 - 1); //-> ~3052;
|
||||||
if(addr == time) {
|
if(addr == time) {
|
||||||
val = static_cast<reg_t>(time_val);
|
val = static_cast<reg_t>(time_val);
|
||||||
} else if(addr == timeh) {
|
} else if(addr == timeh) {
|
||||||
|
@ -328,7 +328,7 @@ public:
|
|||||||
|
|
||||||
void disass_output(uint64_t pc, const std::string instr) override {
|
void disass_output(uint64_t pc, const std::string instr) override {
|
||||||
CLOG(INFO, disass) << fmt::format("0x{:016x} {:40} [p:{};s:0x{:x};c:{}]", pc, instr, lvl[this->reg.PRIV], (reg_t)state.mstatus,
|
CLOG(INFO, disass) << fmt::format("0x{:016x} {:40} [p:{};s:0x{:x};c:{}]", pc, instr, lvl[this->reg.PRIV], (reg_t)state.mstatus,
|
||||||
this->reg.icount + cycle_offset);
|
this->reg.cycle + cycle_offset);
|
||||||
};
|
};
|
||||||
|
|
||||||
iss::instrumentation_if* get_instrumentation_if() override { return &instr_if; }
|
iss::instrumentation_if* get_instrumentation_if() override { return &instr_if; }
|
||||||
@ -361,7 +361,7 @@ protected:
|
|||||||
|
|
||||||
uint64_t get_pendig_traps() override { return arch.reg.trap_state; }
|
uint64_t get_pendig_traps() override { return arch.reg.trap_state; }
|
||||||
|
|
||||||
uint64_t get_total_cycles() override { return arch.reg.icount + arch.cycle_offset; }
|
uint64_t get_total_cycles() override { return arch.reg.cycle + arch.cycle_offset; }
|
||||||
|
|
||||||
void update_last_instr_cycles(unsigned cycles) override { arch.cycle_offset += cycles - 1; }
|
void update_last_instr_cycles(unsigned cycles) override { arch.cycle_offset += cycles - 1; }
|
||||||
|
|
||||||
@ -671,8 +671,10 @@ iss::status riscv_hart_msu_vp<BASE>::read(const address_type type, const access_
|
|||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
} catch(trap_access& ta) {
|
} catch(trap_access& ta) {
|
||||||
this->reg.trap_state = (1 << 31) | ta.id;
|
if((access & access_type::DEBUG) == 0) {
|
||||||
fault_data = ta.addr;
|
this->reg.trap_state = (1UL << 31) | ta.id;
|
||||||
|
fault_data = ta.addr;
|
||||||
|
}
|
||||||
return iss::Err;
|
return iss::Err;
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
@ -710,8 +712,10 @@ iss::status riscv_hart_msu_vp<BASE>::read(const address_type type, const access_
|
|||||||
}
|
}
|
||||||
return iss::Ok;
|
return iss::Ok;
|
||||||
} catch(trap_access& ta) {
|
} catch(trap_access& ta) {
|
||||||
this->reg.trap_state = (1UL << 31) | ta.id;
|
if((access & access_type::DEBUG) == 0) {
|
||||||
fault_data = ta.addr;
|
this->reg.trap_state = (1UL << 31) | ta.id;
|
||||||
|
fault_data = ta.addr;
|
||||||
|
}
|
||||||
return iss::Err;
|
return iss::Err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -841,8 +845,10 @@ iss::status riscv_hart_msu_vp<BASE>::write(const address_type type, const access
|
|||||||
}
|
}
|
||||||
return iss::Ok;
|
return iss::Ok;
|
||||||
} catch(trap_access& ta) {
|
} catch(trap_access& ta) {
|
||||||
this->reg.trap_state = (1UL << 31) | ta.id;
|
if((access & access_type::DEBUG) == 0) {
|
||||||
fault_data = ta.addr;
|
this->reg.trap_state = (1UL << 31) | ta.id;
|
||||||
|
fault_data = ta.addr;
|
||||||
|
}
|
||||||
return iss::Err;
|
return iss::Err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -889,7 +895,7 @@ template <typename BASE> iss::status riscv_hart_msu_vp<BASE>::write_reg(unsigned
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename BASE> iss::status riscv_hart_msu_vp<BASE>::read_cycle(unsigned addr, reg_t& val) {
|
template <typename BASE> iss::status riscv_hart_msu_vp<BASE>::read_cycle(unsigned addr, reg_t& val) {
|
||||||
auto cycle_val = this->reg.icount + cycle_offset;
|
auto cycle_val = this->reg.cycle + cycle_offset;
|
||||||
if(addr == mcycle) {
|
if(addr == mcycle) {
|
||||||
val = static_cast<reg_t>(cycle_val);
|
val = static_cast<reg_t>(cycle_val);
|
||||||
} else if(addr == mcycleh) {
|
} else if(addr == mcycleh) {
|
||||||
@ -910,7 +916,7 @@ template <typename BASE> iss::status riscv_hart_msu_vp<BASE>::write_cycle(unsign
|
|||||||
mcycle_csr = (static_cast<uint64_t>(val) << 32) + (mcycle_csr & 0xffffffff);
|
mcycle_csr = (static_cast<uint64_t>(val) << 32) + (mcycle_csr & 0xffffffff);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cycle_offset = mcycle_csr - this->reg.icount; // TODO: relying on wrap-around
|
cycle_offset = mcycle_csr - this->reg.cycle; // TODO: relying on wrap-around
|
||||||
return iss::Ok;
|
return iss::Ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -938,7 +944,7 @@ template <typename BASE> iss::status riscv_hart_msu_vp<BASE>::write_instret(unsi
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename BASE> iss::status riscv_hart_msu_vp<BASE>::read_time(unsigned addr, reg_t& val) {
|
template <typename BASE> iss::status riscv_hart_msu_vp<BASE>::read_time(unsigned addr, reg_t& val) {
|
||||||
uint64_t time_val = this->reg.icount / (100000000 / 32768 - 1); //-> ~3052;
|
uint64_t time_val = this->reg.cycle / (100000000 / 32768 - 1); //-> ~3052;
|
||||||
if(addr == time) {
|
if(addr == time) {
|
||||||
val = static_cast<reg_t>(time_val);
|
val = static_cast<reg_t>(time_val);
|
||||||
} else if(addr == timeh) {
|
} else if(addr == timeh) {
|
||||||
|
@ -305,7 +305,7 @@ public:
|
|||||||
|
|
||||||
void disass_output(uint64_t pc, const std::string instr) override {
|
void disass_output(uint64_t pc, const std::string instr) override {
|
||||||
NSCLOG(INFO, LOGCAT) << fmt::format("0x{:016x} {:40} [p:{};s:0x{:x};c:{}]", pc, instr, lvl[this->reg.PRIV], (reg_t)state.mstatus,
|
NSCLOG(INFO, LOGCAT) << fmt::format("0x{:016x} {:40} [p:{};s:0x{:x};c:{}]", pc, instr, lvl[this->reg.PRIV], (reg_t)state.mstatus,
|
||||||
this->reg.icount + cycle_offset);
|
this->reg.cycle + cycle_offset);
|
||||||
};
|
};
|
||||||
|
|
||||||
iss::instrumentation_if* get_instrumentation_if() override { return &instr_if; }
|
iss::instrumentation_if* get_instrumentation_if() override { return &instr_if; }
|
||||||
@ -338,7 +338,7 @@ protected:
|
|||||||
|
|
||||||
uint64_t get_pendig_traps() override { return arch.reg.trap_state; }
|
uint64_t get_pendig_traps() override { return arch.reg.trap_state; }
|
||||||
|
|
||||||
uint64_t get_total_cycles() override { return arch.reg.icount + arch.cycle_offset; }
|
uint64_t get_total_cycles() override { return arch.reg.cycle + arch.cycle_offset; }
|
||||||
|
|
||||||
void update_last_instr_cycles(unsigned cycles) override { arch.cycle_offset += cycles - 1; }
|
void update_last_instr_cycles(unsigned cycles) override { arch.cycle_offset += cycles - 1; }
|
||||||
|
|
||||||
@ -674,7 +674,7 @@ std::pair<uint64_t, bool> riscv_hart_mu_p<BASE, FEAT, LOGCAT>::load_file(std::st
|
|||||||
if(reader.get_machine() != EM_RISCV)
|
if(reader.get_machine() != EM_RISCV)
|
||||||
throw std::runtime_error("wrong elf machine in file");
|
throw std::runtime_error("wrong elf machine in file");
|
||||||
auto entry = reader.get_entry();
|
auto entry = reader.get_entry();
|
||||||
for(const auto pseg : reader.segments) {
|
for(const auto& pseg : reader.segments) {
|
||||||
const auto fsize = pseg->get_file_size(); // 0x42c/0x0
|
const auto fsize = pseg->get_file_size(); // 0x42c/0x0
|
||||||
const auto seg_data = pseg->get_data();
|
const auto seg_data = pseg->get_data();
|
||||||
const auto type = pseg->get_type();
|
const auto type = pseg->get_type();
|
||||||
@ -685,7 +685,7 @@ std::pair<uint64_t, bool> riscv_hart_mu_p<BASE, FEAT, LOGCAT>::load_file(std::st
|
|||||||
CPPLOG(ERR) << "problem writing " << fsize << "bytes to 0x" << std::hex << pseg->get_physical_address();
|
CPPLOG(ERR) << "problem writing " << fsize << "bytes to 0x" << std::hex << pseg->get_physical_address();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(const auto sec : reader.sections) {
|
for(const auto& sec : reader.sections) {
|
||||||
if(sec->get_name() == ".symtab") {
|
if(sec->get_name() == ".symtab") {
|
||||||
if(SHT_SYMTAB == sec->get_type() || SHT_DYNSYM == sec->get_type()) {
|
if(SHT_SYMTAB == sec->get_type() || SHT_DYNSYM == sec->get_type()) {
|
||||||
ELFIO::symbol_section_accessor symbols(reader, sec);
|
ELFIO::symbol_section_accessor symbols(reader, sec);
|
||||||
@ -877,8 +877,10 @@ iss::status riscv_hart_mu_p<BASE, FEAT, LOGCAT>::read(const address_type type, c
|
|||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
} catch(trap_access& ta) {
|
} catch(trap_access& ta) {
|
||||||
this->reg.trap_state = (1UL << 31) | ta.id;
|
if((access & access_type::DEBUG) == 0) {
|
||||||
fault_data = ta.addr;
|
this->reg.trap_state = (1UL << 31) | ta.id;
|
||||||
|
fault_data = ta.addr;
|
||||||
|
}
|
||||||
return iss::Err;
|
return iss::Err;
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
@ -905,8 +907,10 @@ iss::status riscv_hart_mu_p<BASE, FEAT, LOGCAT>::read(const address_type type, c
|
|||||||
}
|
}
|
||||||
return iss::Ok;
|
return iss::Ok;
|
||||||
} catch(trap_access& ta) {
|
} catch(trap_access& ta) {
|
||||||
this->reg.trap_state = (1UL << 31) | ta.id;
|
if((access & access_type::DEBUG) == 0) {
|
||||||
fault_data = ta.addr;
|
this->reg.trap_state = (1UL << 31) | ta.id;
|
||||||
|
fault_data = ta.addr;
|
||||||
|
}
|
||||||
return iss::Err;
|
return iss::Err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1045,8 +1049,10 @@ iss::status riscv_hart_mu_p<BASE, FEAT, LOGCAT>::write(const address_type type,
|
|||||||
}
|
}
|
||||||
return iss::Ok;
|
return iss::Ok;
|
||||||
} catch(trap_access& ta) {
|
} catch(trap_access& ta) {
|
||||||
this->reg.trap_state = (1UL << 31) | ta.id;
|
if((access & access_type::DEBUG) == 0) {
|
||||||
fault_data = ta.addr;
|
this->reg.trap_state = (1UL << 31) | ta.id;
|
||||||
|
fault_data = ta.addr;
|
||||||
|
}
|
||||||
return iss::Err;
|
return iss::Err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1099,7 +1105,7 @@ iss::status riscv_hart_mu_p<BASE, FEAT, LOGCAT>::write_plain(unsigned addr, reg_
|
|||||||
|
|
||||||
template <typename BASE, features_e FEAT, typename LOGCAT>
|
template <typename BASE, features_e FEAT, typename LOGCAT>
|
||||||
iss::status riscv_hart_mu_p<BASE, FEAT, LOGCAT>::read_cycle(unsigned addr, reg_t& val) {
|
iss::status riscv_hart_mu_p<BASE, FEAT, LOGCAT>::read_cycle(unsigned addr, reg_t& val) {
|
||||||
auto cycle_val = this->reg.icount + cycle_offset;
|
auto cycle_val = this->reg.cycle + cycle_offset;
|
||||||
if(addr == mcycle) {
|
if(addr == mcycle) {
|
||||||
val = static_cast<reg_t>(cycle_val);
|
val = static_cast<reg_t>(cycle_val);
|
||||||
} else if(addr == mcycleh) {
|
} else if(addr == mcycleh) {
|
||||||
@ -1119,7 +1125,7 @@ iss::status riscv_hart_mu_p<BASE, FEAT, LOGCAT>::write_cycle(unsigned addr, reg_
|
|||||||
mcycle_csr = (static_cast<uint64_t>(val) << 32) + (mcycle_csr & 0xffffffff);
|
mcycle_csr = (static_cast<uint64_t>(val) << 32) + (mcycle_csr & 0xffffffff);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cycle_offset = mcycle_csr - this->reg.icount; // TODO: relying on wrap-around
|
cycle_offset = mcycle_csr - this->reg.cycle; // TODO: relying on wrap-around
|
||||||
return iss::Ok;
|
return iss::Ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1150,7 +1156,7 @@ iss::status riscv_hart_mu_p<BASE, FEAT, LOGCAT>::write_instret(unsigned addr, re
|
|||||||
|
|
||||||
template <typename BASE, features_e FEAT, typename LOGCAT>
|
template <typename BASE, features_e FEAT, typename LOGCAT>
|
||||||
iss::status riscv_hart_mu_p<BASE, FEAT, LOGCAT>::read_time(unsigned addr, reg_t& val) {
|
iss::status riscv_hart_mu_p<BASE, FEAT, LOGCAT>::read_time(unsigned addr, reg_t& val) {
|
||||||
uint64_t time_val = this->reg.icount / (100000000 / 32768 - 1); //-> ~3052;
|
uint64_t time_val = this->reg.cycle / (100000000 / 32768 - 1); //-> ~3052;
|
||||||
if(addr == time) {
|
if(addr == time) {
|
||||||
val = static_cast<reg_t>(time_val);
|
val = static_cast<reg_t>(time_val);
|
||||||
} else if(addr == timeh) {
|
} else if(addr == timeh) {
|
||||||
|
4108
src/iss/debugger/csr_names.cpp
Normal file
4108
src/iss/debugger/csr_names.cpp
Normal file
File diff suppressed because it is too large
Load Diff
@ -30,8 +30,8 @@
|
|||||||
*
|
*
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
#ifndef _ISS_DEBUGGER_RISCV_TARGET_ADAPTER_H_
|
#ifndef _ISS_ARCH_DEBUGGER_RISCV_TARGET_ADAPTER_H_
|
||||||
#define _ISS_DEBUGGER_RISCV_TARGET_ADAPTER_H_
|
#define _ISS_ARCH_DEBUGGER_RISCV_TARGET_ADAPTER_H_
|
||||||
|
|
||||||
#include "iss/arch_if.h"
|
#include "iss/arch_if.h"
|
||||||
#include <iss/arch/traits.h>
|
#include <iss/arch/traits.h>
|
||||||
@ -48,6 +48,10 @@
|
|||||||
|
|
||||||
namespace iss {
|
namespace iss {
|
||||||
namespace debugger {
|
namespace debugger {
|
||||||
|
|
||||||
|
char const* const get_csr_name(unsigned);
|
||||||
|
constexpr auto csr_offset = 100U;
|
||||||
|
|
||||||
using namespace iss::arch;
|
using namespace iss::arch;
|
||||||
using namespace iss::debugger;
|
using namespace iss::debugger;
|
||||||
|
|
||||||
@ -129,11 +133,17 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
static inline constexpr addr_t map_addr(const addr_t& i) { return i; }
|
static inline constexpr addr_t map_addr(const addr_t& i) { return i; }
|
||||||
|
std::string csr_xml;
|
||||||
iss::arch_if* core;
|
iss::arch_if* core;
|
||||||
rp_thread_ref thread_idx;
|
rp_thread_ref thread_idx;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <typename ARCH> typename std::enable_if<iss::arch::traits<ARCH>::FLEN != 0, unsigned>::type get_f0_offset() {
|
||||||
|
return iss::arch::traits<ARCH>::F0;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename ARCH> typename std::enable_if<iss::arch::traits<ARCH>::FLEN == 0, unsigned>::type get_f0_offset() { return 0; }
|
||||||
|
|
||||||
template <typename ARCH> status riscv_target_adapter<ARCH>::set_gen_thread(rp_thread_ref& thread) {
|
template <typename ARCH> status riscv_target_adapter<ARCH>::set_gen_thread(rp_thread_ref& thread) {
|
||||||
thread_idx = thread;
|
thread_idx = thread;
|
||||||
return Ok;
|
return Ok;
|
||||||
@ -175,34 +185,37 @@ template <typename ARCH> status riscv_target_adapter<ARCH>::current_thread_query
|
|||||||
|
|
||||||
template <typename ARCH> status riscv_target_adapter<ARCH>::read_registers(std::vector<uint8_t>& data, std::vector<uint8_t>& avail) {
|
template <typename ARCH> status riscv_target_adapter<ARCH>::read_registers(std::vector<uint8_t>& data, std::vector<uint8_t>& avail) {
|
||||||
CPPLOG(TRACE) << "reading target registers";
|
CPPLOG(TRACE) << "reading target registers";
|
||||||
// return idx<0?:;
|
|
||||||
data.clear();
|
data.clear();
|
||||||
avail.clear();
|
avail.clear();
|
||||||
const uint8_t* reg_base = core->get_regs_base_ptr();
|
const uint8_t* reg_base = core->get_regs_base_ptr();
|
||||||
auto start_reg = arch::traits<ARCH>::X0;
|
auto start_reg = arch::traits<ARCH>::X0;
|
||||||
for(size_t reg_no = start_reg; reg_no < start_reg + 33 /*arch::traits<ARCH>::NUM_REGS*/; ++reg_no) {
|
for(size_t i = 0; i < 33; ++i) {
|
||||||
auto reg_width = arch::traits<ARCH>::reg_bit_widths[reg_no] / 8;
|
if(i < arch::traits<ARCH>::RFS || i == arch::traits<ARCH>::PC) {
|
||||||
unsigned offset = traits<ARCH>::reg_byte_offsets[reg_no];
|
auto reg_no = i < 32 ? start_reg + i : arch::traits<ARCH>::PC;
|
||||||
for(size_t j = 0; j < reg_width; ++j) {
|
unsigned offset = traits<ARCH>::reg_byte_offsets[reg_no];
|
||||||
data.push_back(*(reg_base + offset + j));
|
for(size_t j = 0; j < arch::traits<ARCH>::XLEN / 8; ++j) {
|
||||||
avail.push_back(0xff);
|
data.push_back(*(reg_base + offset + j));
|
||||||
|
avail.push_back(0xff);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for(size_t j = 0; j < arch::traits<ARCH>::XLEN / 8; ++j) {
|
||||||
|
data.push_back(0);
|
||||||
|
avail.push_back(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(iss::arch::traits<ARCH>::FLEN > 0) {
|
||||||
|
auto fstart_reg = get_f0_offset<ARCH>();
|
||||||
|
for(size_t i = 0; i < 32; ++i) {
|
||||||
|
auto reg_no = fstart_reg + i;
|
||||||
|
auto reg_width = arch::traits<ARCH>::reg_bit_widths[reg_no] / 8;
|
||||||
|
unsigned offset = traits<ARCH>::reg_byte_offsets[reg_no];
|
||||||
|
for(size_t j = 0; j < reg_width; ++j) {
|
||||||
|
data.push_back(*(reg_base + offset + j));
|
||||||
|
avail.push_back(0xff);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// work around fill with F type registers
|
|
||||||
// if (arch::traits<ARCH>::NUM_REGS < 65) {
|
|
||||||
// auto reg_width = sizeof(typename arch::traits<ARCH>::reg_t);
|
|
||||||
// for (size_t reg_no = 0; reg_no < 33; ++reg_no) {
|
|
||||||
// for (size_t j = 0; j < reg_width; ++j) {
|
|
||||||
// data.push_back(0x0);
|
|
||||||
// avail.push_back(0x00);
|
|
||||||
// }
|
|
||||||
// // if(arch::traits<ARCH>::XLEN < 64)
|
|
||||||
// // for(unsigned j=0; j<4; ++j){
|
|
||||||
// // data.push_back(0x0);
|
|
||||||
// // avail.push_back(0x00);
|
|
||||||
// // }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
return Ok;
|
return Ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,25 +223,25 @@ template <typename ARCH> status riscv_target_adapter<ARCH>::write_registers(cons
|
|||||||
auto start_reg = arch::traits<ARCH>::X0;
|
auto start_reg = arch::traits<ARCH>::X0;
|
||||||
auto* reg_base = core->get_regs_base_ptr();
|
auto* reg_base = core->get_regs_base_ptr();
|
||||||
auto iter = data.data();
|
auto iter = data.data();
|
||||||
bool e_ext = arch::traits<ARCH>::PC < 32;
|
auto iter_end = data.data() + data.size();
|
||||||
for(size_t reg_no = 0; reg_no < start_reg + 33 /*arch::traits<ARCH>::NUM_REGS*/; ++reg_no) {
|
for(size_t i = 0; i < 33 && iter < iter_end; ++i) {
|
||||||
if(e_ext && reg_no > 15) {
|
auto reg_width = arch::traits<ARCH>::XLEN / 8;
|
||||||
if(reg_no == 32) {
|
if(i < arch::traits<ARCH>::RFS) {
|
||||||
auto reg_width = arch::traits<ARCH>::reg_bit_widths[arch::traits<ARCH>::PC] / 8;
|
auto offset = traits<ARCH>::reg_byte_offsets[start_reg + i];
|
||||||
auto offset = traits<ARCH>::reg_byte_offsets[arch::traits<ARCH>::PC];
|
std::copy(iter, iter + reg_width, reg_base + offset);
|
||||||
std::copy(iter, iter + reg_width, reg_base);
|
} else if(i == 32) {
|
||||||
} else {
|
auto offset = traits<ARCH>::reg_byte_offsets[arch::traits<ARCH>::PC];
|
||||||
const uint64_t zero_val = 0;
|
std::copy(iter, iter + reg_width, reg_base + offset);
|
||||||
auto reg_width = arch::traits<ARCH>::reg_bit_widths[15] / 8;
|
}
|
||||||
auto iter = (uint8_t*)&zero_val;
|
iter += reg_width;
|
||||||
std::copy(iter, iter + reg_width, reg_base);
|
}
|
||||||
}
|
if(iss::arch::traits<ARCH>::FLEN > 0) {
|
||||||
} else {
|
auto fstart_reg = get_f0_offset<ARCH>();
|
||||||
auto reg_width = arch::traits<ARCH>::reg_bit_widths[reg_no] / 8;
|
auto reg_width = arch::traits<ARCH>::FLEN / 8;
|
||||||
auto offset = traits<ARCH>::reg_byte_offsets[reg_no];
|
for(size_t i = 0; i < 32 && iter < iter_end; ++i) {
|
||||||
std::copy(iter, iter + reg_width, reg_base);
|
unsigned offset = traits<ARCH>::reg_byte_offsets[fstart_reg + i];
|
||||||
iter += 4;
|
std::copy(iter, iter + reg_width, reg_base + offset);
|
||||||
reg_base += offset;
|
iter += reg_width;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Ok;
|
return Ok;
|
||||||
@ -236,7 +249,7 @@ template <typename ARCH> status riscv_target_adapter<ARCH>::write_registers(cons
|
|||||||
|
|
||||||
template <typename ARCH>
|
template <typename ARCH>
|
||||||
status riscv_target_adapter<ARCH>::read_single_register(unsigned int reg_no, std::vector<uint8_t>& data, std::vector<uint8_t>& avail) {
|
status riscv_target_adapter<ARCH>::read_single_register(unsigned int reg_no, std::vector<uint8_t>& data, std::vector<uint8_t>& avail) {
|
||||||
if(reg_no < 65) {
|
if(reg_no < csr_offset) {
|
||||||
// auto reg_size = arch::traits<ARCH>::reg_bit_width(static_cast<typename
|
// auto reg_size = arch::traits<ARCH>::reg_bit_width(static_cast<typename
|
||||||
// arch::traits<ARCH>::reg_e>(reg_no))/8;
|
// arch::traits<ARCH>::reg_e>(reg_no))/8;
|
||||||
auto* reg_base = core->get_regs_base_ptr();
|
auto* reg_base = core->get_regs_base_ptr();
|
||||||
@ -247,23 +260,24 @@ status riscv_target_adapter<ARCH>::read_single_register(unsigned int reg_no, std
|
|||||||
std::copy(reg_base + offset, reg_base + offset + reg_width, data.begin());
|
std::copy(reg_base + offset, reg_base + offset + reg_width, data.begin());
|
||||||
std::fill(avail.begin(), avail.end(), 0xff);
|
std::fill(avail.begin(), avail.end(), 0xff);
|
||||||
} else {
|
} else {
|
||||||
typed_addr_t<iss::address_type::PHYSICAL> a(iss::access_type::DEBUG_READ, traits<ARCH>::CSR, reg_no - 65);
|
typed_addr_t<iss::address_type::PHYSICAL> a(iss::access_type::DEBUG_READ, traits<ARCH>::CSR, reg_no - csr_offset);
|
||||||
data.resize(sizeof(typename traits<ARCH>::reg_t));
|
data.resize(sizeof(typename traits<ARCH>::reg_t));
|
||||||
avail.resize(sizeof(typename traits<ARCH>::reg_t));
|
avail.resize(sizeof(typename traits<ARCH>::reg_t));
|
||||||
std::fill(avail.begin(), avail.end(), 0xff);
|
std::fill(avail.begin(), avail.end(), 0xff);
|
||||||
core->read(a, data.size(), data.data());
|
core->read(a, data.size(), data.data());
|
||||||
|
std::fill(avail.begin(), avail.end(), 0xff);
|
||||||
}
|
}
|
||||||
return data.size() > 0 ? Ok : Err;
|
return data.size() > 0 ? Ok : Err;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename ARCH> status riscv_target_adapter<ARCH>::write_single_register(unsigned int reg_no, const std::vector<uint8_t>& data) {
|
template <typename ARCH> status riscv_target_adapter<ARCH>::write_single_register(unsigned int reg_no, const std::vector<uint8_t>& data) {
|
||||||
if(reg_no < 65) {
|
if(reg_no < csr_offset) {
|
||||||
auto* reg_base = core->get_regs_base_ptr();
|
auto* reg_base = core->get_regs_base_ptr();
|
||||||
auto reg_width = arch::traits<ARCH>::reg_bit_widths[static_cast<typename arch::traits<ARCH>::reg_e>(reg_no)] / 8;
|
auto reg_width = arch::traits<ARCH>::reg_bit_widths[static_cast<typename arch::traits<ARCH>::reg_e>(reg_no)] / 8;
|
||||||
auto offset = traits<ARCH>::reg_byte_offsets[reg_no];
|
auto offset = traits<ARCH>::reg_byte_offsets[reg_no];
|
||||||
std::copy(data.begin(), data.begin() + reg_width, reg_base + offset);
|
std::copy(data.begin(), data.begin() + reg_width, reg_base + offset);
|
||||||
} else {
|
} else {
|
||||||
typed_addr_t<iss::address_type::PHYSICAL> a(iss::access_type::DEBUG_WRITE, traits<ARCH>::CSR, reg_no - 65);
|
typed_addr_t<iss::address_type::PHYSICAL> a(iss::access_type::DEBUG_WRITE, traits<ARCH>::CSR, reg_no - csr_offset);
|
||||||
core->write(a, data.size(), data.data());
|
core->write(a, data.size(), data.data());
|
||||||
}
|
}
|
||||||
return Ok;
|
return Ok;
|
||||||
@ -276,7 +290,7 @@ template <typename ARCH> status riscv_target_adapter<ARCH>::read_mem(uint64_t ad
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename ARCH> status riscv_target_adapter<ARCH>::write_mem(uint64_t addr, const std::vector<uint8_t>& data) {
|
template <typename ARCH> status riscv_target_adapter<ARCH>::write_mem(uint64_t addr, const std::vector<uint8_t>& data) {
|
||||||
auto a = map_addr({iss::access_type::DEBUG_READ, iss::address_type::VIRTUAL, 0, addr});
|
auto a = map_addr({iss::access_type::DEBUG_WRITE, iss::address_type::VIRTUAL, 0, addr});
|
||||||
auto f = [&]() -> status { return core->write(a, data.size(), data.data()); };
|
auto f = [&]() -> status { return core->write(a, data.size(), data.data()); };
|
||||||
return srv->execute_syncronized(f);
|
return srv->execute_syncronized(f);
|
||||||
}
|
}
|
||||||
@ -369,93 +383,57 @@ status riscv_target_adapter<ARCH>::resume_from_addr(bool step, int sig, uint64_t
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename ARCH> status riscv_target_adapter<ARCH>::target_xml_query(std::string& out_buf) {
|
template <typename ARCH> status riscv_target_adapter<ARCH>::target_xml_query(std::string& out_buf) {
|
||||||
const std::string res{"<?xml version=\"1.0\"?><!DOCTYPE target SYSTEM \"gdb-target.dtd\">"
|
if(!csr_xml.size()) {
|
||||||
"<target><architecture>riscv:rv32</architecture>"
|
std::ostringstream oss;
|
||||||
//" <feature name=\"org.gnu.gdb.riscv.rv32i\">\n"
|
oss << "<?xml version=\"1.0\"?><!DOCTYPE feature SYSTEM \"gdb-target.dtd\"><target version=\"1.0\">\n";
|
||||||
//" <reg name=\"x0\" bitsize=\"32\" group=\"general\"/>\n"
|
if(iss::arch::traits<ARCH>::XLEN == 32)
|
||||||
//" <reg name=\"x1\" bitsize=\"32\" group=\"general\"/>\n"
|
oss << "<architecture>riscv:rv32</architecture>\n";
|
||||||
//" <reg name=\"x2\" bitsize=\"32\" group=\"general\"/>\n"
|
else if(iss::arch::traits<ARCH>::XLEN == 64)
|
||||||
//" <reg name=\"x3\" bitsize=\"32\" group=\"general\"/>\n"
|
oss << " <architectureriscv:rv64</architecture>\n";
|
||||||
//" <reg name=\"x4\" bitsize=\"32\" group=\"general\"/>\n"
|
oss << " <feature name=\"org.gnu.gdb.riscv.cpu\">\n";
|
||||||
//" <reg name=\"x5\" bitsize=\"32\" group=\"general\"/>\n"
|
auto reg_base_num = iss::arch::traits<ARCH>::X0;
|
||||||
//" <reg name=\"x6\" bitsize=\"32\" group=\"general\"/>\n"
|
for(auto i = 0U; i < iss::arch::traits<ARCH>::RFS; ++i) {
|
||||||
//" <reg name=\"x7\" bitsize=\"32\" group=\"general\"/>\n"
|
oss << " <reg name=\"x" << i << "\" bitsize=\"" << iss::arch::traits<ARCH>::reg_bit_widths[reg_base_num + i]
|
||||||
//" <reg name=\"x8\" bitsize=\"32\" group=\"general\"/>\n"
|
<< "\" type=\"int\" regnum=\"" << i << "\"/>\n";
|
||||||
//" <reg name=\"x9\" bitsize=\"32\" group=\"general\"/>\n"
|
}
|
||||||
//" <reg name=\"x10\" bitsize=\"32\" group=\"general\"/>\n"
|
oss << " <reg name=\"pc\" bitsize=\"" << iss::arch::traits<ARCH>::reg_bit_widths[iss::arch::traits<ARCH>::PC]
|
||||||
//" <reg name=\"x11\" bitsize=\"32\" group=\"general\"/>\n"
|
<< "\" type=\"code_ptr\" regnum=\"" << 32U << "\"/>\n";
|
||||||
//" <reg name=\"x12\" bitsize=\"32\" group=\"general\"/>\n"
|
oss << " </feature>\n";
|
||||||
//" <reg name=\"x13\" bitsize=\"32\" group=\"general\"/>\n"
|
if(iss::arch::traits<ARCH>::FLEN > 0) {
|
||||||
//" <reg name=\"x14\" bitsize=\"32\" group=\"general\"/>\n"
|
oss << " <feature name=\"org.gnu.gdb.riscv.fpu\">\n";
|
||||||
//" <reg name=\"x15\" bitsize=\"32\" group=\"general\"/>\n"
|
auto reg_base_num = get_f0_offset<ARCH>();
|
||||||
//" <reg name=\"x16\" bitsize=\"32\" group=\"general\"/>\n"
|
auto type = iss::arch::traits<ARCH>::FLEN == 32 ? "ieee_single" : "riscv_double";
|
||||||
//" <reg name=\"x17\" bitsize=\"32\" group=\"general\"/>\n"
|
for(auto i = 0U; i < 32; ++i) {
|
||||||
//" <reg name=\"x18\" bitsize=\"32\" group=\"general\"/>\n"
|
oss << " <reg name=\"f" << i << "\" bitsize=\"" << iss::arch::traits<ARCH>::reg_bit_widths[reg_base_num + i]
|
||||||
//" <reg name=\"x19\" bitsize=\"32\" group=\"general\"/>\n"
|
<< "\" type=\"" << type << "\" regnum=\"" << i + 33 << "\"/>\n";
|
||||||
//" <reg name=\"x20\" bitsize=\"32\" group=\"general\"/>\n"
|
}
|
||||||
//" <reg name=\"x21\" bitsize=\"32\" group=\"general\"/>\n"
|
oss << " <reg name=\"fcsr\" bitsize=\"" << iss::arch::traits<ARCH>::XLEN << "\" regnum=\"103\" type int/>\n";
|
||||||
//" <reg name=\"x22\" bitsize=\"32\" group=\"general\"/>\n"
|
oss << " <reg name=\"fflags\" bitsize=\"" << iss::arch::traits<ARCH>::XLEN << "\" regnum=\"101\" type int/>\n";
|
||||||
//" <reg name=\"x23\" bitsize=\"32\" group=\"general\"/>\n"
|
oss << " <reg name=\"frm\" bitsize=\"" << iss::arch::traits<ARCH>::XLEN << "\" regnum=\"102\" type int/>\n";
|
||||||
//" <reg name=\"x24\" bitsize=\"32\" group=\"general\"/>\n"
|
oss << " </feature>\n";
|
||||||
//" <reg name=\"x25\" bitsize=\"32\" group=\"general\"/>\n"
|
}
|
||||||
//" <reg name=\"x26\" bitsize=\"32\" group=\"general\"/>\n"
|
oss << " <feature name=\"org.gnu.gdb.riscv.csr\">\n";
|
||||||
//" <reg name=\"x27\" bitsize=\"32\" group=\"general\"/>\n"
|
std::vector<uint8_t> data;
|
||||||
//" <reg name=\"x28\" bitsize=\"32\" group=\"general\"/>\n"
|
std::vector<uint8_t> avail;
|
||||||
//" <reg name=\"x29\" bitsize=\"32\" group=\"general\"/>\n"
|
data.resize(sizeof(typename traits<ARCH>::reg_t));
|
||||||
//" <reg name=\"x30\" bitsize=\"32\" group=\"general\"/>\n"
|
avail.resize(sizeof(typename traits<ARCH>::reg_t));
|
||||||
//" <reg name=\"x31\" bitsize=\"32\" group=\"general\"/>\n"
|
for(auto i = 0U; i < 4096; ++i) {
|
||||||
//" </feature>\n"
|
typed_addr_t<iss::address_type::PHYSICAL> a(iss::access_type::DEBUG_READ, traits<ARCH>::CSR, i);
|
||||||
"</target>"};
|
std::fill(avail.begin(), avail.end(), 0xff);
|
||||||
out_buf = res;
|
auto res = core->read(a, data.size(), data.data());
|
||||||
|
if(res == iss::Ok) {
|
||||||
|
oss << " <reg name=\"" << get_csr_name(i) << "\" bitsize=\"" << iss::arch::traits<ARCH>::XLEN
|
||||||
|
<< "\" type=\"int\" regnum=\"" << (i + csr_offset) << "\"/>\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
oss << " </feature>\n";
|
||||||
|
oss << "</target>\n";
|
||||||
|
csr_xml = oss.str();
|
||||||
|
}
|
||||||
|
out_buf = csr_xml;
|
||||||
return Ok;
|
return Ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
*
|
|
||||||
<?xml version="1.0"?>
|
|
||||||
<!DOCTYPE target SYSTEM "gdb-target.dtd">
|
|
||||||
<target>
|
|
||||||
<architecture>riscv:rv32</architecture>
|
|
||||||
|
|
||||||
<feature name="org.gnu.gdb.riscv.rv32i">
|
|
||||||
<reg name="x0" bitsize="32" group="general"/>
|
|
||||||
<reg name="x1" bitsize="32" group="general"/>
|
|
||||||
<reg name="x2" bitsize="32" group="general"/>
|
|
||||||
<reg name="x3" bitsize="32" group="general"/>
|
|
||||||
<reg name="x4" bitsize="32" group="general"/>
|
|
||||||
<reg name="x5" bitsize="32" group="general"/>
|
|
||||||
<reg name="x6" bitsize="32" group="general"/>
|
|
||||||
<reg name="x7" bitsize="32" group="general"/>
|
|
||||||
<reg name="x8" bitsize="32" group="general"/>
|
|
||||||
<reg name="x9" bitsize="32" group="general"/>
|
|
||||||
<reg name="x10" bitsize="32" group="general"/>
|
|
||||||
<reg name="x11" bitsize="32" group="general"/>
|
|
||||||
<reg name="x12" bitsize="32" group="general"/>
|
|
||||||
<reg name="x13" bitsize="32" group="general"/>
|
|
||||||
<reg name="x14" bitsize="32" group="general"/>
|
|
||||||
<reg name="x15" bitsize="32" group="general"/>
|
|
||||||
<reg name="x16" bitsize="32" group="general"/>
|
|
||||||
<reg name="x17" bitsize="32" group="general"/>
|
|
||||||
<reg name="x18" bitsize="32" group="general"/>
|
|
||||||
<reg name="x19" bitsize="32" group="general"/>
|
|
||||||
<reg name="x20" bitsize="32" group="general"/>
|
|
||||||
<reg name="x21" bitsize="32" group="general"/>
|
|
||||||
<reg name="x22" bitsize="32" group="general"/>
|
|
||||||
<reg name="x23" bitsize="32" group="general"/>
|
|
||||||
<reg name="x24" bitsize="32" group="general"/>
|
|
||||||
<reg name="x25" bitsize="32" group="general"/>
|
|
||||||
<reg name="x26" bitsize="32" group="general"/>
|
|
||||||
<reg name="x27" bitsize="32" group="general"/>
|
|
||||||
<reg name="x28" bitsize="32" group="general"/>
|
|
||||||
<reg name="x29" bitsize="32" group="general"/>
|
|
||||||
<reg name="x30" bitsize="32" group="general"/>
|
|
||||||
<reg name="x31" bitsize="32" group="general"/>
|
|
||||||
</feature>
|
|
||||||
|
|
||||||
</target>
|
|
||||||
|
|
||||||
*/
|
|
||||||
} // namespace debugger
|
} // namespace debugger
|
||||||
} // namespace iss
|
} // namespace iss
|
||||||
|
|
||||||
#endif /* _ISS_DEBUGGER_RISCV_TARGET_ADAPTER_H_ */
|
#endif /* _ISS_ARCH_DEBUGGER_RISCV_TARGET_ADAPTER_H_ */
|
||||||
|
@ -141,7 +141,10 @@ int main(int argc, char* argv[]) {
|
|||||||
std::tie(cpu, vm) = f.create(isa_opt, clim["gdb-port"].as<unsigned>(), &semihosting_cb);
|
std::tie(cpu, vm) = f.create(isa_opt, clim["gdb-port"].as<unsigned>(), &semihosting_cb);
|
||||||
}
|
}
|
||||||
if(!cpu) {
|
if(!cpu) {
|
||||||
CPPLOG(ERR) << "Could not create cpu for isa " << isa_opt << " and backend " << clim["backend"].as<std::string>() << std::endl;
|
auto list = f.get_names();
|
||||||
|
std::sort(std::begin(list), std::end(list));
|
||||||
|
CPPLOG(ERR) << "Could not create cpu for isa " << isa_opt << " and backend " << clim["backend"].as<std::string>() << "\n"
|
||||||
|
<< "Available implementations (core|platform|backend):\n - " << util::join(list, "\n - ") << std::endl;
|
||||||
return 127;
|
return 127;
|
||||||
}
|
}
|
||||||
if(!vm) {
|
if(!vm) {
|
||||||
|
@ -42,7 +42,6 @@
|
|||||||
#include <iss/plugin/loader.h>
|
#include <iss/plugin/loader.h>
|
||||||
#endif
|
#endif
|
||||||
#include "sc_core_adapter_if.h"
|
#include "sc_core_adapter_if.h"
|
||||||
#include <iss/arch/tgc_mapper.h>
|
|
||||||
#include <scc/report.h>
|
#include <scc/report.h>
|
||||||
#include <util/ities.h>
|
#include <util/ities.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@ -125,7 +124,7 @@ using vm_ptr = std::unique_ptr<iss::vm_if>;
|
|||||||
|
|
||||||
class core_wrapper {
|
class core_wrapper {
|
||||||
public:
|
public:
|
||||||
core_wrapper(core_complex* owner)
|
core_wrapper(core_complex_if* owner)
|
||||||
: owner(owner) {}
|
: owner(owner) {}
|
||||||
|
|
||||||
void reset(uint64_t addr) { vm->reset(addr); }
|
void reset(uint64_t addr) { vm->reset(addr); }
|
||||||
@ -181,7 +180,7 @@ public:
|
|||||||
"SystemC sub-commands: break <time>, print_time"});
|
"SystemC sub-commands: break <time>, print_time"});
|
||||||
}
|
}
|
||||||
|
|
||||||
core_complex* const owner;
|
core_complex_if* const owner;
|
||||||
vm_ptr vm{nullptr};
|
vm_ptr vm{nullptr};
|
||||||
sc_cpu_ptr cpu{nullptr};
|
sc_cpu_ptr cpu{nullptr};
|
||||||
iss::debugger::target_adapter_if* tgt_adapter{nullptr};
|
iss::debugger::target_adapter_if* tgt_adapter{nullptr};
|
||||||
@ -197,7 +196,6 @@ struct core_trace {
|
|||||||
scv_tr_handle tr_handle;
|
scv_tr_handle tr_handle;
|
||||||
};
|
};
|
||||||
|
|
||||||
SC_HAS_PROCESS(core_complex); // NOLINT
|
|
||||||
#ifndef CWR_SYSTEMC
|
#ifndef CWR_SYSTEMC
|
||||||
template <unsigned int BUSWIDTH>
|
template <unsigned int BUSWIDTH>
|
||||||
core_complex<BUSWIDTH>::core_complex(sc_module_name const& name)
|
core_complex<BUSWIDTH>::core_complex(sc_module_name const& name)
|
||||||
@ -209,8 +207,7 @@ core_complex<BUSWIDTH>::core_complex(sc_module_name const& name)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
template <unsigned int BUSWIDTH>
|
template <unsigned int BUSWIDTH> void core_complex<BUSWIDTH>::init() {
|
||||||
void core_complex<BUSWIDTH>::init() {
|
|
||||||
trc = new core_trace();
|
trc = new core_trace();
|
||||||
ibus.register_invalidate_direct_mem_ptr([=](uint64_t start, uint64_t end) -> void {
|
ibus.register_invalidate_direct_mem_ptr([=](uint64_t start, uint64_t end) -> void {
|
||||||
auto lut_entry = fetch_lut.getEntry(start);
|
auto lut_entry = fetch_lut.getEntry(start);
|
||||||
@ -255,19 +252,16 @@ void core_complex<BUSWIDTH>::init() {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
template <unsigned int BUSWIDTH>
|
template <unsigned int BUSWIDTH> core_complex<BUSWIDTH>::~core_complex() {
|
||||||
core_complex<BUSWIDTH>::~core_complex() {
|
|
||||||
delete cpu;
|
delete cpu;
|
||||||
delete trc;
|
delete trc;
|
||||||
for(auto* p : plugin_list)
|
for(auto* p : plugin_list)
|
||||||
delete p;
|
delete p;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <unsigned int BUSWIDTH>
|
template <unsigned int BUSWIDTH> void core_complex<BUSWIDTH>::trace(sc_trace_file* trf) const {}
|
||||||
void core_complex<BUSWIDTH>::trace(sc_trace_file* trf) const {}
|
|
||||||
|
|
||||||
template <unsigned int BUSWIDTH>
|
template <unsigned int BUSWIDTH> void core_complex<BUSWIDTH>::before_end_of_elaboration() {
|
||||||
void core_complex<BUSWIDTH>::before_end_of_elaboration() {
|
|
||||||
SCCDEBUG(SCMOD) << "instantiating iss::arch::tgf with " << GET_PROP_VALUE(backend) << " backend";
|
SCCDEBUG(SCMOD) << "instantiating iss::arch::tgf with " << GET_PROP_VALUE(backend) << " backend";
|
||||||
// cpu = scc::make_unique<core_wrapper>(this);
|
// cpu = scc::make_unique<core_wrapper>(this);
|
||||||
cpu = new core_wrapper(this);
|
cpu = new core_wrapper(this);
|
||||||
@ -308,8 +302,7 @@ void core_complex<BUSWIDTH>::before_end_of_elaboration() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <unsigned int BUSWIDTH>
|
template <unsigned int BUSWIDTH> void core_complex<BUSWIDTH>::start_of_simulation() {
|
||||||
void core_complex<BUSWIDTH>::start_of_simulation() {
|
|
||||||
// quantum_keeper.reset();
|
// quantum_keeper.reset();
|
||||||
if(GET_PROP_VALUE(elf_file).size() > 0) {
|
if(GET_PROP_VALUE(elf_file).size() > 0) {
|
||||||
istringstream is(GET_PROP_VALUE(elf_file));
|
istringstream is(GET_PROP_VALUE(elf_file));
|
||||||
@ -332,8 +325,7 @@ void core_complex<BUSWIDTH>::start_of_simulation() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <unsigned int BUSWIDTH>
|
template <unsigned int BUSWIDTH> bool core_complex<BUSWIDTH>::disass_output(uint64_t pc, const std::string instr_str) {
|
||||||
bool core_complex<BUSWIDTH>::disass_output(uint64_t pc, const std::string instr_str) {
|
|
||||||
if(trc->m_db == nullptr)
|
if(trc->m_db == nullptr)
|
||||||
return false;
|
return false;
|
||||||
if(trc->tr_handle.is_active())
|
if(trc->tr_handle.is_active())
|
||||||
@ -347,8 +339,7 @@ bool core_complex<BUSWIDTH>::disass_output(uint64_t pc, const std::string instr_
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <unsigned int BUSWIDTH>
|
template <unsigned int BUSWIDTH> void core_complex<BUSWIDTH>::forward() {
|
||||||
void core_complex<BUSWIDTH>::forward() {
|
|
||||||
#ifndef CWR_SYSTEMC
|
#ifndef CWR_SYSTEMC
|
||||||
set_clock_period(clk_i.read());
|
set_clock_period(clk_i.read());
|
||||||
#else
|
#else
|
||||||
@ -357,30 +348,24 @@ void core_complex<BUSWIDTH>::forward() {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
template <unsigned int BUSWIDTH>
|
template <unsigned int BUSWIDTH> void core_complex<BUSWIDTH>::set_clock_period(sc_core::sc_time period) {
|
||||||
void core_complex<BUSWIDTH>::set_clock_period(sc_core::sc_time period) {
|
|
||||||
curr_clk = period;
|
curr_clk = period;
|
||||||
if(period == SC_ZERO_TIME)
|
if(period == SC_ZERO_TIME)
|
||||||
cpu->set_interrupt_execution(true);
|
cpu->set_interrupt_execution(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <unsigned int BUSWIDTH>
|
template <unsigned int BUSWIDTH> void core_complex<BUSWIDTH>::rst_cb() {
|
||||||
void core_complex<BUSWIDTH>::rst_cb() {
|
|
||||||
if(rst_i.read())
|
if(rst_i.read())
|
||||||
cpu->set_interrupt_execution(true);
|
cpu->set_interrupt_execution(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <unsigned int BUSWIDTH>
|
template <unsigned int BUSWIDTH> void core_complex<BUSWIDTH>::sw_irq_cb() { cpu->local_irq(3, sw_irq_i.read()); }
|
||||||
void core_complex<BUSWIDTH>::sw_irq_cb() { cpu->local_irq(3, sw_irq_i.read()); }
|
|
||||||
|
|
||||||
template <unsigned int BUSWIDTH>
|
template <unsigned int BUSWIDTH> void core_complex<BUSWIDTH>::timer_irq_cb() { cpu->local_irq(7, timer_irq_i.read()); }
|
||||||
void core_complex<BUSWIDTH>::timer_irq_cb() { cpu->local_irq(7, timer_irq_i.read()); }
|
|
||||||
|
|
||||||
template <unsigned int BUSWIDTH>
|
template <unsigned int BUSWIDTH> void core_complex<BUSWIDTH>::ext_irq_cb() { cpu->local_irq(11, ext_irq_i.read()); }
|
||||||
void core_complex<BUSWIDTH>::ext_irq_cb() { cpu->local_irq(11, ext_irq_i.read()); }
|
|
||||||
|
|
||||||
template <unsigned int BUSWIDTH>
|
template <unsigned int BUSWIDTH> void core_complex<BUSWIDTH>::local_irq_cb() {
|
||||||
void core_complex<BUSWIDTH>::local_irq_cb() {
|
|
||||||
for(auto i = 0U; i < local_irq_i.size(); ++i) {
|
for(auto i = 0U; i < local_irq_i.size(); ++i) {
|
||||||
if(local_irq_i[i].event()) {
|
if(local_irq_i[i].event()) {
|
||||||
cpu->local_irq(16 + i, local_irq_i[i].read());
|
cpu->local_irq(16 + i, local_irq_i[i].read());
|
||||||
@ -388,8 +373,7 @@ void core_complex<BUSWIDTH>::local_irq_cb() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <unsigned int BUSWIDTH>
|
template <unsigned int BUSWIDTH> void core_complex<BUSWIDTH>::run() {
|
||||||
void core_complex<BUSWIDTH>::run() {
|
|
||||||
wait(SC_ZERO_TIME); // separate from elaboration phase
|
wait(SC_ZERO_TIME); // separate from elaboration phase
|
||||||
do {
|
do {
|
||||||
wait(SC_ZERO_TIME);
|
wait(SC_ZERO_TIME);
|
||||||
@ -407,8 +391,7 @@ void core_complex<BUSWIDTH>::run() {
|
|||||||
sc_stop();
|
sc_stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <unsigned int BUSWIDTH>
|
template <unsigned int BUSWIDTH> bool core_complex<BUSWIDTH>::read_mem(uint64_t addr, unsigned length, uint8_t* const data, bool is_fetch) {
|
||||||
bool core_complex<BUSWIDTH>::read_mem(uint64_t addr, unsigned length, uint8_t* const data, bool is_fetch) {
|
|
||||||
auto& dmi_lut = is_fetch ? fetch_lut : read_lut;
|
auto& dmi_lut = is_fetch ? fetch_lut : read_lut;
|
||||||
auto lut_entry = dmi_lut.getEntry(addr);
|
auto lut_entry = dmi_lut.getEntry(addr);
|
||||||
if(lut_entry.get_granted_access() != tlm::tlm_dmi::DMI_ACCESS_NONE && addr + length <= lut_entry.get_end_address() + 1) {
|
if(lut_entry.get_granted_access() != tlm::tlm_dmi::DMI_ACCESS_NONE && addr + length <= lut_entry.get_end_address() + 1) {
|
||||||
@ -466,8 +449,7 @@ bool core_complex<BUSWIDTH>::read_mem(uint64_t addr, unsigned length, uint8_t* c
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <unsigned int BUSWIDTH>
|
template <unsigned int BUSWIDTH> bool core_complex<BUSWIDTH>::write_mem(uint64_t addr, unsigned length, const uint8_t* const data) {
|
||||||
bool core_complex<BUSWIDTH>::write_mem(uint64_t addr, unsigned length, const uint8_t* const data) {
|
|
||||||
auto lut_entry = write_lut.getEntry(addr);
|
auto lut_entry = write_lut.getEntry(addr);
|
||||||
if(lut_entry.get_granted_access() != tlm::tlm_dmi::DMI_ACCESS_NONE && addr + length <= lut_entry.get_end_address() + 1) {
|
if(lut_entry.get_granted_access() != tlm::tlm_dmi::DMI_ACCESS_NONE && addr + length <= lut_entry.get_end_address() + 1) {
|
||||||
auto offset = addr - lut_entry.get_start_address();
|
auto offset = addr - lut_entry.get_start_address();
|
||||||
@ -515,8 +497,7 @@ bool core_complex<BUSWIDTH>::write_mem(uint64_t addr, unsigned length, const uin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <unsigned int BUSWIDTH>
|
template <unsigned int BUSWIDTH> bool core_complex<BUSWIDTH>::read_mem_dbg(uint64_t addr, unsigned length, uint8_t* const data) {
|
||||||
bool core_complex<BUSWIDTH>::read_mem_dbg(uint64_t addr, unsigned length, uint8_t* const data) {
|
|
||||||
tlm::tlm_generic_payload gp;
|
tlm::tlm_generic_payload gp;
|
||||||
gp.set_command(tlm::TLM_READ_COMMAND);
|
gp.set_command(tlm::TLM_READ_COMMAND);
|
||||||
gp.set_address(addr);
|
gp.set_address(addr);
|
||||||
@ -526,8 +507,7 @@ bool core_complex<BUSWIDTH>::read_mem_dbg(uint64_t addr, unsigned length, uint8_
|
|||||||
return dbus->transport_dbg(gp) == length;
|
return dbus->transport_dbg(gp) == length;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <unsigned int BUSWIDTH>
|
template <unsigned int BUSWIDTH> bool core_complex<BUSWIDTH>::write_mem_dbg(uint64_t addr, unsigned length, const uint8_t* const data) {
|
||||||
bool core_complex<BUSWIDTH>::write_mem_dbg(uint64_t addr, unsigned length, const uint8_t* const data) {
|
|
||||||
write_buf.resize(length);
|
write_buf.resize(length);
|
||||||
std::copy(data, data + length, write_buf.begin()); // need to copy as TLM does not guarantee data integrity
|
std::copy(data, data + length, write_buf.begin()); // need to copy as TLM does not guarantee data integrity
|
||||||
tlm::tlm_generic_payload gp;
|
tlm::tlm_generic_payload gp;
|
||||||
|
@ -33,10 +33,10 @@
|
|||||||
#ifndef _SYSC_CORE_COMPLEX_H_
|
#ifndef _SYSC_CORE_COMPLEX_H_
|
||||||
#define _SYSC_CORE_COMPLEX_H_
|
#define _SYSC_CORE_COMPLEX_H_
|
||||||
|
|
||||||
|
#include <scc/signal_opt_ports.h>
|
||||||
#include <scc/tick2time.h>
|
#include <scc/tick2time.h>
|
||||||
#include <scc/traceable.h>
|
#include <scc/traceable.h>
|
||||||
#include <scc/utilities.h>
|
#include <scc/utilities.h>
|
||||||
#include <scc/signal_opt_ports.h>
|
|
||||||
#include <tlm/scc/initiator_mixin.h>
|
#include <tlm/scc/initiator_mixin.h>
|
||||||
#include <tlm/scc/scv/tlm_rec_initiator_socket.h>
|
#include <tlm/scc/scv/tlm_rec_initiator_socket.h>
|
||||||
#ifdef CWR_SYSTEMC
|
#ifdef CWR_SYSTEMC
|
||||||
@ -71,27 +71,27 @@ struct core_complex_if {
|
|||||||
|
|
||||||
virtual ~core_complex_if() = default;
|
virtual ~core_complex_if() = default;
|
||||||
|
|
||||||
virtual bool read_mem(uint64_t addr, unsigned length, uint8_t* const data, bool is_fetch) =0;
|
virtual bool read_mem(uint64_t addr, unsigned length, uint8_t* const data, bool is_fetch) = 0;
|
||||||
|
|
||||||
virtual bool write_mem(uint64_t addr, unsigned length, const uint8_t* const data) =0;
|
virtual bool write_mem(uint64_t addr, unsigned length, const uint8_t* const data) = 0;
|
||||||
|
|
||||||
virtual bool read_mem_dbg(uint64_t addr, unsigned length, uint8_t* const data) =0;
|
virtual bool read_mem_dbg(uint64_t addr, unsigned length, uint8_t* const data) = 0;
|
||||||
|
|
||||||
virtual bool write_mem_dbg(uint64_t addr, unsigned length, const uint8_t* const data) =0;
|
virtual bool write_mem_dbg(uint64_t addr, unsigned length, const uint8_t* const data) = 0;
|
||||||
|
|
||||||
virtual bool disass_output(uint64_t pc, const std::string instr) =0;
|
virtual bool disass_output(uint64_t pc, const std::string instr) = 0;
|
||||||
|
|
||||||
virtual unsigned get_last_bus_cycles() =0;
|
virtual unsigned get_last_bus_cycles() = 0;
|
||||||
|
|
||||||
virtual void sync(uint64_t) =0;
|
//! Allow quantum keeper handling
|
||||||
|
virtual void sync(uint64_t) = 0;
|
||||||
|
|
||||||
virtual char const* hier_name() = 0;
|
virtual char const* hier_name() = 0;
|
||||||
|
|
||||||
scc::sc_in_opt<uint64_t> mtime_i{"mtime_i"};
|
scc::sc_in_opt<uint64_t> mtime_i{"mtime_i"};
|
||||||
};
|
};
|
||||||
|
|
||||||
template <unsigned int BUSWIDTH = scc::LT>
|
template <unsigned int BUSWIDTH = scc::LT> class core_complex : public sc_core::sc_module, public scc::traceable, public core_complex_if {
|
||||||
class core_complex : public sc_core::sc_module, public scc::traceable, public core_complex_if {
|
|
||||||
public:
|
public:
|
||||||
tlm::scc::initiator_mixin<tlm::tlm_initiator_socket<BUSWIDTH>> ibus{"ibus"};
|
tlm::scc::initiator_mixin<tlm::tlm_initiator_socket<BUSWIDTH>> ibus{"ibus"};
|
||||||
|
|
||||||
@ -207,9 +207,7 @@ public:
|
|||||||
|
|
||||||
void set_clock_period(sc_core::sc_time period);
|
void set_clock_period(sc_core::sc_time period);
|
||||||
|
|
||||||
char const* hier_name() override {
|
char const* hier_name() override { return name(); }
|
||||||
return name();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void before_end_of_elaboration() override;
|
void before_end_of_elaboration() override;
|
||||||
|
@ -46,12 +46,12 @@ using namespace sysc;
|
|||||||
volatile std::array<bool, 2> tgc_init = {
|
volatile std::array<bool, 2> tgc_init = {
|
||||||
iss_factory::instance().register_creator("tgc5c|m_p|interp",
|
iss_factory::instance().register_creator("tgc5c|m_p|interp",
|
||||||
[](unsigned gdb_port, void* data) -> iss_factory::base_t {
|
[](unsigned gdb_port, void* data) -> iss_factory::base_t {
|
||||||
auto cc = reinterpret_cast<sysc::tgfs::core_complex*>(data);
|
auto cc = reinterpret_cast<sysc::tgfs::core_complex_if*>(data);
|
||||||
auto* cpu = new sc_core_adapter<arch::riscv_hart_m_p<arch::tgc5c>>(cc);
|
auto* cpu = new sc_core_adapter<arch::riscv_hart_m_p<arch::tgc5c>>(cc);
|
||||||
return {sysc::sc_cpu_ptr{cpu}, vm_ptr{create(static_cast<arch::tgc5c*>(cpu), gdb_port)}};
|
return {sysc::sc_cpu_ptr{cpu}, vm_ptr{create(static_cast<arch::tgc5c*>(cpu), gdb_port)}};
|
||||||
}),
|
}),
|
||||||
iss_factory::instance().register_creator("tgc5c|mu_p|interp", [](unsigned gdb_port, void* data) -> iss_factory::base_t {
|
iss_factory::instance().register_creator("tgc5c|mu_p|interp", [](unsigned gdb_port, void* data) -> iss_factory::base_t {
|
||||||
auto cc = reinterpret_cast<sysc::tgfs::core_complex*>(data);
|
auto cc = reinterpret_cast<sysc::tgfs::core_complex_if*>(data);
|
||||||
auto* cpu = new sc_core_adapter<arch::riscv_hart_mu_p<arch::tgc5c>>(cc);
|
auto* cpu = new sc_core_adapter<arch::riscv_hart_mu_p<arch::tgc5c>>(cc);
|
||||||
return {sysc::sc_cpu_ptr{cpu}, vm_ptr{create(static_cast<arch::tgc5c*>(cpu), gdb_port)}};
|
return {sysc::sc_cpu_ptr{cpu}, vm_ptr{create(static_cast<arch::tgc5c*>(cpu), gdb_port)}};
|
||||||
})};
|
})};
|
||||||
@ -79,12 +79,12 @@ using namespace sysc;
|
|||||||
volatile std::array<bool, 2> tgc_init = {
|
volatile std::array<bool, 2> tgc_init = {
|
||||||
iss_factory::instance().register_creator("tgc5c|m_p|tcc",
|
iss_factory::instance().register_creator("tgc5c|m_p|tcc",
|
||||||
[](unsigned gdb_port, void* data) -> iss_factory::base_t {
|
[](unsigned gdb_port, void* data) -> iss_factory::base_t {
|
||||||
auto cc = reinterpret_cast<sysc::tgfs::core_complex*>(data);
|
auto cc = reinterpret_cast<sysc::tgfs::core_complex_if*>(data);
|
||||||
auto* cpu = new sc_core_adapter<arch::riscv_hart_m_p<arch::tgc5c>>(cc);
|
auto* cpu = new sc_core_adapter<arch::riscv_hart_m_p<arch::tgc5c>>(cc);
|
||||||
return {sysc::sc_cpu_ptr{cpu}, vm_ptr{create(static_cast<arch::tgc5c*>(cpu), gdb_port)}};
|
return {sysc::sc_cpu_ptr{cpu}, vm_ptr{create(static_cast<arch::tgc5c*>(cpu), gdb_port)}};
|
||||||
}),
|
}),
|
||||||
iss_factory::instance().register_creator("tgc5c|mu_p|tcc", [](unsigned gdb_port, void* data) -> iss_factory::base_t {
|
iss_factory::instance().register_creator("tgc5c|mu_p|tcc", [](unsigned gdb_port, void* data) -> iss_factory::base_t {
|
||||||
auto cc = reinterpret_cast<sysc::tgfs::core_complex*>(data);
|
auto cc = reinterpret_cast<sysc::tgfs::core_complex_if*>(data);
|
||||||
auto* cpu = new sc_core_adapter<arch::riscv_hart_mu_p<arch::tgc5c>>(cc);
|
auto* cpu = new sc_core_adapter<arch::riscv_hart_mu_p<arch::tgc5c>>(cc);
|
||||||
return {sysc::sc_cpu_ptr{cpu}, vm_ptr{create(static_cast<arch::tgc5c*>(cpu), gdb_port)}};
|
return {sysc::sc_cpu_ptr{cpu}, vm_ptr{create(static_cast<arch::tgc5c*>(cpu), gdb_port)}};
|
||||||
})};
|
})};
|
||||||
@ -96,12 +96,12 @@ using namespace sysc;
|
|||||||
volatile std::array<bool, 2> tgc_init = {
|
volatile std::array<bool, 2> tgc_init = {
|
||||||
iss_factory::instance().register_creator("tgc5c|m_p|asmjit",
|
iss_factory::instance().register_creator("tgc5c|m_p|asmjit",
|
||||||
[](unsigned gdb_port, void* data) -> iss_factory::base_t {
|
[](unsigned gdb_port, void* data) -> iss_factory::base_t {
|
||||||
auto cc = reinterpret_cast<sysc::tgfs::core_complex*>(data);
|
auto cc = reinterpret_cast<sysc::tgfs::core_complex_if*>(data);
|
||||||
auto* cpu = new sc_core_adapter<arch::riscv_hart_m_p<arch::tgc5c>>(cc);
|
auto* cpu = new sc_core_adapter<arch::riscv_hart_m_p<arch::tgc5c>>(cc);
|
||||||
return {sysc::sc_cpu_ptr{cpu}, vm_ptr{create(static_cast<arch::tgc5c*>(cpu), gdb_port)}};
|
return {sysc::sc_cpu_ptr{cpu}, vm_ptr{create(static_cast<arch::tgc5c*>(cpu), gdb_port)}};
|
||||||
}),
|
}),
|
||||||
iss_factory::instance().register_creator("tgc5c|mu_p|asmjit", [](unsigned gdb_port, void* data) -> iss_factory::base_t {
|
iss_factory::instance().register_creator("tgc5c|mu_p|asmjit", [](unsigned gdb_port, void* data) -> iss_factory::base_t {
|
||||||
auto cc = reinterpret_cast<sysc::tgfs::core_complex*>(data);
|
auto cc = reinterpret_cast<sysc::tgfs::core_complex_if*>(data);
|
||||||
auto* cpu = new sc_core_adapter<arch::riscv_hart_mu_p<arch::tgc5c>>(cc);
|
auto* cpu = new sc_core_adapter<arch::riscv_hart_mu_p<arch::tgc5c>>(cc);
|
||||||
return {sysc::sc_cpu_ptr{cpu}, vm_ptr{create(static_cast<arch::tgc5c*>(cpu), gdb_port)}};
|
return {sysc::sc_cpu_ptr{cpu}, vm_ptr{create(static_cast<arch::tgc5c*>(cpu), gdb_port)}};
|
||||||
})};
|
})};
|
||||||
|
@ -55,8 +55,8 @@ public:
|
|||||||
s << "[p:" << lvl[this->reg.PRIV] << ";s:0x" << std::hex << std::setfill('0') << std::setw(sizeof(reg_t) * 2)
|
s << "[p:" << lvl[this->reg.PRIV] << ";s:0x" << std::hex << std::setfill('0') << std::setw(sizeof(reg_t) * 2)
|
||||||
<< (reg_t)this->state.mstatus << std::dec << ";c:" << this->reg.icount + this->cycle_offset << "]";
|
<< (reg_t)this->state.mstatus << std::dec << ";c:" << this->reg.icount + this->cycle_offset << "]";
|
||||||
SCCDEBUG(owner->hier_name()) << "disass: "
|
SCCDEBUG(owner->hier_name()) << "disass: "
|
||||||
<< "0x" << std::setw(16) << std::right << std::setfill('0') << std::hex << pc << "\t\t" << std::setw(40)
|
<< "0x" << std::setw(16) << std::right << std::setfill('0') << std::hex << pc << "\t\t"
|
||||||
<< std::setfill(' ') << std::left << instr << s.str();
|
<< std::setw(40) << std::setfill(' ') << std::left << instr << s.str();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -113,7 +113,7 @@ public:
|
|||||||
|
|
||||||
iss::status read_csr(unsigned addr, reg_t& val) override {
|
iss::status read_csr(unsigned addr, reg_t& val) override {
|
||||||
if((addr == iss::arch::time || addr == iss::arch::timeh)) {
|
if((addr == iss::arch::time || addr == iss::arch::timeh)) {
|
||||||
uint64_t time_val = owner->mtime_i.get_interface()? owner->mtime_i.read():0;
|
uint64_t time_val = owner->mtime_i.get_interface() ? owner->mtime_i.read() : 0;
|
||||||
if(addr == iss::arch::time) {
|
if(addr == iss::arch::time) {
|
||||||
val = static_cast<reg_t>(time_val);
|
val = static_cast<reg_t>(time_val);
|
||||||
} else if(addr == iss::arch::timeh) {
|
} else if(addr == iss::arch::timeh) {
|
||||||
@ -163,7 +163,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
sysc::tgfs::core_complex_if* const owner;
|
sysc::tgfs::core_complex_if* const owner{nullptr};
|
||||||
sc_core::sc_event wfi_evt;
|
sc_core::sc_event wfi_evt;
|
||||||
uint64_t hostvar{std::numeric_limits<uint64_t>::max()};
|
uint64_t hostvar{std::numeric_limits<uint64_t>::max()};
|
||||||
unsigned to_host_wr_cnt = 0;
|
unsigned to_host_wr_cnt = 0;
|
||||||
|
@ -333,10 +333,14 @@ typename vm_base<ARCH>::virt_addr_t vm_impl<ARCH>::execute_inst(finish_cond_e co
|
|||||||
while(!this->core.should_stop() &&
|
while(!this->core.should_stop() &&
|
||||||
!(is_icount_limit_enabled(cond) && icount >= count_limit) &&
|
!(is_icount_limit_enabled(cond) && icount >= count_limit) &&
|
||||||
!(is_fcount_limit_enabled(cond) && fetch_count >= count_limit)){
|
!(is_fcount_limit_enabled(cond) && fetch_count >= count_limit)){
|
||||||
fetch_count++;
|
if(this->debugging_enabled())
|
||||||
|
this->tgt_adapter->check_continue(*PC);
|
||||||
|
pc.val=*PC;
|
||||||
if(fetch_ins(pc, data)!=iss::Ok){
|
if(fetch_ins(pc, data)!=iss::Ok){
|
||||||
this->do_sync(POST_SYNC, std::numeric_limits<unsigned>::max());
|
if(this->sync_exec && PRE_SYNC) this->do_sync(PRE_SYNC, std::numeric_limits<unsigned>::max());
|
||||||
pc.val = super::core.enter_trap(std::numeric_limits<uint64_t>::max(), pc.val, 0);
|
process_spawn_blocks();
|
||||||
|
if(this->sync_exec && POST_SYNC) this->do_sync(PRE_SYNC, std::numeric_limits<unsigned>::max());
|
||||||
|
pc.val = super::core.enter_trap(arch::traits<ARCH>::RV_CAUSE_FETCH_ACCESS<<16, pc.val, 0);
|
||||||
} else {
|
} else {
|
||||||
if (is_jump_to_self_enabled(cond) &&
|
if (is_jump_to_self_enabled(cond) &&
|
||||||
(instr == 0x0000006f || (instr&0xffff)==0xa001)) throw simulation_stopped(0); // 'J 0' or 'C.J 0'
|
(instr == 0x0000006f || (instr&0xffff)==0xa001)) throw simulation_stopped(0); // 'J 0' or 'C.J 0'
|
||||||
@ -2673,11 +2677,11 @@ typename vm_base<ARCH>::virt_addr_t vm_impl<ARCH>::execute_inst(finish_cond_e co
|
|||||||
icount++;
|
icount++;
|
||||||
instret++;
|
instret++;
|
||||||
}
|
}
|
||||||
cycle++;
|
*PC = *NEXT_PC;
|
||||||
pc.val=*NEXT_PC;
|
|
||||||
this->core.reg.PC = this->core.reg.NEXT_PC;
|
|
||||||
this->core.reg.trap_state = this->core.reg.pending_trap;
|
this->core.reg.trap_state = this->core.reg.pending_trap;
|
||||||
}
|
}
|
||||||
|
fetch_count++;
|
||||||
|
cycle++;
|
||||||
}
|
}
|
||||||
return pc;
|
return pc;
|
||||||
}
|
}
|
||||||
|
@ -2553,9 +2553,8 @@ private:
|
|||||||
|
|
||||||
this->gen_instr_prologue();
|
this->gen_instr_prologue();
|
||||||
/*generate behavior*/
|
/*generate behavior*/
|
||||||
auto wait_arg0 = this->gen_const(8,1);
|
|
||||||
std::vector<Value*> wait_args{
|
std::vector<Value*> wait_args{
|
||||||
wait_arg0
|
this->gen_ext(this->gen_const(8,1), 32)
|
||||||
};
|
};
|
||||||
this->builder.CreateCall(this->mod->getFunction("wait"), wait_args);
|
this->builder.CreateCall(this->mod->getFunction("wait"), wait_args);
|
||||||
bb = BasicBlock::Create(this->mod->getContext(), "entry", this->func, this->leave_blk);
|
bb = BasicBlock::Create(this->mod->getContext(), "entry", this->func, this->leave_blk);
|
||||||
@ -2719,7 +2718,7 @@ private:
|
|||||||
csr,
|
csr,
|
||||||
this->builder.CreateAnd(
|
this->builder.CreateAnd(
|
||||||
xrd,
|
xrd,
|
||||||
this->builder.CreateNeg(xrs1))
|
this->builder.CreateNot(xrs1))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if(rd!=0) {
|
if(rd!=0) {
|
||||||
|
Reference in New Issue
Block a user