@@ -33,7 +33,7 @@ async def initialize(dut, timeout=50):
33
33
cocotb .log .setLevel (logging .DEBUG )
34
34
35
35
# Start the background timeout task
36
- await cocotb .start (timeout_task (timeout ))
36
+ cocotb .start_soon (timeout_task (timeout ))
37
37
38
38
# Initialize inputs
39
39
dut .araddr .value = 0
@@ -86,10 +86,16 @@ async def writer():
86
86
await tb .write_csr (fifo_addr , int2bytes (d ))
87
87
88
88
async def reader (return_data ):
89
+ # Wait until there is data in FIFO
90
+ read_offset = 2
91
+ while int (dut .fifo_depth_o .value ) < read_offset :
92
+ await RisingEdge (tb .clk )
93
+
89
94
# Read sequence should read data on each write data
90
- for _ in test_data :
95
+ for i in range ( data_len ) :
91
96
# Awaiting `awvalid` causes reading simultaneously with write data channel activity
92
- await RisingEdge (dut .awvalid )
97
+ if i < (data_len - read_offset ):
98
+ await RisingEdge (dut .awvalid )
93
99
return_data .append (dword2int (await tb .read_csr (fifo_addr )))
94
100
95
101
received_data = []
@@ -103,7 +109,7 @@ async def reader(return_data):
103
109
tb .log .info ("Test finished!" )
104
110
105
111
106
- @cocotb .test (skip = True )
112
+ @cocotb .test ()
107
113
async def test_collision_with_read (dut ):
108
114
tb , data_len , test_data = await initialize (dut )
109
115
@@ -114,22 +120,22 @@ async def test_collision_with_read(dut):
114
120
async def writer ():
115
121
# Write sequence should write data on each read data
116
122
for i , d in enumerate (test_data ):
117
- # Awaiting `arvalid` causes writing simultaneously with read data channel activity
118
- if i >= 2 :
119
- await RisingEdge (dut .arvalid )
123
+ # Awaiting read request causes writing simultaneously with read data channel activity
124
+ if i > 2 :
125
+ await RisingEdge (dut .s_cpuif_req )
126
+ assert not dut .s_cpuif_req_is_wr .value
120
127
await tb .write_csr (fifo_addr , int2bytes (d ))
121
128
122
129
async def reader (return_data ):
123
130
# Wait until there is data in FIFO
124
- while dut .fifo_depth_o .value < 2 :
125
- continue
131
+ read_offset = 2
132
+ while int (dut .fifo_depth_o .value ) < read_offset :
133
+ await RisingEdge (tb .clk )
126
134
127
135
# Read sequence should just read data
128
- for i in range (data_len ):
129
- wvalid = RisingEdge (dut .wvalid )
130
- wready = RisingEdge (dut .wready )
131
- await Combine (wvalid , wready )
136
+ for _ in range (data_len ):
132
137
return_data .append (dword2int (await tb .read_csr (fifo_addr )))
138
+ await RisingEdge (tb .clk )
133
139
134
140
received_data = []
135
141
w = cocotb .start_soon (writer ())
0 commit comments