From ca7555bd4d868c39cd2d92395c985e57dd3a197a Mon Sep 17 00:00:00 2001 From: "Wesley W. Terpstra" Date: Fri, 2 Dec 2016 17:48:17 -0800 Subject: [PATCH] RegMapFIFO: amoor.w can do thread-safe TX --- src/main/scala/util/RegMapFIFO.scala | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/scala/util/RegMapFIFO.scala b/src/main/scala/util/RegMapFIFO.scala index aaeba59..3e45482 100644 --- a/src/main/scala/util/RegMapFIFO.scala +++ b/src/main/scala/util/RegMapFIFO.scala @@ -8,18 +8,24 @@ import regmapper._ object NonBlockingEnqueue { def apply(enq: DecoupledIO[UInt], regWidth: Int = 32): Seq[RegField] = { val enqWidth = enq.bits.getWidth + val quash = Wire(Bool()) require(enqWidth > 0) require(regWidth > enqWidth) Seq( RegField(enqWidth, RegReadFn(UInt(0)), RegWriteFn((valid, data) => { - enq.valid := valid + enq.valid := valid && !quash enq.bits := data Bool(true) })), RegField(regWidth - enqWidth - 1), - RegField.r(1, !enq.ready)) + RegField(1, + !enq.ready, + RegWriteFn((valid, data) => { + quash := valid && data(0) + Bool(true) + }))) } }