From ec70e5fb02bbdabc1118057c93553412b20b0af4 Mon Sep 17 00:00:00 2001 From: "Wesley W. Terpstra" Date: Mon, 30 Oct 2017 14:00:53 -0700 Subject: [PATCH] apb: inject fuzzy errors --- src/main/scala/amba/apb/SRAM.scala | 8 +++++--- src/main/scala/amba/apb/Test.scala | 3 ++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/scala/amba/apb/SRAM.scala b/src/main/scala/amba/apb/SRAM.scala index 91e1f210..b9063195 100644 --- a/src/main/scala/amba/apb/SRAM.scala +++ b/src/main/scala/amba/apb/SRAM.scala @@ -12,7 +12,9 @@ class APBRAM( executable: Boolean = true, beatBytes: Int = 4, devName: Option[String] = None, - errors: Seq[AddressSet] = Nil) + errors: Seq[AddressSet] = Nil, + fuzzReady: Boolean = false, + fuzzError: Boolean = false) (implicit p: Parameters) extends DiplomaticSRAM(address, beatBytes, devName) { val node = APBSlaveNode(Seq(APBSlavePortParameters( @@ -37,8 +39,8 @@ class APBRAM( mem.write(paddr, Vec.tabulate(beatBytes) { i => in.pwdata(8*(i+1)-1, 8*i) }, in.pstrb.toBools) } - in.pready := Bool(true) - in.pslverr := RegNext(!legal) + in.pready := Bool(!fuzzReady) || LFSR16(!in.penable)(0) + in.pslverr := RegEnable(!legal, !in.penable) || (Bool(fuzzError) && LFSR16(Bool(true))(0)) in.prdata := mem.readAndHold(paddr, read).asUInt } } diff --git a/src/main/scala/amba/apb/Test.scala b/src/main/scala/amba/apb/Test.scala index 2d88c031..5c57191a 100644 --- a/src/main/scala/amba/apb/Test.scala +++ b/src/main/scala/amba/apb/Test.scala @@ -21,7 +21,7 @@ class APBFuzzBridge(aFlow: Boolean, txns: Int)(implicit p: Parameters) extends L val fuzz = LazyModule(new TLFuzzer(txns)) val model = LazyModule(new TLRAMModel("APBFuzzMaster")) val xbar = LazyModule(new APBFanout) - val ram = LazyModule(new APBRAM(AddressSet(0x0, 0xff))) + val ram = LazyModule(new APBRAM(AddressSet(0x0, 0xff), fuzzReady = true, fuzzError = true)) val gpio = LazyModule(new RRTest0(0x100)) ram.node := xbar.node @@ -31,6 +31,7 @@ class APBFuzzBridge(aFlow: Boolean, txns: Int)(implicit p: Parameters) extends L := TLDelayer(0.2) := TLBuffer(BufferParams.flow) := TLDelayer(0.2) + := TLFragmenter(4, 8) := model.node := fuzz.node)