blob: a8e281034000cd80611aaea547c077c44fb28294 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
package Chisel
object Literal {
def sizeof(x: BigInt): Int = x.bitLength
def decodeBase(base: Char): Int = base match {
case 'x' | 'h' => 16
case 'd' => 10
case 'o' => 8
case 'b' => 2
case _ => ChiselError.error("Invalid base " + base); 2
}
def stringToVal(base: Char, x: String): BigInt =
BigInt(x, decodeBase(base))
}
|