summaryrefslogtreecommitdiff
path: root/src/base/addr_range.hh
diff options
context:
space:
mode:
authorAndreas Hansson <andreas.hansson@arm.com>2012-10-15 08:07:04 -0400
committerAndreas Hansson <andreas.hansson@arm.com>2012-10-15 08:07:04 -0400
commit36d199b9a96838359230f1ae8a40446e05296145 (patch)
tree8d96e6243c2693fc290b0841477b30300a1f3245 /src/base/addr_range.hh
parent43ca8415e8747145cb1a410d4672d4cd2247c695 (diff)
downloadgem5-36d199b9a96838359230f1ae8a40446e05296145.tar.xz
Mem: Use range operations in bus in preparation for striping
This patch transitions the bus to use the AddrRange operations instead of directly accessing the start and end. The change facilitates the move to a more elaborate AddrRange class that also supports address striping in the bus by specifying interleaving bits in the ranges. Two new functions are added to the AddrRange to determine if two ranges intersect, and if one is a subset of another. The bus propagation of address ranges is also tweaked such that an update is only propagated if the bus received information from all the downstream slave modules. This avoids the iteration and need for the cycle-breaking scheme that was previously used.
Diffstat (limited to 'src/base/addr_range.hh')
-rw-r--r--src/base/addr_range.hh27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/base/addr_range.hh b/src/base/addr_range.hh
index 21593355b..f7a3b054f 100644
--- a/src/base/addr_range.hh
+++ b/src/base/addr_range.hh
@@ -69,6 +69,33 @@ class AddrRange
Addr size() const { return end - start + 1; }
bool valid() const { return start < end; }
+
+ /**
+ * Determine if another range intersects this one, i.e. if there
+ * is an address that is both in this range and the other
+ * range. No check is made to ensure either range is valid.
+ *
+ * @param r Range to intersect with
+ * @return true if the intersection of the two ranges is not empty
+ */
+ bool intersects(const AddrRange& r) const
+ {
+ return (start <= r.start && end >= r.start) ||
+ (start <= r.end && end >= r.end);
+ }
+
+ /**
+ * Determine if this range is a subset of another range, i.e. if
+ * every address in this range is also in the other range. No
+ * check is made to ensure either range is valid.
+ *
+ * @param r Range to compare with
+ * @return true if the this range is a subset of the other one
+ */
+ bool isSubset(const AddrRange& r) const
+ {
+ return start >= r.start && end <= r.end;
+ }
};
/**