Skip to content

Commit

Permalink
Cleaned Up Old Comments in Read/Write Memory Methods (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
kathlenemagnus authored Nov 21, 2024
1 parent e81e3e5 commit b62fe90
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 20 deletions.
5 changes: 0 additions & 5 deletions .github/workflows/clangformat-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ jobs:
COMPILER: ${{ matrix.COMPILER }}

steps:
- name: Setup Keys
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}

# Get Atlas
- name: Clone Atlas
uses: actions/checkout@v4
Expand Down
5 changes: 0 additions & 5 deletions .github/workflows/ubuntu-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ jobs:
COMPILER: ${{ matrix.COMPILER }}

steps:
- name: Setup Keys
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}

# Get Atlas
- name: Clone Atlas
uses: actions/checkout@v4
Expand Down
12 changes: 4 additions & 8 deletions core/AtlasState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,37 +74,33 @@ namespace atlas
translate_unit_ = getContainer()->getChild("translate")->getResourceAs<Translate*>();
}

template <typename MemoryType> MemoryType AtlasState::readMemory(const Addr vaddr)
template <typename MemoryType> MemoryType AtlasState::readMemory(const Addr paddr)
{
// TODO: Get physical address from translation result
const Addr paddr = vaddr;
auto* memory = atlas_system_->getSystemMemory();

static_assert(std::is_trivial<MemoryType>());
static_assert(std::is_standard_layout<MemoryType>());
const size_t size = sizeof(MemoryType);
std::vector<uint8_t> buffer(sizeof(MemoryType) / sizeof(uint8_t), 0);
const bool success = memory->tryRead(paddr, size, buffer.data());
sparta_assert(success, "Failed to read from memory at address 0x" << std::hex << vaddr);
sparta_assert(success, "Failed to read from memory at address 0x" << std::hex << paddr);

const MemoryType value = convertFromByteVector<MemoryType>(buffer);
ILOG("Memory read to 0x" << std::hex << paddr << ": 0x" << (uint64_t)value);
return value;
}

template <typename MemoryType>
void AtlasState::writeMemory(const Addr vaddr, const MemoryType value)
void AtlasState::writeMemory(const Addr paddr, const MemoryType value)
{
// TODO: Get physical address from translation result
const Addr paddr = vaddr;
auto* memory = atlas_system_->getSystemMemory();

static_assert(std::is_trivial<MemoryType>());
static_assert(std::is_standard_layout<MemoryType>());
const size_t size = sizeof(MemoryType);
const std::vector<uint8_t> buffer = convertToByteVector<MemoryType>(value);
const bool success = memory->tryWrite(paddr, size, buffer.data());
sparta_assert(success, "Failed to write to memory at address 0x" << std::hex << vaddr);
sparta_assert(success, "Failed to write to memory at address 0x" << std::hex << paddr);

ILOG("Memory write to 0x" << std::hex << paddr << ": 0x" << (uint64_t)value);
}
Expand Down
4 changes: 2 additions & 2 deletions core/AtlasState.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,9 @@ namespace atlas
return csr_rset_->getRegister(reg_num);
}

template <typename MemoryType> MemoryType readMemory(const Addr vaddr);
template <typename MemoryType> MemoryType readMemory(const Addr paddr);

template <typename MemoryType> void writeMemory(const Addr vaddr, const MemoryType value);
template <typename MemoryType> void writeMemory(const Addr paddr, const MemoryType value);

void addObserver(Observer* observer) { observers_.push_back(observer); }

Expand Down

0 comments on commit b62fe90

Please sign in to comment.