2016-11-28 01:16:37 +01:00
|
|
|
// See LICENSE.SiFive for license details.
|
|
|
|
|
2016-10-04 00:17:36 +02:00
|
|
|
import Chisel._
|
|
|
|
import chisel3.internal.sourceinfo.{SourceInfo, SourceLine, UnlocatableSourceInfo}
|
|
|
|
|
|
|
|
package object diplomacy
|
|
|
|
{
|
|
|
|
def sourceLine(sourceInfo: SourceInfo, prefix: String = " (", suffix: String = ")") = sourceInfo match {
|
|
|
|
case SourceLine(filename, line, col) => s"$prefix$filename:$line:$col$suffix"
|
|
|
|
case _ => ""
|
|
|
|
}
|
2017-03-01 02:50:54 +01:00
|
|
|
|
|
|
|
def bitIndexes(x: BigInt, tail: Seq[Int] = Nil): Seq[Int] = {
|
|
|
|
require (x >= 0)
|
|
|
|
if (x == 0) {
|
|
|
|
tail.reverse
|
|
|
|
} else {
|
|
|
|
val lowest = x.lowestSetBit
|
|
|
|
bitIndexes(x.clearBit(lowest), lowest +: tail)
|
|
|
|
}
|
|
|
|
}
|
2016-10-04 00:17:36 +02:00
|
|
|
}
|