Commit f93ae122 authored by Jens Korinth's avatar Jens Korinth
Browse files

Simplify overlap logic in BitRange

parent 57c18b2b
......@@ -4,8 +4,7 @@ package object axi4lite {
/** Tuple-type for bit ranges. */
sealed case class BitRange(to: Int, from: Int) {
require (to >= from && from >= 0, "BitRange: invalid range (%d, %d)".format(to, from))
def overlapsWith(other: BitRange): Boolean = (from <= other.from && to >= other.from) ||
(from > other.from && from <= other.to)
def overlapsWith(other: BitRange): Boolean = !(to < other.from || from > other.to)
}
/** Names for bit ranges. **/
type BitfieldMap = Map[String, BitRange]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment