10#include "sparta/utils/Utils.hpp"
23 typedef uint64_t offset_type;
24 typedef uint32_t ident_type;
48 offset_type subset_offset=0) :
49 offset_(0), is_placed_(false), size_(size),
52 subset_of_(subset_of),
53 subset_offset_(subset_offset)
81 void place(offset_type offset) {
84 ex << ident_ <<
" was already placed. Cannot place again";
99 sparta_assert(is_placed_,
"Should not be invoking writeInitial when is_placed_ is false");
172 virtual void place_(offset_type offset) {
192 const offset_type size_;
198 const ident_type ident_;
199 const ident_type subset_of_;
200 const offset_type subset_offset_;
Set of macros for Sparta assertions. Caught by the framework.
#define sparta_assert(...)
Simple variadic assertion that will throw a sparta_exception if the condition fails.
Exception class for all of Sparta.
static const ident_type INVALID_ID
Indicates an invalid ID for an ArchDataSegment or any refinement.
ArchDataSegment(ArchData *data, offset_type size, ident_type id, ident_type subset_of=INVALID_ID, offset_type subset_offset=0)
Constructor.
virtual ~ArchDataSegment()
Virtual destructor.
ArchData * getArchData()
Gets the ArchData associated with this segment.
offset_type getOffset() const
Gets the offset of this segment once placed.
void place(offset_type offset)
Sets the offset of this DataView within its ArchData then invokes the place_ method for subclasses to...
const ArchData * getArchData() const
Gets the ArchData associated with this segment.
void writeInitial()
Invokes writeInitial_, giving subclasses a chance to write a value to memory during initialization or...
ident_type getLayoutID() const
Gets the layout Identifier of this segment.
ident_type getSubsetOf() const
Gets the segment of which this segment is a subset.
offset_type getSubsetOffset() const
Gets the offset into the segment of which this segment is a subset.
virtual void place_(offset_type offset)
Allows subclasses to observe placement in an ArchData. Do not write an initial value from within this...
offset_type getLayoutSize() const
Gets the layout size of this segment (number of bytes)
bool isPlaced() const
Has this segment been placed yet.
virtual void writeInitial_()
Write initial value of this segment into ArchData. This occurrs immediately after placement and may o...
Contains a set of contiguous line of architectural data which can be referred to by any architected o...
Used to construct and throw a standard C++ exception. Inherits from std::exception.
Macros for handling exponential backoff.
bool isPowerOf2(uint64_t x)
Determines if input is 0 or a power of 2.