Skip to content

Commit

Permalink
Add emulate debug
Browse files Browse the repository at this point in the history
  • Loading branch information
slacrherbst committed Jun 25, 2024
1 parent 67db86b commit 9ab2c11
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
8 changes: 8 additions & 0 deletions include/rogue/interfaces/memory/Emulate.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<rogue::Logging> log_;

public:
//! Class factory which returns a pointer to a Emulate (EmulatePtr)
/** Exposed to Python as rogue.interfaces.memory.Emualte()
Expand Down
14 changes: 12 additions & 2 deletions src/rogue/interfaces/memory/Emulate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 9ab2c11

Please sign in to comment.