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:
		@@ -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
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user