Architecture
- Top level (dws_accelerator) runs three layer types: depthwise only, pointwise only, or the full depthwise-separable block (DW then PW), chosen per layer by conv_type.
- Two convolution units, one per stage, each built on an 8×8 PE array. The depthwise output is written to an on-chip intermediate buffer and read directly by the pointwise unit, so the intermediate feature map never goes back to external memory.
- Control FSM: IDLE → SETUP_DW → PROCESS_DW → BUFFER_DW_OUTPUT → SETUP_PW → PROCESS_PW → DONE. It latches the layer configuration and derives the PW input size from the DW output size.
- PE: registered 8-bit × 8-bit multiply into a 32-bit partial sum. Activations are forwarded down each column; weights are held per PE.
- Per-row adder trees reduce eight PE products to one partial sum per cycle. The tree is a parameterized ternary reduction, so any array width works (odd and even widths were both fixed and tested).
- Configurable for 1×1, 3×3, 5×5 and 7×7 kernels, inputs up to 224×224 and up to 512 channels; 8-bit activations and weights.
- Post-processing: ReLU and quantization back to 8 bits in a reducer stage, plus pooling and normalization blocks. Input, weight, partial-sum and FIFO buffer modules are in memory_units/.
- A systolic (psum-forwarding) PE-array variant was explored alongside the weight-broadcast array.
Verification Architecture
- Directed SystemVerilog testbenches for the PE, the PE array performing convolution, and the adder tree.
- NumPy reference convolution (tests/conv.ipynb) produces the golden outputs for the PE-array convolution test.
- Benches print results each cycle for comparison against the NumPy golden. The comparison is not yet automated.
Verification Strategy
- Bottom-up: PE first (product, enable/hold behaviour), then the PE array on a 4×4 input with a 3×3 kernel, then adder trees at odd and even widths.
- PlannedSelf-checking benches that compare automatically against the NumPy golden.
- PlannedFull DW, PW and DSC layer tests with random tensors.
- PlannedAssertions on FSM handshakes and the intermediate-buffer read/write pointers.
Results
- ~20× speedup through dataflow parallelism (measured outside this repo).
- PE-array convolution: a 4×4 input with a 3×3 kernel produces 348, 393, 528 and 573, matching the NumPy golden output exactly (re-run in Questa 21.1).
- PE test: products and enable-hold behaviour correct over all cycles.
- Bugs found and fixed during bring-up: adder-tree reduction for odd widths, PE-array output delays, and a redundant psum_in path removed from the PE.
Evidence
always_ff @(posedge clk) begin
if (rst) begin
psum_out <= '0;
iact_out <= '0;
end else if(en) begin
iact_out <= iact;
psum_out <= iact * weight;
end
endfor (n = 0; n < triplets; n++) begin : gen_triplets
assign tree[l+1][n] = tree[l][n*3] + tree[l][n*3+1] + tree[l][n*3+2];
end
if (remainder == 1) begin : gen_remainder1
assign tree[l+1][triplets] = tree[l][triplets*3];
end else if (remainder == 2) begin : gen_remainder2
assign tree[l+1][triplets] = tree[l][triplets*3] + tree[l][triplets*3+1];
endNumPy: [[348. 393.]
[528. 573.]]
RTL: # -- Cycle 4 -- PSUM: 528
# -- Cycle 5 -- PSUM: 348
# -- Cycle 8 -- PSUM: 573
# PSUM: 393