Miscellaneous cleanup
This commit is contained in:
@ -28,19 +28,19 @@ object AVec
|
||||
|
||||
object Str
|
||||
{
|
||||
def apply(s: String): Bits = {
|
||||
def apply(s: String): UInt = {
|
||||
var i = BigInt(0)
|
||||
require(s.forall(validChar _))
|
||||
for (c <- s)
|
||||
i = (i << 8) | c
|
||||
Lit(i, s.length*8){Bits()}
|
||||
UInt(i, s.length*8)
|
||||
}
|
||||
def apply(x: Char): Bits = {
|
||||
def apply(x: Char): UInt = {
|
||||
require(validChar(x))
|
||||
Lit(x, 8){Bits()}
|
||||
UInt(x.toInt, 8)
|
||||
}
|
||||
def apply(x: UInt): Bits = apply(x, 10)
|
||||
def apply(x: UInt, radix: Int): Bits = {
|
||||
def apply(x: UInt): UInt = apply(x, 10)
|
||||
def apply(x: UInt, radix: Int): UInt = {
|
||||
val rad = UInt(radix)
|
||||
val w = x.getWidth
|
||||
require(w > 0)
|
||||
@ -53,8 +53,8 @@ object Str
|
||||
}
|
||||
s
|
||||
}
|
||||
def apply(x: SInt): Bits = apply(x, 10)
|
||||
def apply(x: SInt, radix: Int): Bits = {
|
||||
def apply(x: SInt): UInt = apply(x, 10)
|
||||
def apply(x: SInt, radix: Int): UInt = {
|
||||
val neg = x < SInt(0)
|
||||
val abs = x.abs
|
||||
if (radix != 10) {
|
||||
@ -78,7 +78,7 @@ object Str
|
||||
}
|
||||
}
|
||||
|
||||
private def digit(d: UInt): Bits = Mux(d < UInt(10), Str('0')+d, Str(('a'-10).toChar)+d)(7,0)
|
||||
private def digit(d: UInt): UInt = Mux(d < UInt(10), Str('0')+d, Str(('a'-10).toChar)+d)(7,0)
|
||||
private def validChar(x: Char) = x == (x & 0xFF)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user