1
0

Merge pull request #896 from freechipsproject/fuzzer-rage

Fuzzer rage
This commit is contained in:
Wesley W. Terpstra 2017-07-26 16:01:07 -07:00 committed by GitHub
commit 3cceb866cf
4 changed files with 19 additions and 21 deletions

View File

@ -190,6 +190,7 @@ class TLAtomicAutomata(logical: Boolean = true, arithmetic: Boolean = true, conc
} }
// We need to deal with a potential D response in the same cycle as the A request // We need to deal with a potential D response in the same cycle as the A request
val d_first = edgeOut.first(out.d)
val d_cam_sel_raw = cam_a.map(_.bits.source === in.d.bits.source) val d_cam_sel_raw = cam_a.map(_.bits.source === in.d.bits.source)
val d_cam_sel_match = (d_cam_sel_raw zip cam_dmatch) map { case (a,b) => a&&b } val d_cam_sel_match = (d_cam_sel_raw zip cam_dmatch) map { case (a,b) => a&&b }
val d_cam_data = Mux1H(d_cam_sel_match, cam_d.map(_.data)) val d_cam_data = Mux1H(d_cam_sel_match, cam_d.map(_.data))
@ -200,7 +201,7 @@ class TLAtomicAutomata(logical: Boolean = true, arithmetic: Boolean = true, conc
val d_ackd = out.d.bits.opcode === TLMessages.AccessAckData val d_ackd = out.d.bits.opcode === TLMessages.AccessAckData
val d_ack = out.d.bits.opcode === TLMessages.AccessAck val d_ack = out.d.bits.opcode === TLMessages.AccessAck
when (out.d.fire()) { when (out.d.fire() && d_first) {
(d_cam_sel zip cam_d) foreach { case (en, r) => (d_cam_sel zip cam_d) foreach { case (en, r) =>
when (en && d_ackd) { when (en && d_ackd) {
r.data := out.d.bits.data r.data := out.d.bits.data
@ -214,8 +215,8 @@ class TLAtomicAutomata(logical: Boolean = true, arithmetic: Boolean = true, conc
} }
} }
val d_drop = d_ackd && d_cam_sel_any val d_drop = d_first && d_ackd && d_cam_sel_any
val d_replace = d_ack && d_cam_sel_match.reduce(_ || _) val d_replace = d_first && d_ack && d_cam_sel_match.reduce(_ || _)
in.d.valid := out.d.valid && !d_drop in.d.valid := out.d.valid && !d_drop
out.d.ready := in.d.ready || d_drop out.d.ready := in.d.ready || d_drop

View File

@ -14,12 +14,11 @@ class IDMapGenerator(numIds: Int) extends Module {
val alloc = Decoupled(UInt(width = w)) val alloc = Decoupled(UInt(width = w))
} }
io.free.ready := Bool(true)
// True indicates that the id is available // True indicates that the id is available
val bitmap = RegInit(UInt((BigInt(1) << numIds) - 1, width = numIds)) val bitmap = RegInit(UInt((BigInt(1) << numIds) - 1, width = numIds))
io.free.ready := Bool(true)
assert (!io.free.valid || !bitmap(io.free.bits)) // No double freeing
val select = ~(leftOR(bitmap) << 1) & bitmap val select = ~(leftOR(bitmap) << 1) & bitmap
io.alloc.bits := OHToUInt(select) io.alloc.bits := OHToUInt(select)
io.alloc.valid := bitmap.orR() io.alloc.valid := bitmap.orR()
@ -31,6 +30,7 @@ class IDMapGenerator(numIds: Int) extends Module {
when (io.free.fire()) { set := UIntToOH(io.free.bits) } when (io.free.fire()) { set := UIntToOH(io.free.bits) }
bitmap := (bitmap & ~clr) | set bitmap := (bitmap & ~clr) | set
assert (!io.free.valid || !(bitmap & ~clr)(io.free.bits)) // No double freeing
} }
object LFSR64 object LFSR64
@ -125,12 +125,7 @@ class TLFuzzer(
// Source ID generation // Source ID generation
val idMap = Module(new IDMapGenerator(inFlight)) val idMap = Module(new IDMapGenerator(inFlight))
val alloc = Queue.irrevocable(idMap.io.alloc, 1, pipe = true) val src = idMap.io.alloc.bits holdUnless a_first
val src = alloc.bits
alloc.ready := req_done
idMap.io.free.valid := resp_done
idMap.io.free.bits := out.d.bits.source
// Increment random number generation for the following subfields // Increment random number generation for the following subfields
val inc = Wire(Bool()) val inc = Wire(Bool())
val inc_beat = Wire(Bool()) val inc_beat = Wire(Bool())
@ -183,12 +178,13 @@ class TLFuzzer(
UInt("b100") -> lbits, UInt("b100") -> lbits,
UInt("b101") -> hbits)) UInt("b101") -> hbits))
// Wire both the used and un-used channel signals // Wire up Fuzzer flow control
if (nOperations>0) { val a_gen = if (nOperations>0) num_reqs =/= UInt(0) else Bool(true)
out.a.valid := legal && alloc.valid && num_reqs =/= UInt(0) out.a.valid := a_gen && legal && (!a_first || idMap.io.alloc.valid)
} else { idMap.io.alloc.ready := a_gen && legal && a_first && out.a.ready
out.a.valid := legal && alloc.valid idMap.io.free.valid := d_first && out.d.fire()
} idMap.io.free.bits := out.d.bits.source
out.a.bits := bits out.a.bits := bits
out.b.ready := Bool(true) out.b.ready := Bool(true)
out.c.valid := Bool(false) out.c.valid := Bool(false)

View File

@ -95,7 +95,7 @@ class TLRAMModel(log: String = "")(implicit p: Parameters) extends LazyModule
when (in.a.fire()) { flight(in.a.bits.source) := a_flight } when (in.a.fire()) { flight(in.a.bits.source) := a_flight }
val bypass = if (edge.manager.minLatency > 0) Bool(false) else in.a.valid && in.a.bits.source === out.d.bits.source val bypass = if (edge.manager.minLatency > 0) Bool(false) else in.a.valid && in.a.bits.source === out.d.bits.source
val d_flight = RegNext(Mux(bypass, a_flight, flight(out.d.bits.source))) val d_flight = RegEnable(Mux(bypass, a_flight, flight(out.d.bits.source)), edge.first(out.d))
// Process A access requests // Process A access requests
val a = Reg(next = in.a.bits) val a = Reg(next = in.a.bits)

View File

@ -60,8 +60,9 @@ class TLSourceShrinker(maxInFlight: Int)(implicit p: Parameters) extends LazyMod
out.a.bits := in.a.bits out.a.bits := in.a.bits
out.a.bits.source := nextFree holdUnless a_first out.a.bits.source := nextFree holdUnless a_first
val bypass = Bool(edgeOut.manager.minLatency == 0) && in.a.fire() && a_first && nextFree === out.d.bits.source
in.d <> out.d in.d <> out.d
in.d.bits.source := sourceIdMap(out.d.bits.source) in.d.bits.source := Mux(bypass, in.a.bits.source, sourceIdMap(out.d.bits.source))
when (a_first && in.a.fire()) { when (a_first && in.a.fire()) {
sourceIdMap(nextFree) := in.a.bits.source sourceIdMap(nextFree) := in.a.bits.source