Skip to main content

Module microcode

Module microcode 

Source
Expand description

Microcode for the barrel field machine: ISA, compiler, and interpreter.

A field machine executes one VLIW bundle per issue slot. A bundle has three independent slots:

  • M: one modular multiplication dst = a * b;
  • A: one modular addition/subtraction, or OUT, which emits a value;
  • T: one constant-address scan step of the fixed-base table.

The machine interleaves K independent contexts (barrel multithreading). Each context issues one bundle every K issue slots, and K is at least the longest unit latency. A bundle’s results are therefore always visible to the context’s next bundle, and no program needs latency scheduling. The compiler only packs operations into bundles, respecting dependencies.

Registers live in banks named after their single writer, so each bank has exactly one write port: M (multiplier results), A (add/sub results), I (job inputs, written by the loader), L (the selected Niels point, written by the T slot), and C (read-only constants).

Every operation is data independent: secret digits only choose between already-read table entries; they never form an address or skip a bundle.

The flow is: a program is written against Builder as straight-line code over virtual values (V); Builder::compile list-schedules the operations into bundles and then allocates physical registers in banks M and A by value lifetime; interpret runs the result with the exact read-before-write semantics of the hardware, which is how programs are tested; concat() merges several programs into one ROM.

Structs§

ASlot
Add/subtract slot.
Builder
Straight-line program builder over virtual values.
Bundle
One VLIW bundle.
Context
Per-context architectural state for interpret.
MSlot
Multiply slot.
Operand
A physical operand: a register in one bank of the issuing context.
Program
Compiled, register-allocated program.
TSlot
Table-scan slot.

Enums§

AOp
Add/subtract slot operation.
Bank
Register bank. Each bank has one writer, so it needs only one write port.
V
A virtual value used by the Builder.

Functions§

concat
Several programs in one ROM: concatenated bundles, a shared constant bank (deduplicated), and the entry bundle of each program.
interpret
Bit-exact reference execution of one context; returns (index, value) outputs.