assign interrupt ranges deterministically
This commit is contained in:
parent
4ac0ef2940
commit
4c3e8ec1b4
@ -15,19 +15,19 @@ import java.nio.{ByteBuffer, ByteOrder}
|
|||||||
|
|
||||||
class RangeManager {
|
class RangeManager {
|
||||||
private var finalized = false
|
private var finalized = false
|
||||||
private val l = collection.mutable.HashMap[String, Int]()
|
private val l = collection.mutable.ListBuffer[(String, Int)]()
|
||||||
def add(name: String, element: Int) = { require(!finalized); l += (name -> element) }
|
def add(name: String, element: Int) = { require(!finalized); l += (name -> element) }
|
||||||
def rangeMap = {
|
def rangeMap = {
|
||||||
finalized = true
|
finalized = true
|
||||||
l map {
|
(l map {
|
||||||
var sum = 0
|
var sum = 0
|
||||||
x => { sum += x._2; (x._1 -> (sum-x._2, sum)) }
|
x => { sum += x._2; (x._1 -> (sum-x._2, sum)) }
|
||||||
}
|
}).toMap
|
||||||
}
|
}
|
||||||
def range(name: String) = rangeMap(name)
|
def range(name: String) = rangeMap(name)
|
||||||
def print = {
|
def print = {
|
||||||
rangeMap map { case (name, (start, end)) =>
|
rangeMap.toSeq.sortBy(_._2).foreach { case (name, (start, end)) =>
|
||||||
println(s"${name} on port ${start}-${end-1}")
|
println(s"${name} on int ${start}-${end-1}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
def sum = {
|
def sum = {
|
||||||
|
Loading…
Reference in New Issue
Block a user