Skip to content

Commit a29cf61

Browse files
authored
Merge pull request #170 from JonasDann/bugfix/simulation-ctrl-reads
Fixed CSR reads in simulation
2 parents 9f2a9dd + 40b51eb commit a29cf61

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

sim/hw/ctrl_simulation.svh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,13 @@ class ctrl_simulation;
5353
logic [AXIL_DATA_BITS-1:0] read_data;
5454

5555
forever begin
56-
mbx.get(trs);
56+
// We need this as non-blocking with @(...), otherwise timing might be off if we do a
57+
// busy wait and we would need to wait an additional cycle every time
58+
int success = mbx.try_get(trs);
59+
while (!success) begin
60+
@(drv.axi.cbm);
61+
success = mbx.try_get(trs);
62+
end
5763

5864
if (trs.is_write) begin // Write a control register
5965
drv.write(trs.addr, trs.data);

sim/hw/tb_user.sv

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,9 @@ module tb_user;
378378

379379
#(RST_PERIOD) aresetn = 1'b1;
380380

381+
// Wait some more because otherwise reset pipelining might swallow up some data
382+
#(RST_PERIOD);
383+
381384
env_threads();
382385
env_done();
383386

sim/unit_test/fpga_test_case.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ def read_register(
391391
periodically and waiting for the output is canceled when the event is set. In this case,
392392
None will be returned!
393393
"""
394-
self._io_writer.ctrl_read(id, stop_event)
394+
return self._io_writer.ctrl_read(id, stop_event)
395395

396396
def set_stream_input(
397397
self,

0 commit comments

Comments
 (0)