Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleaned Up Old Comments in Read/Write Memory Methods #16

Merged
merged 3 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading