aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/models/lt_bus.h1
-rw-r--r--src/utils/range.h6
-rw-r--r--src/utils/types.h1
3 files changed, 7 insertions, 1 deletions
diff --git a/src/models/lt_bus.h b/src/models/lt_bus.h
index c533c50..a8391f8 100644
--- a/src/models/lt_bus.h
+++ b/src/models/lt_bus.h
@@ -47,6 +47,7 @@ class lt_bus : public sc_core::sc_module {
void attach_target(tlm::tlm_base_target_socket_b<>& target,
u64 start,
u64 end) {
+ assert(start <= end);
const range addr{start, end};
// Check if new range overlaps with any registered memory map range.
diff --git a/src/utils/range.h b/src/utils/range.h
index ce25298..e4ef12f 100644
--- a/src/utils/range.h
+++ b/src/utils/range.h
@@ -7,7 +7,7 @@
struct range {
constexpr explicit range(u64 start, u64 end) : start{start}, end{end} {
- assert(start < end);
+ assert(start <= end);
}
constexpr bool overlaps(range rhs) const {
@@ -18,6 +18,10 @@ struct range {
return start <= rhs.start && rhs.end <= end;
}
+ constexpr bool operator==(range rhs) const {
+ return start == rhs.start && end == rhs.end;
+ }
+
u64 start;
u64 end;
};
diff --git a/src/utils/types.h b/src/utils/types.h
index a13b8ef..4f824f6 100644
--- a/src/utils/types.h
+++ b/src/utils/types.h
@@ -3,6 +3,7 @@
#include <cstdint>
+using u8 = std::uint8_t;
using u32 = std::uint32_t;
using u64 = std::uint64_t;