How to avoid "divergent poking / peeking threads" when use fork/join #1989
-
I implemented an arbiter with 4 request ports and 4 response ports. All these request and response ports are in decoupled style. When a client want to perform some critical action, it has to request on a specified request port and wait for an ack from response port. As this arbiter works like a mutex lock, I would like to test it in a multi-thread style, so I wrote the following codes: //.....
var threadHandle = fork{}
for (i <- 0 until Config.LAUNCH_WIDTH) {
threadHandle = threadHandle.fork {
val idx = i
for (j <- 0 until TESTNUM) {
dut.clock.step(1)
// launch a request
dut.io.port(idx).request.valid.poke(true.B)
while (!dut.io.port(idx).request.ready.peek().litToBoolean) {
// wait until request is accepted
dut.clock.step(1)
}
dut.io.port(idx).request.valid.poke(false.B)
// wait for response
dut.io.port(idx).response.ready.poke(false.B)
while (!dut.io.port(idx).response.valid.peek().litToBoolean) {
dut.clock.step(1)
}
dut.clock.step(1)
dut.io.port(idx).response.ready.poke(false.B)
}
}
}
threadHandle.join()
} And then, unfortunately, I got a:
So, what's wrong here? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Could you please provide a piece of reproducible code? |
Beta Was this translation helpful? Give feedback.
-
Possible cause (without looking at the details of your example or test case): ChiselTest doesn't allow combinational peek-after-poke operations between threads. This applies for peek-after-poke on the same signal, and signals that are combinationally dependent. From the error message, it appears one thread is poking |
Beta Was this translation helpful? Give feedback.
Possible cause (without looking at the details of your example or test case): ChiselTest doesn't allow combinational peek-after-poke operations between threads. This applies for peek-after-poke on the same signal, and signals that are combinationally dependent. From the error message, it appears one thread is poking
io_port_0_request_valid
and another is peekingio_port_3_request_ready
, and there may be a combinational path between the two.Here's the check that generates that error message.