
This is a tiny matrix-multiply accelerator: a 2x2 output-stationary systolic array of signed 4-bit (int4) multiply-accumulate units.
Each processing element (PE) holds one result C[i][j] in a 12-bit accumulator. Every clock it adds a * b and then passes a to its right neighbour and b to the neighbour below. The rows of A enter from the left and the columns of B from the top. Each row or column starts one cycle later than the one before it, so A[i][k] and B[k][j] reach PE(i,j) in the same cycle.
B col 0 B col 1
| |
A row 0 -> [PE00] -> [PE01]
| |
A row 1 -> [PE10] -> [PE11]
The chip uses a load, then compute protocol:
COMPUTE can either clear the accumulators first or keep adding to them (accumulate mode). Accumulate mode lets you compute (2xK) x (Kx2) for any even K by loading K in chunks of 2. Results wrap like two's complement past +2047 or -2048. With all inputs at -8 that happens beyond K = 31, and in practice much later.
Blocks: controller (command decoder and FSM, with a 2-FF synchroniser on op), feeder (A/B buffers and input skew), systolic_array (4 x pe) and readout (result byte mux).
All signals are driven from the RP2040 (or any microcontroller). Commands are edge-triggered: set addr and ui_in first, then set op, hold it for at least 4 clocks, and return op to 00 before the next command. Holding a command longer never repeats it.
op uio[6:5] |
Command | addr uio[4:0] |
Data |
|---|---|---|---|
00 |
NOP | - | - |
01 |
WRITE row | bit 1: 0 = A, 1 = B. bit 0: row | ui_in = {elem1, elem0}, two signed int4 values with element 0 in bits [3:0] |
10 |
COMPUTE | bit 0: 1 = clear first, 0 = accumulate | - |
11 |
READ-SELECT | bits [2:1]: result i*2+j. bit 0: 0 = low byte, 1 = high byte |
result byte appears on uo_out |
uio[7] (DONE) goes low when a COMPUTE starts and high when it finishes, within about 10 clocks of op changing.
Reading a result: the high byte is the result sign-extended to 16 bits, so value = int8(hi) * 256 + lo.
Example: A = [[1, 2], [3, 4]], B = [[5, 6], [7, 7]]
addr=0b00, ui_in=0x21. WRITE A row 1: addr=0b01, ui_in=0x43.addr=0b10, ui_in=0x65. WRITE B row 1: addr=0b11, ui_in=0x77.addr=1) and wait for DONE.uo_out each time. Expect C = [[19, 20], [43, 46]]: the bytes are 19, 0, 20, 0, 43, 0, 46, 0.To multiply with a larger K, load the next 2 columns of A and 2 rows of B, then COMPUTE with addr=0 (accumulate) instead of clear.
None. Everything is driven from the demo board's RP2040.
| # | Input | Output | Bidirectional |
|---|---|---|---|
| 0 | DIN0 | DOUT0 | ADDR0 / CLEAR |
| 1 | DIN1 | DOUT1 | ADDR1 |
| 2 | DIN2 | DOUT2 | ADDR2 |
| 3 | DIN3 | DOUT3 | ADDR3 |
| 4 | DIN4 | DOUT4 | ADDR4 |
| 5 | DIN5 | DOUT5 | OP0 |
| 6 | DIN6 | DOUT6 | OP1 |
| 7 | DIN7 | DOUT7 | DONE |