@@ -29,16 +29,15 @@ async def load_matrix(dut, matrix, sel):
2929 dut .uio_in .value = 0
3030 await RisingEdge (dut .clk )
3131
32- async def read_signed_output (dut , transpose = False , relu = False ):
32+ async def read_signed_output (dut , transpose = 0 , relu = 0 ):
3333 # Apply instruction signal just before reading
34- dut .uio_in .value = 0b00000001 | (transpose << 1 ) | (relu << 2 )
35- await ClockCycles (dut .clk , 1 )
36- dut .uio_in .value = 0
37- await ClockCycles (dut .clk , 2 ) # allow systolic array to compute
34+ for i in range (3 ):
35+ dut .uio_in .value = (transpose << 1 ) | (relu << 2 )
36+ await ClockCycles (dut .clk , 1 )
3837
3938 results = []
4039 for i in range (4 ):
41- dut .uio_in .value = 0 # Read mode
40+ dut .uio_in .value = ( transpose << 1 ) | ( relu << 2 )
4241 await ClockCycles (dut .clk , 1 )
4342 val_unsigned = dut .uo_out .value .integer
4443 val_signed = val_unsigned if val_unsigned < 128 else val_unsigned - 256
@@ -61,14 +60,14 @@ async def test_relu_transpose(dut):
6160 dut .rst_n .value = 1
6261 await ClockCycles (dut .clk , 5 )
6362
64- A = [1 , - 2 , 3 , - 4 ] # row-major
65- B = [5 , 6 , - 7 , 8 ] # row-major
63+ A = [5 , - 6 , 7 , 8 ] # row-major
64+ B = [8 , 9 , 6 , 8 ] # row-major: [B00, B01, B10, B11]
6665
6766 await load_matrix (dut , A , sel = 0 )
6867 await load_matrix (dut , B , sel = 1 )
6968
70- expected = get_expected_matmul (A , B , transpose = True , relu = True )
71- results = await read_signed_output (dut )
69+ expected = get_expected_matmul (A , B , transpose = False , relu = True )
70+ results = await read_signed_output (dut , relu = 1 )
7271
7372 for i in range (4 ):
7473 assert results [i ] == expected [i ], f"C[{ i // 2 } ][{ i % 2 } ] = { results [i ]} != expected { expected [i ]} "
0 commit comments