You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, I've encountered an issue while working on my project. I've instantiated an AxiRam in Cocotb to serve as the model RAM for the DUT (Device Under Test), enabling me to initialize its values from the Cocotb test bench. Initially, everything works well, especially with smaller-scale test cases. However, when attempting to test with a larger input scale, I encountered a problem.
To handle the larger input scale, I introduced a while loop in the test bench to wait for responses. Unfortunately, this seems to cause the write and read operations of the AxiRam to hang.
Due to the complexity of the DUT, I'm unable to provide the entire code. However, I can confirm that I haven't altered any inputs to the DUT itself. The only change made was the inclusion of a while loop to maintain the test bench's execution. I've observed the write and read operations hanging from the output console.
For reference, here's an example of the test bench, where the DUT completes a read operation from the AxiRam and do calculation on top and write data back in the end:
dut.weight_prefetcher_req_valid.value = 1 # enable the prefetcher
dut.weight_prefetcher_req.req_opcode.value = 0 # 00 is for weight bank requests
dut.weight_prefetcher_req.start_address.value = byte_per_weight_block * (i % weight_matrix_iteration) # start address of the weight bank
dut.weight_prefetcher_req.in_features.value = weight_matrix_size[1] # number of input features
dut.weight_prefetcher_req.out_features.value = weight_matrix_size[0] # number of output features
dut.weight_prefetcher_req.nodeslot.value = 0 # not used for weight bank requests
dut.weight_prefetcher_req.nodeslot_precision.value = 1 # 01 is for fixed 8-bit precision
dut.weight_prefetcher_req.neighbour_count.value = 0 # not used for weight bank requests
# --------------------------------------------------
dut.feature_prefetcher_req_valid.value = 1 # enable the prefetcher
dut.feature_prefetcher_req.req_opcode.value = 0 # 00 is for weight bank requests
dut.feature_prefetcher_req.start_address.value = weigth_address_range + byte_per_input_block * (i // weight_matrix_iteration) # start address of the feature bank
dut.feature_prefetcher_req.in_features.value = input_matrix_size[1] # number of input features
dut.feature_prefetcher_req.out_features.value = input_matrix_size[0] # number of output features
dut.feature_prefetcher_req.nodeslot.value = 0 # not used for weight bank requests
dut.feature_prefetcher_req.nodeslot_precision.value = 1 # 01 is for fixed 8-bit precision
dut.feature_prefetcher_req.neighbour_count.value = 0 # not used for weight bank requests
# --------------------------------------------------
dut.nsb_fte_req_valid.value = 1 # enable the fte
dut.nsb_fte_req.precision.value = 1 # 01 is for fixed 8-bit precision
dut.layer_config_out_channel_count.value = input_matrix_size[0] # here we used the first dimension of the input matrix as output channel count
dut.layer_config_out_features_count.value = weight_matrix_size[0] # here we used the first dimension of the weight matrix as output features count
dut.layer_config_out_features_address_msb_value.value = (writeback_address >> 32) & 0b11 # 2 is for the msb of 34 bits address
dut.layer_config_out_features_address_lsb_value.value = writeback_address & 0xFFFFFFFF # 0 for the rest of the address
dut.writeback_offset.value = offset # 0 for the writeback offset
#---------------------------------------------------
print("Done instructing fte")
i = 0
while True:
await RisingEdge(dut.clk)
await Timer(10, units="ns")
if dut.nsb_fte_resp_valid.value == 1:
done = True
break
if i==1000000:
done = False
break
i+=1
reset_fte(dut)
This test bench passed successfully, and all the reading and writing logs from the console appear to be correct. However, upon introducing a while loop as shown below:
dut.weight_prefetcher_req_valid.value = 1 # enable the prefetcher
dut.weight_prefetcher_req.req_opcode.value = 0 # 00 is for weight bank requests
dut.weight_prefetcher_req.start_address.value = byte_per_weight_block * (i % weight_matrix_iteration) # start address of the weight bank
dut.weight_prefetcher_req.in_features.value = weight_matrix_size[1] # number of input features
dut.weight_prefetcher_req.out_features.value = weight_matrix_size[0] # number of output features
dut.weight_prefetcher_req.nodeslot.value = 0 # not used for weight bank requests
dut.weight_prefetcher_req.nodeslot_precision.value = 1 # 01 is for fixed 8-bit precision
dut.weight_prefetcher_req.neighbour_count.value = 0 # not used for weight bank requests
# --------------------------------------------------
dut.feature_prefetcher_req_valid.value = 1 # enable the prefetcher
dut.feature_prefetcher_req.req_opcode.value = 0 # 00 is for weight bank requests
dut.feature_prefetcher_req.start_address.value = weigth_address_range + byte_per_input_block * (i // weight_matrix_iteration) # start address of the feature bank
dut.feature_prefetcher_req.in_features.value = input_matrix_size[1] # number of input features
dut.feature_prefetcher_req.out_features.value = input_matrix_size[0] # number of output features
dut.feature_prefetcher_req.nodeslot.value = 0 # not used for weight bank requests
dut.feature_prefetcher_req.nodeslot_precision.value = 1 # 01 is for fixed 8-bit precision
dut.feature_prefetcher_req.neighbour_count.value = 0 # not used for weight bank requests
# --------------------------------------------------
await Timer(10, units="ns")
p = 0
fetched_weight, fetched_input = False, False
while True:
await RisingEdge(dut.clk)
await Timer(10, units="ns")
if dut.weight_prefetcher_resp_valid.value == 1:
fetched_weight = True
if dut.feature_prefetcher_resp_valid.value == 1:
fetched_input = True
if fetched_weight and fetched_input:
break
elif p==1000000:
raise ValueError("Deadlock detected: weight_prefetcher_req_ready and feature_prefetcher_req_ready are not ready")
p+=1
reset_nsb_prefetcher(dut)
# --------------------------------------------------
dut.nsb_fte_req_valid.value = 1 # enable the fte
dut.nsb_fte_req.precision.value = 1 # 01 is for fixed 8-bit precision
dut.layer_config_out_channel_count.value = input_matrix_size[0] # here we used the first dimension of the input matrix as output channel count
dut.layer_config_out_features_count.value = weight_matrix_size[0] # here we used the first dimension of the weight matrix as output features count
dut.layer_config_out_features_address_msb_value.value = (writeback_address >> 32) & 0b11 # 2 is for the msb of 34 bits address
dut.layer_config_out_features_address_lsb_value.value = writeback_address & 0xFFFFFFFF # 0 for the rest of the address
dut.writeback_offset.value = offset # 0 for the writeback offset
#---------------------------------------------------
print("Done instructing fte")
i = 0
while True:
await RisingEdge(dut.clk)
await Timer(10, units="ns")
if dut.nsb_fte_resp_valid.value == 1:
done = True
break
if i==1000000:
done = False
break
i+=1
reset_fte(dut)
It appears that introducing the while loop has caused the read operation to hang, as depicted in the provided image.
Comparing it with the completed read and write operations, which occurred without the while loop, everything seems to function correctly, as shown in the second image.
For reference, this is how I connected AxiRam to my hardware:
May I ask if there is anyway to work around this? Thank you very very much for your help.
The text was updated successfully, but these errors were encountered:
JeffreyWong20
changed the title
Writing to / Reading from the AxiRam component from the hardware DUT hands if while loops is added in the test bench
Writing to / Reading from the AxiRam component from the hardware DUT hang if while loops is added in the test bench
Apr 8, 2024
JeffreyWong20
changed the title
Writing to / Reading from the AxiRam component from the hardware DUT hang if while loops is added in the test bench
Writing to / Reading of AxiRam from the hardware DUT hang when adding when loops to the test bench
Apr 8, 2024
Cocotb version: 0.1.24
Hardware simulator: QuestaSim
Hello, I've encountered an issue while working on my project. I've instantiated an AxiRam in Cocotb to serve as the model RAM for the DUT (Device Under Test), enabling me to initialize its values from the Cocotb test bench. Initially, everything works well, especially with smaller-scale test cases. However, when attempting to test with a larger input scale, I encountered a problem.
To handle the larger input scale, I introduced a while loop in the test bench to wait for responses. Unfortunately, this seems to cause the write and read operations of the AxiRam to hang.
Due to the complexity of the DUT, I'm unable to provide the entire code. However, I can confirm that I haven't altered any inputs to the DUT itself. The only change made was the inclusion of a while loop to maintain the test bench's execution. I've observed the write and read operations hanging from the output console.
For reference, here's an example of the test bench, where the DUT completes a read operation from the AxiRam and do calculation on top and write data back in the end:
This test bench passed successfully, and all the reading and writing logs from the console appear to be correct. However, upon introducing a while loop as shown below:
It appears that introducing the while loop has caused the read operation to hang, as depicted in the provided image.
Comparing it with the completed read and write operations, which occurred without the while loop, everything seems to function correctly, as shown in the second image.
For reference, this is how I connected AxiRam to my hardware:
May I ask if there is anyway to work around this? Thank you very very much for your help.
The text was updated successfully, but these errors were encountered: