1
0

Standardize Data.holdUnless and SeqMem.readAndHold

- Make API more idiomatic (x holdUnless y, instead of holdUnless(x, y))
- Add new SeqMem API, readAndHold, which corresponds to most common
  use of holdUnless
This commit is contained in:
Andrew Waterman
2017-02-25 02:54:42 -08:00
parent fd972f5c67
commit dfa61bc487
9 changed files with 25 additions and 22 deletions

View File

@ -23,6 +23,14 @@ package object util {
def asUInt(): UInt = Cat(x.map(_.asUInt).reverse)
}
implicit class DataToAugmentedData[T <: Data](val x: T) extends AnyVal {
def holdUnless(enable: Bool): T = Mux(enable, x, RegEnable(x, enable))
}
implicit class SeqMemToAugmentedSeqMem[T <: Data](val x: SeqMem[T]) extends AnyVal {
def readAndHold(addr: UInt, enable: Bool): T = x.read(addr, enable) holdUnless RegNext(enable)
}
implicit def uintToBitPat(x: UInt): BitPat = BitPat(x)
implicit def wcToUInt(c: WideCounter): UInt = c.value