BURTON Mark
Builds for 1 pipeline failed in 4 minutes 25 seconds

add some nicer printing to memory, and make it so it auto-allocates to fill it's port size

... ... @@ -73,7 +73,8 @@
class BaseMemory
{
public:
BaseMemory()
BaseMemory(const char * name):
m_name(name)
{
}
... ... @@ -85,6 +86,11 @@ public:
}
}
void* ptr()
{
return (void *)m_ptr;
}
void allocate_memory(size_t size, bool ro)
{
m_size = size;
... ... @@ -95,7 +101,7 @@ public:
if (!m_ptr)
{
std::cout << "BaseMemory: error: can't create memory." << std::endl;
std::cout << "BaseMemory " << m_name << ": error: can't create memory." << std::endl;
sc_core::sc_stop();
return;
}
... ... @@ -136,7 +142,7 @@ public:
if (offset + size > m_size * 1024)
{
std::cout << "error out of bound memory access.." << std::endl;
std::cout << "BaseMemory " << m_name << ": error out of bound memory access to 0x" << std::hex << offset <<" size 0x"<<size << std::endl;
sc_core::sc_stop();
return;
}
... ... @@ -162,7 +168,7 @@ public:
}
else
{
std::cout << "Invalid command ..." << std::endl;
std::cout << "BaseMemory " << m_name << ": Invalid command ..." << std::endl;
sc_core::sc_stop();
return;
}
... ... @@ -177,7 +183,7 @@ public:
if (size > mask_len)
{
std::cout << "Invalid mask length ..." << std::endl;
std::cout << "BaseMemory " << m_name << ": Invalid mask length ..." << std::endl;
sc_core::sc_stop();
return;
}
... ... @@ -205,7 +211,7 @@ public:
}
else
{
std::cout << "Invalid command ..." << std::endl;
std::cout << "BaseMemory " << m_name << ": Invalid command ..." << std::endl;
sc_core::sc_stop();
return;
}
... ... @@ -238,6 +244,7 @@ private:
size_t m_size;
bool m_ro;
void *m_ptr;
const char *m_name;
};
#endif /* BASE_MEMORY_H */
... ...
... ... @@ -25,7 +25,7 @@ class DualPortMemory:
public:
DualPortMemory(sc_core::sc_module_name name):
sc_core::sc_module(name),
BaseMemory(),
BaseMemory(name),
targetPort0("target_port_0"),
targetPort1("target_port_1"),
m_size("size", 1000),
... ...
... ... @@ -66,14 +66,14 @@ template <unsigned int BUSWIDTH>
class Memory:
public sc_module,
public BaseMemory,
public gs::tlm_b_if<gs::gp::GenericSlaveAccessHandle>
public gs::tlm_td_b_if<gs::gp::GenericSlaveAccessHandle>
{
public:
Memory(sc_core::sc_module_name name):
sc_module(name),
BaseMemory(),
BaseMemory(name),
target_port("target_port"),
m_size("size", 262144),
m_size("size", 0),
m_ro("read_only", false)
{
this->target_port.bind_b_if(*this);
... ... @@ -88,10 +88,19 @@ class Memory:
void end_of_elaboration()
{
if (m_size==0) {
m_size=(((target_port.high_addr - target_port.base_addr)+512)/1024);
std::cout << "Memory " << name() << ": WARNING, auto-setting size to " << m_size << "k " << std::endl;
} else {
if (m_size < (((target_port.high_addr - target_port.base_addr)+512)/1024)) {
std::cout << "Memory " << name() << ": WARNING, you have allocated a different amount of memory than the size of the address map." << std::endl;
}
}
this->allocate_memory(m_size, m_ro);
}
void b_transact(gs::gp::GenericSlaveAccessHandle ah)
void b_transact(gs::gp::GenericSlaveAccessHandle ah, sc_core::sc_time& time)
{
accessHandle t = _getSlaveAccessHandle(ah);
uint32_t offset = t->getMAddr() - target_port.base_addr;
... ...