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:
@ -5,6 +5,7 @@ package uncore.apb
|
||||
import Chisel._
|
||||
import config._
|
||||
import diplomacy._
|
||||
import util._
|
||||
|
||||
class APBRAM(address: AddressSet, executable: Boolean = true, beatBytes: Int = 4)(implicit p: Parameters) extends LazyModule
|
||||
{
|
||||
@ -34,7 +35,6 @@ class APBRAM(address: AddressSet, executable: Boolean = true, beatBytes: Int = 4
|
||||
|
||||
// Use single-ported memory with byte-write enable
|
||||
val mem = SeqMem(1 << mask.filter(b=>b).size, Vec(beatBytes, Bits(width = 8)))
|
||||
def holdUnless[T <: Data](in : T, enable: Bool): T = Mux(!enable, RegEnable(in, enable), in)
|
||||
|
||||
val read = in.psel && !in.penable && !in.pwrite
|
||||
when (in.psel && !in.penable && in.pwrite) {
|
||||
@ -43,6 +43,6 @@ class APBRAM(address: AddressSet, executable: Boolean = true, beatBytes: Int = 4
|
||||
|
||||
in.pready := Bool(true)
|
||||
in.pslverr := Bool(false)
|
||||
in.prdata := holdUnless(mem.read(paddr, read).asUInt, RegNext(read))
|
||||
in.prdata := mem.readAndHold(paddr, read).asUInt
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user