From 36d199b9a96838359230f1ae8a40446e05296145 Mon Sep 17 00:00:00 2001 From: Andreas Hansson Date: Mon, 15 Oct 2012 08:07:04 -0400 Subject: 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. --- src/base/addr_range.hh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src/base') 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; + } }; /** -- cgit v1.2.3