diff --git a/include/rogue/interfaces/memory/Emulate.h b/include/rogue/interfaces/memory/Emulate.h index 716eed097..f3d67d6ce 100644 --- a/include/rogue/interfaces/memory/Emulate.h +++ b/include/rogue/interfaces/memory/Emulate.h @@ -44,12 +44,20 @@ namespace memory { * and write transactions. */ class Emulate : public Slave { + // Map to store 4K address space chunks MAP_TYPE memMap_; // Lock std::mutex mtx_; + // Total allocated memory + uint32_t totAlloc_; + uint32_t totSize_; + + //! Log + std::shared_ptr log_; + public: //! Class factory which returns a pointer to a Emulate (EmulatePtr) /** Exposed to Python as rogue.interfaces.memory.Emualte() diff --git a/src/rogue/interfaces/memory/Emulate.cpp b/src/rogue/interfaces/memory/Emulate.cpp index 181fbbd1e..4b77f3b9e 100644 --- a/src/rogue/interfaces/memory/Emulate.cpp +++ b/src/rogue/interfaces/memory/Emulate.cpp @@ -46,7 +46,11 @@ rim::EmulatePtr rim::Emulate::create(uint32_t min, uint32_t max) { } //! Create an block -rim::Emulate::Emulate(uint32_t min, uint32_t max) : Slave(min, max) {} +rim::Emulate::Emulate(uint32_t min, uint32_t max) : Slave(min, max) { + totAlloc_ = 0; + totSize_ = 0; + log_ = rogue::Logging::create("memory.Emulate"); +} //! Destroy a block rim::Emulate::~Emulate() { @@ -82,7 +86,13 @@ void rim::Emulate::doTransaction(rim::TransactionPtr tran) { size -= size4k; addr += size4k; - if (memMap_.find(addr4k) == memMap_.end()) memMap_.insert(std::make_pair(addr4k, (uint8_t*)malloc(0x1000))); + if (memMap_.find(addr4k) == memMap_.end()) { + memMap_.insert(std::make_pair(addr4k, (uint8_t*)malloc(0x1000))); + totSize_ += 0x1000; + totAlloc_ ++; + printf("Got Here\n"); + log_->debug("Allocating block at 0x%x. Total Blocks %i, Total Size = %i", addr4k, totAlloc_, totSize_); + } // Write or post if (tran->type() == rogue::interfaces::memory::Write || tran->type() == rogue::interfaces::memory::Post) {