Skip to content

Commit

Permalink
Changes to support Atlas registers (#539)
Browse files Browse the repository at this point in the history
  • Loading branch information
colby-nyce authored Nov 11, 2024
1 parent a944066 commit 6b015e3
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 10 deletions.
8 changes: 7 additions & 1 deletion sparta/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,13 @@ if (ENABLE_SANITIZERS)
endif ()

set(CMAKE_CXX_FLAGS_PROFILE "-O3 -pg -g")
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g3")
if(DEFINED SPARTA_CXX_FLAGS_DEBUG AND SPARTA_CXX_FLAGS_DEBUG)
set(CMAKE_CXX_FLAGS_DEBUG "${SPARTA_CXX_FLAGS_DEBUG}")
message(STATUS "Using Sparta custom debug flags: ${CMAKE_CXX_FLAGS_DEBUG}")
else()
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g3")
message(STATUS "Using Sparta default debug flags: ${CMAKE_CXX_FLAGS_DEBUG}")
endif()

#
# If we're using CONDA, we might be using the one suggested for
Expand Down
54 changes: 53 additions & 1 deletion sparta/sparta/functional/Register.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1507,6 +1507,48 @@ class Register : public RegisterBase
return ss.str();
}

/*!
* \brief Index of read/write access within register
*/
typedef RegisterBase::index_type index_type;

/*!
* \brief Read value directly from the Register's backing store
* \note This is intentionally hiding the dmiRead() from the base
* class so we don't have to go through the dmiRead_() virtual method.
*/
template <typename T>
inline T dmiRead(index_type idx = 0) const
{
T res;
dmiReadImpl_(&res, sizeof(res), sizeof(res) * idx);
return res;
}

/*!
* \brief Write a value directly to this Register's backing store
* \note No masking, boundary checkor or notification is performed
* \note This is intentionally hiding the dmiWrite() from the base
* class so we don't have to go through the dmiWrite_() virtual method.
*/
template <typename T>
inline void dmiWrite(T val, index_type idx = 0)
{
dmiWriteImpl_(&val, sizeof(val), sizeof(val) * idx);
}

/*!
* \brief Write a value into this register without it being affected by the write-mask
* \warning This ignores read-only fields
* \note This is intentionally hiding the writeUnmasked() from the base
* class so we don't have to go through the dmiWriteImpl_() virtual method.
*/
template <typename T>
inline void writeUnmasked(T val, index_type idx = 0)
{
dmiWriteImpl_(&val, sizeof(T), idx);
}

private:
/*!
* \brief Discover and store the raw location of this Register's data
Expand Down Expand Up @@ -1536,7 +1578,7 @@ class Register : public RegisterBase

void dmiRead_(void *buf, size_t size, size_t offset = 0) const override final
{
memcpy(buf, raw_data_ptr_ + offset, size);
dmiReadImpl_(buf, size, offset);
}

void write_(const void *buf, size_t size, size_t offset=0) override final
Expand All @@ -1559,6 +1601,16 @@ class Register : public RegisterBase
}

void dmiWrite_(const void *buf, size_t size, size_t offset = 0) override final
{
dmiWriteImpl_(buf, size, offset);
}

inline void dmiReadImpl_(void *buf, size_t size, size_t offset = 0) const
{
memcpy(buf, raw_data_ptr_ + offset, size);
}

inline void dmiWriteImpl_(const void *buf, size_t size, size_t offset = 0)
{
memcpy(raw_data_ptr_ + offset, buf, size);
dview_.getLine()->flagDirty();
Expand Down
19 changes: 11 additions & 8 deletions sparta/sparta/functional/RegisterSet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -480,8 +480,9 @@ class RegisterSet : public TreeNode
const RegisterBase::Definition *defs,
const RegisterProxyBase::Definition *proxy_defs,
CurrentBankFunction cbfxn,
RegisterTypeTag<RegisterT> tag)
: TreeNode("regs",
RegisterTypeTag<RegisterT> tag,
const std::string& name = "regs")
: TreeNode(name,
TreeNode::GROUP_NAME_BUILTIN,
TreeNode::GROUP_IDX_NONE,
"Register set")
Expand Down Expand Up @@ -530,8 +531,9 @@ class RegisterSet : public TreeNode
template <typename RegisterT>
RegisterSet(TreeNode *parent,
const RegisterBase::Definition *defs,
RegisterTypeTag<RegisterT> tag)
: RegisterSet(parent, defs, nullptr, nullptr, tag)
RegisterTypeTag<RegisterT> tag,
const std::string& name = "regs")
: RegisterSet(parent, defs, nullptr, nullptr, tag, name)
{
// Handled in delegated consturctor
}
Expand All @@ -541,18 +543,19 @@ class RegisterSet : public TreeNode
create(TreeNode *parent,
const RegisterBase::Definition *defs,
const RegisterProxyBase::Definition *proxy_defs,
CurrentBankFunction cbfxn)
CurrentBankFunction cbfxn,
const std::string& name = "regs")
{
return std::unique_ptr<RegisterSet>(new RegisterSet(
parent, defs, proxy_defs, cbfxn, RegisterTypeTag<RegisterT>()));
parent, defs, proxy_defs, cbfxn, RegisterTypeTag<RegisterT>(), name));
}

template <typename RegisterT = Register>
static std::unique_ptr<RegisterSet>
create(TreeNode *parent, const RegisterBase::Definition *defs)
create(TreeNode *parent, const RegisterBase::Definition *defs, const std::string& name = "regs")
{
return std::unique_ptr<RegisterSet>(new RegisterSet(
parent, defs, RegisterTypeTag<RegisterT>()));
parent, defs, RegisterTypeTag<RegisterT>(), name));
}

/*!
Expand Down

0 comments on commit 6b015e3

Please sign in to comment.