Hi Chris,
Thanks, I hadn't realized update blocks can be used in testbench code.
This solution would be straightforward if an input or output lasted 1 cycle. Then I could just do
@s.update
# Send input
@s.update
# Read output
However, sending an input lasts ~100s cycles and involves iterating through an array. I suppose the @s.update could still work if I have variables to keep track of where I am in the array, i.e.,
input_x = 0
input_y = 0
dut.input_data.value = test_vector[0,0]
@s.update
def input_update():
dut.input_valid.value = 1
input_x += 1
if input_x >= x_lim:
input_x = 0
input_y +=1
if input_y >= y_lim:
dut.input_valid.value = 0
And then I'd need to do similarly for the output.
This is a bit more verbose than being able to have nested for-loops, but it'll work. I was hoping for a construct where I don't need to explicitly check the loop indices:
initial begin
dut.input_valid.value = 1
for i in range(x_lim):
for j in range(y_lim):
dut.input_data.value = test_vector[i,j]
sim.cycle()
dut.input_valid.value = 1
end
And then I can do the same initial-begin-end for the output.