clean up Str
This commit is contained in:
parent
95c5147dc5
commit
7cc53c7725
@ -56,7 +56,7 @@ object Str
|
|||||||
def apply(x: Fix): Bits = apply(x, 10)
|
def apply(x: Fix): Bits = apply(x, 10)
|
||||||
def apply(x: Fix, radix: Int): Bits = {
|
def apply(x: Fix, radix: Int): Bits = {
|
||||||
val neg = x < Fix(0)
|
val neg = x < Fix(0)
|
||||||
val abs = Mux(neg, -x, x).toUFix
|
val abs = x.abs
|
||||||
if (radix != 10) {
|
if (radix != 10) {
|
||||||
Cat(Mux(neg, Str('-'), Str(' ')), Str(abs, radix))
|
Cat(Mux(neg, Str('-'), Str(' ')), Str(abs, radix))
|
||||||
} else {
|
} else {
|
||||||
@ -79,16 +79,6 @@ object Str
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def bigIntToString(x: BigInt): String = {
|
|
||||||
val s = new StringBuilder
|
|
||||||
var b = x
|
|
||||||
while (b != 0) {
|
|
||||||
s += (x & 0xFF).toChar
|
|
||||||
b = b >> 8
|
|
||||||
}
|
|
||||||
s.toString
|
|
||||||
}
|
|
||||||
|
|
||||||
private def digit(d: Int): Char = (if (d < 10) '0'+d else 'a'-10+d).toChar
|
private def digit(d: Int): Char = (if (d < 10) '0'+d else 'a'-10+d).toChar
|
||||||
private def digits(radix: Int): Vec[Bits] =
|
private def digits(radix: Int): Vec[Bits] =
|
||||||
AVec((0 until radix).map(i => Str(digit(i))))
|
AVec((0 until radix).map(i => Str(digit(i))))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user