Go to the documentation of this file.
41 #ifndef __BASE_ADDR_RANGE_HH__
42 #define __BASE_ADDR_RANGE_HH__
129 uint8_t _intlv_match)
135 "Match value %d does not fit in %d interleaving bits\n",
136 _intlv_match,
masks.size());
166 uint8_t _xor_high_bit, uint8_t _intlv_bits,
167 uint8_t _intlv_match)
172 fatal_if(_intlv_bits && _intlv_match >=
ULL(1) << _intlv_bits,
173 "Match value %d does not fit in %d interleaving bits\n",
174 _intlv_match, _intlv_bits);
177 if (_intlv_bits && _xor_high_bit) {
178 if (_xor_high_bit == _intlv_high_bit) {
179 fatal(
"XOR and interleave high bit must be different\n");
180 }
else if (_xor_high_bit > _intlv_high_bit) {
181 if ((_xor_high_bit - _intlv_high_bit) < _intlv_bits)
182 fatal(
"XOR and interleave high bit must be at least "
183 "%d bits apart\n", _intlv_bits);
185 if ((_intlv_high_bit - _xor_high_bit) < _intlv_bits) {
186 fatal(
"Interleave and XOR high bit must be at least "
187 "%d bits apart\n", _intlv_bits);
192 for (
auto i = 0;
i < _intlv_bits;
i++) {
193 uint8_t bit1 = _intlv_high_bit -
i;
196 uint8_t bit2 = _xor_high_bit -
i;
218 if (!ranges.empty()) {
220 _start = ranges.front()._start;
221 _end = ranges.front()._end;
222 masks = ranges.front().masks;
227 if (ranges.size() > 1) {
229 if (ranges.size() != (
ULL(1) <<
masks.size()))
230 fatal(
"Got %d ranges spanning %d interleaving bits\n",
231 ranges.size(),
masks.size());
234 for (
const auto&
r : ranges) {
236 fatal(
"Can only merge ranges with the same start, end "
237 "and interleaving bits, %s %s\n",
to_string(),
240 if (
r.intlvMatch != match)
241 fatal(
"Expected interleave match %d but got %d when "
242 "merging\n", match,
r.intlvMatch);
269 auto combined_mask = 0;
271 combined_mask |=
mask;
273 const uint8_t lowest_bit =
ctz64(combined_mask);
274 return ULL(1) << lowest_bit;
334 for (
int i = 0;
i <
masks.size();
i++) {
396 panic(
"Cannot test intersection of %s and %s\n",
413 panic(
"Cannot test subset of interleaved range %s\n",
to_string());
419 if (
r.interleaved()) {
421 size() <=
r.granularity();
443 for (
int i = 0;
i <
masks.size();
i++) {
483 int masks_lsb[
masks.size()];
484 for (
int i = 0;
i <
masks.size();
i++) {
490 std::sort(masks_lsb, masks_lsb +
masks.size());
492 for (
int i = 0;
i <
masks.size();
i++) {
493 const int intlv_bit = masks_lsb[
i];
515 int masks_lsb[
masks.size()];
516 for (
int i = 0;
i <
masks.size();
i++) {
521 std::sort(masks_lsb, masks_lsb +
masks.size());
522 for (
int i = 0;
i <
masks.size();
i++) {
523 const int intlv_bit = masks_lsb[
i];
534 for (
int i = 0;
i <
masks.size();
i++) {
596 if (
_start !=
r._start)
return false;
597 if (
_end !=
r._end)
return false;
598 if (
masks !=
r.masks)
return false;
609 return !(*
this ==
r);
639 {
return AddrRange(start, start + size); }
641 #endif // __BASE_ADDR_RANGE_HH__
AddrRange(Addr _start, Addr _end, uint8_t _intlv_high_bit, uint8_t _xor_high_bit, uint8_t _intlv_bits, uint8_t _intlv_match)
Legacy constructor of AddrRange.
#define fatal(...)
This implements a cprintf based fatal() function.
bool operator==(const AddrRange &r) const
bool interleaved() const
Determine if the range is interleaved or not.
uint32_t stripes() const
Determine the number of interleaved address stripes this range is part of.
bool contains(const Addr &a) const
Determine if the range contains an address.
Addr end() const
Get the end address of the range.
Addr getOffset(const Addr &a) const
Determine the offset of an address within the range.
Addr removeIntlvBits(Addr a) const
Remove the interleaving bits from an input address.
int popCount(uint64_t val)
Returns the number of set ones in the provided value.
bool operator!=(const AddrRange &r) const
AddrRange(const std::vector< AddrRange > &ranges)
Create an address range by merging a collection of interleaved ranges.
The AddrRange class encapsulates an address range, and supports a number of tests to check if two ran...
std::list< AddrRange > AddrRangeList
Convenience typedef for a collection of address ranges.
bool valid() const
Determine if the range is valid.
AddrRange RangeSize(Addr start, Addr size)
uint8_t intlvMatch
The value to compare sel with.
bool intersects(const AddrRange &r) const
Determine if another range intersects this one, i.e.
Addr addIntlvBits(Addr a) const
This method adds the interleaving bits removed by removeIntlvBits.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Addr _start
Private fields for the start and end of the range _start is the beginning of the range (inclusive).
uint64_t granularity() const
Determing the interleaving granularity of the range.
Addr start() const
Get the start address of the range.
std::string to_string() const
Get a string representation of the range.
int ctz64(uint64_t value)
Count trailing zeros in a 64-bit value.
std::vector< Addr > masks
Each mask determines the bits we need to xor to get one bit of sel.
AddrRange(Addr _start, Addr _end)
T insertBits(T val, int first, int last, B bit_val)
Returns val with bits first to last set to the LSBs of bit_val.
bool mergesWith(const AddrRange &r) const
Determine if another range merges with the current one, i.e.
AddrRange(Addr _start, Addr _end, const std::vector< Addr > &_masks, uint8_t _intlv_match)
Construct an address range.
AddrRange RangeEx(Addr start, Addr end)
bool operator<(const AddrRange &r) const
Less-than operator used to turn an STL map into a binary search tree of non-overlapping address range...
bool isSubset(const AddrRange &r) const
Determine if this range is a subset of another range, i.e.
AddrRange RangeIn(Addr start, Addr end)
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
Addr size() const
Get the size of the address range.
std::string csprintf(const char *format, const Args &...args)
#define ULL(N)
uint64_t constant
#define panic(...)
This implements a cprintf based panic() function.
T bits(T val, int first, int last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it.
Generated on Wed Sep 30 2020 14:02:07 for gem5 by doxygen 1.8.17