Lot 02Shift / multiply · in designVol. 32

Lot 02 · Shift · In design

Barrel shifter and the multiply loop that stretched my brain.

Rotate, logical/arithmetic shift, and a priority-encoder-optimized multiply—built from roughly forty 74ACT157 2-to-1 muxes stitched into a 32-bit barrel.

A naive add-and-shift multiply would burn ~32 cycles for 16×16. Tomato’s loop uses a priority encoder to skip entire chunks of zero bits in the multiplier operand. Worst case drops to 16 cycles; best case zero; amortized average about 4 cycles per operation. The ALU was the deep combinational problem—this lot is sequencing plus a very wide mux tree made tolerable in 74ACT.

Role in the machine

The shift board feeds the datapath beside 07_alu: barrel operations for shifts/rotates, and the multiply FSM that reuses the adder through controlled shifts. Control lives on shift-mul-control.kicad_sch with the barrel on the main shift sheet. Local EEPROM decode (same 10-bit opcode philosophy as every other slice) keeps propagation predictable at bench clocks.

Status
In design · schematic started
Key ICs
~40× 74ACT157 · priority encoder glue
Multiply
16 max · ~4 avg cycles
Project
hardware/kicad/boards/02_shift_encoder/

Related journal: Multiply engine · Mul/div dispatch.