remove unused SC_THREAD
This commit is contained in:
parent
406d498209
commit
21003e2fa9
13
inc/Memory.h
13
inc/Memory.h
|
@ -36,6 +36,10 @@ public:
|
||||||
Memory(sc_module_name name, string filename);
|
Memory(sc_module_name name, string filename);
|
||||||
Memory(sc_module_name name, bool use_file);
|
Memory(sc_module_name name, bool use_file);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Returns Program Counter read from hexfile
|
||||||
|
* @return Initial PC
|
||||||
|
*/
|
||||||
virtual uint32_t getPCfromHEX();
|
virtual uint32_t getPCfromHEX();
|
||||||
|
|
||||||
// TLM-2 blocking transport method
|
// TLM-2 blocking transport method
|
||||||
|
@ -48,8 +52,6 @@ public:
|
||||||
virtual bool get_direct_mem_ptr(tlm::tlm_generic_payload& trans,
|
virtual bool get_direct_mem_ptr(tlm::tlm_generic_payload& trans,
|
||||||
tlm::tlm_dmi& dmi_data);
|
tlm::tlm_dmi& dmi_data);
|
||||||
|
|
||||||
void invalidation_process();
|
|
||||||
|
|
||||||
// *********************************************
|
// *********************************************
|
||||||
// TLM-2 debug transport method
|
// TLM-2 debug transport method
|
||||||
// *********************************************
|
// *********************************************
|
||||||
|
@ -57,8 +59,15 @@ public:
|
||||||
virtual unsigned int transport_dbg(tlm::tlm_generic_payload& trans);
|
virtual unsigned int transport_dbg(tlm::tlm_generic_payload& trans);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Memory array in bytes
|
||||||
|
*/
|
||||||
uint8_t mem[SIZE];
|
uint8_t mem[SIZE];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Program counter (PC) read from hex file
|
||||||
|
*/
|
||||||
uint32_t program_counter;
|
uint32_t program_counter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -10,10 +10,8 @@ Memory::Memory(sc_module_name name, string filename): sc_module(name)
|
||||||
socket.register_transport_dbg( this, &Memory::transport_dbg);
|
socket.register_transport_dbg( this, &Memory::transport_dbg);
|
||||||
|
|
||||||
memset(mem, 0, SIZE*sizeof(uint8_t));
|
memset(mem, 0, SIZE*sizeof(uint8_t));
|
||||||
// readCustomHexFile("memory.hex");
|
|
||||||
readHexFile(filename);
|
|
||||||
|
|
||||||
SC_THREAD(invalidation_process);
|
readHexFile(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
Memory::Memory(sc_module_name name, bool use_file): sc_module(name)
|
Memory::Memory(sc_module_name name, bool use_file): sc_module(name)
|
||||||
|
@ -24,11 +22,8 @@ Memory::Memory(sc_module_name name, bool use_file): sc_module(name)
|
||||||
socket.register_transport_dbg( this, &Memory::transport_dbg);
|
socket.register_transport_dbg( this, &Memory::transport_dbg);
|
||||||
|
|
||||||
memset(mem, 0, SIZE*sizeof(int));
|
memset(mem, 0, SIZE*sizeof(int));
|
||||||
|
|
||||||
SC_THREAD(invalidation_process);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint32_t Memory::getPCfromHEX() {
|
uint32_t Memory::getPCfromHEX() {
|
||||||
return program_counter;
|
return program_counter;
|
||||||
|
|
||||||
|
@ -63,9 +58,6 @@ void Memory::b_transport( tlm::tlm_generic_payload& trans, sc_time& delay )
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//cout << "MEM: addr=" << hex << adr << endl << endl;
|
|
||||||
//cout << "MEM: data=" << hex << mem[adr] << endl;
|
|
||||||
|
|
||||||
// Obliged to implement read and write commands
|
// Obliged to implement read and write commands
|
||||||
if ( cmd == tlm::TLM_READ_COMMAND )
|
if ( cmd == tlm::TLM_READ_COMMAND )
|
||||||
memcpy(ptr, &mem[adr], len);
|
memcpy(ptr, &mem[adr], len);
|
||||||
|
@ -104,18 +96,6 @@ bool Memory::get_direct_mem_ptr(tlm::tlm_generic_payload& trans,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Memory::invalidation_process()
|
|
||||||
{
|
|
||||||
// Invalidate DMI pointers periodically
|
|
||||||
for (int i = 0; i < 4; i++)
|
|
||||||
{
|
|
||||||
wait(LATENCY*8);
|
|
||||||
socket->invalidate_direct_mem_ptr(0, SIZE-1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
unsigned int Memory::transport_dbg(tlm::tlm_generic_payload& trans)
|
unsigned int Memory::transport_dbg(tlm::tlm_generic_payload& trans)
|
||||||
{
|
{
|
||||||
tlm::tlm_command cmd = trans.get_command();
|
tlm::tlm_command cmd = trans.get_command();
|
||||||
|
@ -146,27 +126,25 @@ void Memory::readHexFile(string filename) {
|
||||||
|
|
||||||
if (hexfile.is_open()) {
|
if (hexfile.is_open()) {
|
||||||
while(getline(hexfile, line) ) {
|
while(getline(hexfile, line) ) {
|
||||||
/* # is a comentary in the file */
|
|
||||||
if (line[0] == ':') {
|
if (line[0] == ':') {
|
||||||
if (line.substr(7,2) == "00")
|
if (line.substr(7,2) == "00") {
|
||||||
{
|
|
||||||
/* Data */
|
/* Data */
|
||||||
byte_count = stol(line.substr(1,2), nullptr, 16);
|
byte_count = stol(line.substr(1,2), nullptr, 16);
|
||||||
address = stol(line.substr(3,4), nullptr, 16);
|
address = stol(line.substr(3,4), nullptr, 16);
|
||||||
address = address + extended_address;
|
address = address + extended_address;
|
||||||
|
|
||||||
for (i=0; i < byte_count; i++) {
|
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") {
|
} else if (line.substr(7,2) == "02") {
|
||||||
/* Extended segment address */
|
/* Extended segment address */
|
||||||
extended_address = stol(line.substr(9,4), nullptr, 16) * 16;
|
extended_address = stol(line.substr(9,4), nullptr, 16) * 16;
|
||||||
} else if (line.substr(7,2) == "03") {
|
} else if (line.substr(7,2) == "03") {
|
||||||
/* Start segment address */
|
/* Start segment address */
|
||||||
uint32_t code_segment;
|
uint32_t code_segment;
|
||||||
code_segment = stol(line.substr(9,4), nullptr, 16) * 16; /* ? */
|
code_segment = stol(line.substr(9,4), nullptr, 16) * 16; /* ? */
|
||||||
program_counter = stol(line.substr(13,4), nullptr, 16);
|
program_counter = stol(line.substr(13,4), nullptr, 16);
|
||||||
program_counter = program_counter + code_segment;
|
program_counter = program_counter + code_segment;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -174,11 +152,4 @@ void Memory::readHexFile(string filename) {
|
||||||
} else {
|
} else {
|
||||||
SC_REPORT_ERROR("Memory", "Open file error");
|
SC_REPORT_ERROR("Memory", "Open file error");
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
for(int i = 50;i<100; i++) {
|
|
||||||
cout << "Dump address: 0x" << hex << extended_address + i << ": 0x" <<
|
|
||||||
mem[extended_address+i] << dec << endl;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue