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