1
0

assign interrupt ranges deterministically

This commit is contained in:
Yunsup Lee 2016-09-28 20:32:53 -07:00 committed by Yunsup Lee
parent 4ac0ef2940
commit 4c3e8ec1b4

View File

@ -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 = {