1
0

Make Int -> Bool conversions explicit

This commit is contained in:
Andrew Waterman
2014-03-24 04:36:53 -07:00
parent 1b030777ce
commit 6465e2df14
2 changed files with 10 additions and 7 deletions

View File

@ -3,15 +3,18 @@ package rocket
import Chisel._
import scala.math._
object Util
{
class BooleanToInt(x: Int) {
def toBoolean: Boolean = if (x != 0) true else false
}
object Util {
implicit def intToUInt(x: Int): UInt = UInt(x)
implicit def intToBoolean(x: Int): Boolean = if (x != 0) true else false
implicit def booleanToInt(x: Boolean): Int = if (x) 1 else 0
implicit def booleanToBool(x: Boolean): Bits = Bool(x)
implicit def intSeqToUIntSeq(x: Iterable[Int]): Iterable[UInt] = x.map(UInt(_))
implicit def wcToUInt(c: WideCounter): UInt = c.value
implicit def booleanToInt(x: Boolean): Int = if (x) 1 else 0
implicit def intToBooleanToInt(x: Int): BooleanToInt = new BooleanToInt(x)
}
object AVec