Rework on DMI mechanism. Limited memory to 16MB

This commit is contained in:
Màrius Montón 2021-11-16 10:20:59 +01:00
parent e0684b6e40
commit 5caf1b77c8
2 changed files with 19 additions and 11 deletions

View File

@ -29,8 +29,9 @@ public:
// TLM-2 socket, defaults to 32-bits wide, base protocol // TLM-2 socket, defaults to 32-bits wide, base protocol
tlm_utils::simple_target_socket<Memory> socket; tlm_utils::simple_target_socket<Memory> socket;
/* 16 MBytes */
enum { enum {
SIZE = 0xFFFFFFFF SIZE = 0x1000000
}; };
const sc_core::sc_time LATENCY; const sc_core::sc_time LATENCY;
@ -77,7 +78,11 @@ private:
*/ */
std::uint32_t program_counter; std::uint32_t program_counter;
std::uint32_t memory_offset; /**
* @brief DMI can be used?
*/
bool dmi_allowed;
/** /**
* @brief Read Intel hex file * @brief Read Intel hex file
* @param filename file name to read * @param filename file name to read

View File

@ -16,7 +16,7 @@ Memory::Memory(sc_core::sc_module_name const &name, std::string const &filename)
socket.register_get_direct_mem_ptr(this, &Memory::get_direct_mem_ptr); socket.register_get_direct_mem_ptr(this, &Memory::get_direct_mem_ptr);
socket.register_transport_dbg(this, &Memory::transport_dbg); socket.register_transport_dbg(this, &Memory::transport_dbg);
memory_offset = 0; dmi_allowed = false;
program_counter = 0; program_counter = 0;
readHexFile(filename); readHexFile(filename);
@ -29,7 +29,7 @@ Memory::Memory(sc_core::sc_module_name const& name) :
socket.register_b_transport(this, &Memory::b_transport); socket.register_b_transport(this, &Memory::b_transport);
socket.register_get_direct_mem_ptr(this, &Memory::get_direct_mem_ptr); socket.register_get_direct_mem_ptr(this, &Memory::get_direct_mem_ptr);
socket.register_transport_dbg(this, &Memory::transport_dbg); socket.register_transport_dbg(this, &Memory::transport_dbg);
memory_offset = 0;
program_counter = 0; program_counter = 0;
log = Log::getInstance(); log = Log::getInstance();
@ -83,12 +83,7 @@ void Memory::b_transport(tlm::tlm_generic_payload &trans,
// ********************************************* // *********************************************
// Set DMI hint to indicated that DMI is supported // Set DMI hint to indicated that DMI is supported
// ********************************************* // *********************************************
trans.set_dmi_allowed(dmi_allowed);
if (memory_offset == 0) {
trans.set_dmi_allowed(true);
} else {
trans.set_dmi_allowed(false);
}
// Obliged to set response status to indicate successful completion // Obliged to set response status to indicate successful completion
trans.set_response_status(tlm::TLM_OK_RESPONSE); trans.set_response_status(tlm::TLM_OK_RESPONSE);
@ -99,7 +94,7 @@ bool Memory::get_direct_mem_ptr(tlm::tlm_generic_payload &trans,
(void) trans; (void) trans;
if (memory_offset != 0) { if (!dmi_allowed) {
return false; return false;
} }
@ -142,6 +137,7 @@ unsigned int Memory::transport_dbg(tlm::tlm_generic_payload &trans) {
void Memory::readHexFile(std::string const& filename) { void Memory::readHexFile(std::string const& filename) {
std::ifstream hexfile; std::ifstream hexfile;
std::string line; std::string line;
std::uint32_t memory_offset = 0;
hexfile.open(filename); hexfile.open(filename);
@ -192,6 +188,13 @@ void Memory::readHexFile(std::string const& filename) {
} }
} }
hexfile.close(); hexfile.close();
if (memory_offset != 0) {
dmi_allowed = false;
} else {
dmi_allowed = true;
}
} else { } else {
SC_REPORT_ERROR("Memory", "Open file error"); SC_REPORT_ERROR("Memory", "Open file error");
} }