DMI access added (if available)
This commit is contained in:
parent
24a27f39fe
commit
d42d67b991
|
@ -86,6 +86,9 @@ public:
|
|||
|
||||
private:
|
||||
Log *log;
|
||||
|
||||
bool instr_direct_mem_ptr(tlm::tlm_generic_payload&, tlm::tlm_dmi& dmi_data);
|
||||
void invalidate_direct_mem_ptr(sc_dt::uint64 start, sc_dt::uint64 end);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -70,6 +70,9 @@ private:
|
|||
bool interrupt;
|
||||
uint32_t int_cause;
|
||||
bool irq_already_down;
|
||||
|
||||
bool dmi_ptr_valid;
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Process and triggers IRQ if all conditions met
|
||||
|
@ -100,6 +103,8 @@ private:
|
|||
* When called it triggers an IRQ
|
||||
*/
|
||||
void call_interrupt(tlm::tlm_generic_payload &trans, sc_time &delay);
|
||||
|
||||
void invalidate_direct_mem_ptr(sc_dt::uint64 start, sc_dt::uint64 end);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -10,6 +10,8 @@ BusCtrl::BusCtrl(sc_module_name name): sc_module(name)
|
|||
cpu_instr_socket.register_b_transport(this, &BusCtrl::b_transport);
|
||||
cpu_data_socket.register_b_transport(this, &BusCtrl::b_transport);
|
||||
log = Log::getInstance();
|
||||
cpu_instr_socket.register_get_direct_mem_ptr(this, &BusCtrl::instr_direct_mem_ptr);
|
||||
memory_socket.register_invalidate_direct_mem_ptr( this, &BusCtrl::invalidate_direct_mem_ptr);
|
||||
}
|
||||
|
||||
|
||||
|
@ -42,3 +44,12 @@ void BusCtrl::b_transport( tlm::tlm_generic_payload& trans, sc_time& delay ) {
|
|||
|
||||
trans.set_response_status( tlm::TLM_OK_RESPONSE );
|
||||
}
|
||||
|
||||
bool BusCtrl::instr_direct_mem_ptr(tlm::tlm_generic_payload& gp, tlm::tlm_dmi& dmi_data) {
|
||||
return memory_socket->get_direct_mem_ptr(gp, dmi_data);
|
||||
}
|
||||
|
||||
void BusCtrl::invalidate_direct_mem_ptr(sc_dt::uint64 start, sc_dt::uint64 end) {
|
||||
cpu_instr_socket->invalidate_direct_mem_ptr(start, end);
|
||||
}
|
||||
|
||||
|
|
950
src/CPU.cpp
950
src/CPU.cpp
File diff suppressed because it is too large
Load Diff
|
@ -26,7 +26,8 @@ Memory::Memory(sc_module_name name, bool use_file): sc_module(name)
|
|||
socket.register_b_transport( this, &Memory::b_transport);
|
||||
socket.register_get_direct_mem_ptr(this, &Memory::get_direct_mem_ptr);
|
||||
socket.register_transport_dbg( this, &Memory::transport_dbg);
|
||||
|
||||
memory_offset = 0;
|
||||
program_counter = 0;
|
||||
//memset(mem, 0, SIZE*sizeof(uint8_t));
|
||||
}
|
||||
|
||||
|
@ -82,7 +83,11 @@ void Memory::b_transport( tlm::tlm_generic_payload& trans, sc_time& delay )
|
|||
// Set DMI hint to indicated that DMI is supported
|
||||
// *********************************************
|
||||
|
||||
trans.set_dmi_allowed(true);
|
||||
if (memory_offset == 0) {
|
||||
trans.set_dmi_allowed(true);
|
||||
} else {
|
||||
trans.set_dmi_allowed(false);
|
||||
}
|
||||
|
||||
// Obliged to set response status to indicate successful completion
|
||||
trans.set_response_status( tlm::TLM_OK_RESPONSE );
|
||||
|
@ -142,7 +147,7 @@ void Memory::readHexFile(string filename) {
|
|||
address = address + extended_address;
|
||||
//cout << "00 address 0x" << hex << address << endl;
|
||||
for (i=0; i < byte_count; i++) {
|
||||
mem[address+i] = stol(line.substr(9+(i*2), 2), nullptr, 16);
|
||||
mem[address+i] = stol(line.substr(9 + (i * 2), 2), nullptr, 16);
|
||||
}
|
||||
} else if (line.substr(7,2) == "02") {
|
||||
/* Extended segment address */
|
||||
|
@ -157,14 +162,12 @@ void Memory::readHexFile(string filename) {
|
|||
cout << "03 PC set to 0x" << hex << program_counter << endl;
|
||||
} else if (line.substr(7,2) == "04") {
|
||||
/* Start segment address */
|
||||
//extended_address = stol(line.substr(9,4), nullptr, 16) << 16;
|
||||
memory_offset = stol(line.substr(9,4), nullptr, 16) << 16;
|
||||
extended_address = 0;
|
||||
cout << "04 address set to 0x" << hex << extended_address << endl;
|
||||
cout << "04 offset set to 0x" << hex << memory_offset << endl;
|
||||
} else if (line.substr(7,2) == "05") {
|
||||
program_counter = stol(line.substr(9,8), nullptr, 16);
|
||||
//program_counter = 0;
|
||||
cout << "05 PC set to 0x" << hex << program_counter << endl;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,14 +41,11 @@ SC_MODULE(Simulator)
|
|||
BusCtrl* Bus;
|
||||
Trace *trace;
|
||||
Timer *timer;
|
||||
// Log *log;
|
||||
|
||||
uint32_t start_PC;
|
||||
|
||||
SC_CTOR(Simulator)
|
||||
{
|
||||
// log = Log::getInstance();
|
||||
|
||||
MainMemory = new Memory("Main_Memory", filename);
|
||||
start_PC = MainMemory->getPCfromHEX();
|
||||
|
||||
|
@ -127,16 +124,15 @@ void process_arguments(int argc, char* argv[]) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (filename.empty()) {
|
||||
filename = std::string(argv[optind]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int sc_main(int argc, char* argv[])
|
||||
{
|
||||
|
||||
|
||||
/* Capture Ctrl+C and finish the simulation */
|
||||
signal(SIGINT, intHandler);
|
||||
|
||||
|
|
Loading…
Reference in New Issue