Skip to content

wave-36b: t27c add gen-pipeline-stage2 + gen-layer-sequencer for BitNet SIMD compute + FSM (R-BN-2, Closes #762)#763

Merged
gHashTag merged 1 commit into
masterfrom
wave-36b/pipeline-sequencer
May 23, 2026
Merged

wave-36b: t27c add gen-pipeline-stage2 + gen-layer-sequencer for BitNet SIMD compute + FSM (R-BN-2, Closes #762)#763
gHashTag merged 1 commit into
masterfrom
wave-36b/pipeline-sequencer

Conversation

@gHashTag
Copy link
Copy Markdown
Owner

Closes #762

Wave 36b lands the second BitNet HLS pipeline module (R-BN-2): the SIMD compute stage with signed-16 accumulator (pipeline_stage2_compute) and the neuron/chunk-grid FSM (layer_sequencer) that drives it. Both emitters are exposed as fresh t27c subcommands so downstream FPGA flows can pin exact Verilog modules. The compute stage consumes the trit27_dot_product primitive emitted by gen-trit-stdlib (Wave 33) — wiring the BitNet stack together end-to-end.

What changed

  • bootstrap/src/bitnet_pipeline.rs (NEW, ~330 lines) — build_pipeline_stage2(module_name) + build_layer_sequencer(module_name) + Verilog-identifier validator + 21 inline unit tests.
  • bootstrap/src/main.rs — registers mod bitnet_pipeline;, adds Commands::GenPipelineStage2 + Commands::GenLayerSequencer, plus run_gen_pipeline_stage2() / run_gen_layer_sequencer() dispatched from both match arms. Boilerplate de-duplicated into a new write_verilog_to_output(verilog, output, label) helper.
  • bootstrap/tests/bitnet_pipeline.rs (NEW) — 20 integration tests covering module-name overrides, identifier rejection, port lists, FSM states, accumulator semantics, output writing, and trit27_dot_product wiring.
  • docs/NOW.md — Wave 36b section prepended.

CLI surface

t27c gen-pipeline-stage2 [--module-name <name>] [--output <path>]
t27c gen-layer-sequencer [--module-name <name>] [--output <path>]

Sample output

t27c gen-pipeline-stage2 --module-name pipeline_stage2_compute:

module pipeline_stage2_compute (
    input  wire        clk,
    input  wire        rst_n,
    input  wire        valid_in,
    input  wire [53:0] input_chunk,
    input  wire [53:0] weight_chunk,
    input  wire        first_chunk,
    input  wire        last_chunk,
    output reg         valid_out,
    output reg  signed [15:0] result,
    output reg         result_final
);
    wire signed [5:0] dot_result;
    trit27_dot_product simd (.input_vec(input_chunk), .weight_vec(weight_chunk), .result(dot_result));
    reg signed [15:0] accumulator;
    // ... accumulator + valid_out + result_final logic
endmodule

t27c gen-layer-sequencer --module-name layer_sequencer:

module layer_sequencer (
    input  wire        clk,
    input  wire        rst_n,
    input  wire        start,
    input  wire [15:0] num_neurons,
    input  wire [7:0]  num_chunks,
    output reg  [15:0] neuron_id,
    output reg  [7:0]  chunk_id,
    output reg         first_chunk,
    output reg         last_chunk,
    output reg         valid,
    output reg         done
);
    localparam IDLE=0, RUN=1, DONE_ST=2;
    // ... FSM walks (neuron_id, chunk_id) grid, strobes valid/first/last/done
endmodule

Constitutional gates

  • L1 TRACEABILITY: Closes #762 in title, body, and commit message.
  • L2 SCOPE: Touches only bootstrap/ and docs/NOW.md. No edits to gen/, coq/, trios-coq/, proofs/, specs/, conformance/, architecture/, rings/, or root Cargo.toml.
  • L3 ASCII: Source + doc-comments are ASCII English-only.
  • L4 TESTS: 20 new integration tests added; entire bootstrap suite green.
  • L5 KERNEL UNTOUCHED: Numeric kernel and trinity invariant phi^2 + 1/phi^2 = 3 unmodified.
  • L6 SPEC FROZEN: Zero spec/kernel changes — pure additive codegen.
  • *L7 NO NEW .sh: No shell scripts introduced.

Tests

  • W36b integration: 20/20 pass (cargo test -p t27c --release --test bitnet_pipeline).
  • Cross-wave regression: 56/56 pass (weight_bram 13, phi_selfcheck 11, behavior_sva 8, trit_stdlib 14, verilog_* 5×2 = 10).
  • Total: 76/76.

Source attribution

Ported from gHashTag/vibee-lang src/vibeec/verilog_codegen.zig:

  • writePipelineStage2 — lines ~1100-1145.
  • writeLayerSequencer — lines ~1147-1190.

Original author: Dmitrii Vasilev (@gHashTag).

Known orthogonal CI failures

The following jobs are inherited failures pre-dating Wave 31 and remain out of scope for this PR:

  • fpga-formal — formal engine harness.
  • fpga-synthesis-arty — Arty-board synthesis.
  • fpga-bitstream — bitstream build (always-pending → fail ~3 min).

Required gates (check, coverage, fpga-conformance, plus the unit/integration suite) are expected to be green.

Roadmap

  • W36c: double_buffer_ctrl (ping-pong activation buffers, vibee-lang ~lines 1192-1225) + AXI-Lite / DMA / IRQ scaffolding — closes the BitNet HLS pipeline (6/6 modules).
  • W37: richer behavior-DSL (multi-clause antecedents, temporal ##N / s_eventually) — extension of Wave 34.
  • W38+: wire stdlib + behavior emitter into existing gen_verilog_* spec emits — first wave that needs L2/L6 reconsideration.

After W36b merges: BitNet HLS pipeline 3/6 modules complete (weight_bram, pipeline_stage2_compute, layer_sequencer).

…et SIMD compute + FSM (R-BN-2)

- new module bootstrap/src/bitnet_pipeline.rs: two pure string emitters
  for the next two BitNet HLS pipeline primitives.
    * build_pipeline_stage2(module_name) emits the SIMD compute stage:
      consumes 54-bit input/weight chunks, instantiates trit27_dot_product
      (from trit_stdlib, W33), accumulates into a signed 16-bit
      accumulator gated by first_chunk, strobes valid_out and result_final
      on last_chunk, resets on negedge rst_n.
    * build_layer_sequencer(module_name) emits the three-state FSM
      (IDLE/RUN/DONE_ST) walking (neuron_id, chunk_id) across the
      neuron-chunk grid and driving valid / first_chunk / last_chunk /
      done strobes consumed by pipeline_stage2_compute.
  Includes the same Verilog-identifier validator pattern as W36a so
  invalid module names safely fall back to the canonical defaults.
  21 inline unit tests cover module headers, port lists, instantiation
  hookup, accumulator semantics, FSM transitions, reset behaviour, and
  ASCII-only invariant.
- main.rs: register mod bitnet_pipeline; add Commands::GenPipelineStage2
  and Commands::GenLayerSequencer; dispatch in both HTTP-server and CLI
  match arms via run_gen_pipeline_stage2 / run_gen_layer_sequencer.
  Extracted a shared write_verilog_to_output(verilog, output, label)
  helper from the existing per-subcommand boilerplate so future
  emitters reuse one well-tested I/O path.
- bootstrap/tests/bitnet_pipeline.rs: 20 integration tests shelling out
  to the two new subcommands, covering module header (default + custom +
  invalid-name fallback), trit27_dot_product instantiation hookup,
  54-bit chunk ports, signed-16 accumulator, negedge-rst_n reset,
  first_chunk gating, last_chunk strobes, FSM three-state declaration,
  port-list neuron/chunk counters, first/last-chunk strobes, IDLE arm
  on start, DONE_ST -> IDLE transition, reset path, ASCII-only stdout,
  and --output file writes for both subcommands.
- docs/NOW.md: prepend Wave 36b section.

Constitution: L1 traceability, L2 bootstrap-only (no edits under gen/,
coq/, trios-coq/, proofs/, specs/, conformance/, architecture/, rings/,
root Cargo.toml), L3 ASCII source + English doc-comments, L4 new tests
added and green (20 integration + 21 inline unit), L5 numeric kernel
untouched (emitters wire together existing primitives only), L6 zero
spec/kernel changes, L7 no new *.sh scripts.

Algorithms ported from gHashTag/vibee-lang src/vibeec/verilog_codegen.zig
lines ~1100-1145 (writePipelineStage2) and lines ~1147-1190
(writeLayerSequencer). Second slice of the W36 BitNet HLS pipeline port;
W36c will add double_buffer_ctrl + AXI-Lite / DMA / IRQ scaffolding.
BitNet HLS pipeline progress: 3/6 modules.

Closes #762
@github-actions
Copy link
Copy Markdown

PR Dashboard

Generated at: 2026-05-23 09:13:10 UTC

Summary

Status Count
Total Open PRs 22
PRs with Failing Checks 20
PRs with All Checks Green 2
READY 1
FAILING 20
PENDING 0

@github-actions
Copy link
Copy Markdown

📓 NotebookLM Notebook linked to this PR

This notebook contains session context, decisions, and artifacts for this work.

@gHashTag gHashTag merged commit fa5e69b into master May 23, 2026
27 of 31 checks passed
@gHashTag gHashTag deleted the wave-36b/pipeline-sequencer branch May 23, 2026 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wave 36b: BitNet pipeline_stage2_compute + layer_sequencer emitters (R-BN-2)

1 participant