Go to the documentation of this file.
41 #ifndef __BASE_ADDR_RANGE_HH__
42 #define __BASE_ADDR_RANGE_HH__
132 uint8_t _intlv_match)
138 "Match value %d does not fit in %d interleaving bits\n",
139 _intlv_match,
masks.size());
169 uint8_t _xor_high_bit, uint8_t _intlv_bits,
170 uint8_t _intlv_match)
175 fatal_if(_intlv_bits && _intlv_match >= 1ULL << _intlv_bits,
176 "Match value %d does not fit in %d interleaving bits\n",
177 _intlv_match, _intlv_bits);
180 if (_intlv_bits && _xor_high_bit) {
181 if (_xor_high_bit == _intlv_high_bit) {
182 fatal(
"XOR and interleave high bit must be different\n");
183 }
else if (_xor_high_bit > _intlv_high_bit) {
184 if ((_xor_high_bit - _intlv_high_bit) < _intlv_bits)
185 fatal(
"XOR and interleave high bit must be at least "
186 "%d bits apart\n", _intlv_bits);
188 if ((_intlv_high_bit - _xor_high_bit) < _intlv_bits) {
189 fatal(
"Interleave and XOR high bit must be at least "
190 "%d bits apart\n", _intlv_bits);
195 for (
auto i = 0;
i < _intlv_bits;
i++) {
196 uint8_t bit1 = _intlv_high_bit -
i;
199 uint8_t bit2 = _xor_high_bit -
i;
200 mask |= (1ULL << bit2);
221 if (!ranges.empty()) {
223 _start = ranges.front()._start;
224 _end = ranges.front()._end;
225 masks = ranges.front().masks;
230 if (ranges.size() > 1) {
232 if (ranges.size() != (1ULL <<
masks.size()))
233 fatal(
"Got %d ranges spanning %d interleaving bits\n",
234 ranges.size(),
masks.size());
237 for (
const auto&
r : ranges) {
239 fatal(
"Can only merge ranges with the same start, end "
240 "and interleaving bits, %s %s\n",
to_string(),
243 if (
r.intlvMatch != match)
244 fatal(
"Expected interleave match %d but got %d when "
245 "merging\n", match,
r.intlvMatch);
272 auto combined_mask = 0;
274 combined_mask |=
mask;
276 const uint8_t lowest_bit =
ctz64(combined_mask);
277 return 1ULL << lowest_bit;
337 for (
int i = 0;
i <
masks.size();
i++) {
342 mask &= ~(1ULL << bit);
399 panic(
"Cannot test intersection of %s and %s\n",
416 panic(
"Cannot test subset of interleaved range %s\n",
to_string());
422 if (
r.interleaved()) {
424 size() <=
r.granularity();
446 for (
int i = 0;
i <
masks.size();
i++) {
492 int masks_lsb[
masks.size()];
493 for (
int i = 0;
i <
masks.size();
i++) {
499 std::sort(masks_lsb, masks_lsb +
masks.size());
501 for (
int i = 0;
i <
masks.size();
i++) {
502 const int intlv_bit = masks_lsb[
i];
530 int masks_lsb[
masks.size()];
531 for (
int i = 0;
i <
masks.size();
i++) {
536 std::sort(masks_lsb, masks_lsb +
masks.size());
537 for (
int i = 0;
i <
masks.size();
i++) {
538 const int intlv_bit = masks_lsb[
i];
550 for (
int i = 0;
i <
masks.size();
i++) {
619 if (
_start !=
r._start)
return false;
620 if (
_end !=
r._end)
return false;
621 if (
masks !=
r.masks)
return false;
632 return !(*
this ==
r);
662 {
return AddrRange(start, start + size); }
666 #endif // __BASE_ADDR_RANGE_HH__
#define fatal(...)
This implements a cprintf based fatal() function.
std::string to_string() const
Get a string representation of the range.
uint64_t granularity() const
Determing the interleaving granularity of the range.
Addr start() const
Get the start address of the range.
Addr addIntlvBits(Addr a) const
This method adds the interleaving bits removed by removeIntlvBits.
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.
AddrRange RangeSize(Addr start, Addr size)
std::list< AddrRange > AddrRangeList
Convenience typedef for a collection of address ranges.
bool contains(const Addr &a) const
Determine if the range contains an address.
bool intersects(const AddrRange &r) const
Determine if another range intersects this one, i.e.
std::string csprintf(const char *format, const Args &...args)
constexpr int ctz64(uint64_t value)
Count trailing zeros in a 64-bit value.
bool isSubset(const AddrRange &r) const
Determine if this range is a subset of another range, i.e.
Addr _start
Private fields for the start and end of the range _start is the beginning of the range (inclusive).
AddrRange RangeIn(Addr start, Addr end)
Addr removeIntlvBits(Addr a) const
Remove the interleaving bits from an input address.
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...
constexpr uint64_t mask(unsigned nbits)
Generate a 64-bit mask of 'nbits' 1s, right justified.
AddrRange RangeEx(Addr start, Addr end)
bool interleaved() const
Determine if the range is interleaved or not.
constexpr int popCount(uint64_t val)
Returns the number of set ones in the provided value.
AddrRange(const std::vector< AddrRange > &ranges)
Create an address range by merging a collection of interleaved ranges.
std::vector< Addr > masks
Each mask determines the bits we need to xor to get one bit of sel.
Addr size() const
Get the size of the address range.
Addr end() const
Get the end address of the range.
bool valid() const
Determine if the range is valid.
constexpr T insertBits(T val, unsigned first, unsigned last, B bit_val)
Returns val with bits first to last set to the LSBs of bit_val.
constexpr T bits(T val, unsigned first, unsigned last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
bool operator==(const AddrRange &r) const
AddrRange(Addr _start, Addr _end)
uint8_t intlvMatch
The value to compare sel with.
bool mergesWith(const AddrRange &r) const
Determine if another range merges with the current one, i.e.
Addr getOffset(const Addr &a) const
Determine the offset of an address within the range.
bool operator!=(const AddrRange &r) const
The AddrRange class encapsulates an address range, and supports a number of tests to check if two ran...
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
AddrRange(Addr _start, Addr _end, const std::vector< Addr > &_masks, uint8_t _intlv_match)
Construct an address range.
#define panic(...)
This implements a cprintf based panic() function.
uint32_t stripes() const
Determine the number of interleaved address stripes this range is part of.
Generated on Wed Jul 28 2021 12:10:22 for gem5 by doxygen 1.8.17