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

@ -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
}
}