code wiki / _hdl_build / nx_fpga_seq.nx

nx_fpga_seq.nx

buildroot/runtime/_hdl_build/nx_fpga_seq.nx

4169 B74 linesdepth 4pulls 4 transitivereach 23 importersview sourcekind librarytopic fpga
docsdependenciesstructsconstsfunctions

about

nx_fpga_seq.nx -- LIB: RUNG 10a -- the SEQUENTIAL (clocked, stateful) fabric. Every prior rung is purely COMBINATIONAL (fab_eval = one forward pass, no memory). A real CPU is SEQUENTIAL: registers and a program counter that HOLD state across clock cycles. This adds the DFF (the FPGA's sequential atom) to the fabric: a cell can be a LUT4 (combinational) or a DFF (holds Q, latches D on a clock TICK). seq_eval settles the combinational logic (DFFs output their CURRENT Q); seq_tick settles then latches every DFF's D->Q SIMULTANEOUSLY (no race). Feedback through a DFF is legal (q -> +1 -> D) -- that is exactly a counter / program counter. REPRESENTATION (adds `kind` to the bitstream): kind[k] 0=LUT4, 1=DFF. LUT cell: init[k] + src[k*4+0..3] inputs. DFF cell: src[k*4+0] = D source (init unused); q[k] = held state (caller-owned, initialized by the caller). NEVER-BRICK (#26): state is bounded (caller-owned q[]), tick is bounded (ncells), deterministic (same q+inputs -> same next q), zero hardware-state writes. Builds on nx_fpga_lut (lut4_eval) + nx_fpga_fabric (fab_resolve). license_tier: ORIGINAL

dependencies 3 imports · 8 importers

nx_fpga_lut.nx nx_fpga_fabric.nx nx_syscalls.nx nx_fpga_seq.nx nx_fpga_board_anim_gate.nx nx_fpga_board_gate.nx nx_fpga_counter_gate.nx nx_fpga_pc.nx nx_fpga_ram.nx nx_fpga_regfile.nx nx_fpga_verilog_seq_gate.nx nx_nhdl_gate.nx

imports: nx_fpga_lut.nxnx_fpga_fabric.nxnx_syscalls.nx

imported by: nx_fpga_board_anim_gate.nxnx_fpga_board_gate.nxnx_fpga_counter_gate.nxnx_fpga_pc.nxnx_fpga_ram.nxnx_fpga_regfile.nxnx_fpga_verilog_seq_gate.nxnx_nhdl_gate.nx

structs

none

consts

16const K_MAGIC_65535: i64 = 65535

functions

19func seq_eval(ncells: i64, npi: i64, kind: *i64, init: *i64, src: *i64, pi: *i64, cellout: *i64, q: *i64) -> i64
35func seq_tick(ncells: i64, npi: i64, kind: *i64, init: *i64, src: *i64, pi: *i64, cellout: *i64, q: *i64) -> i64
48func seq_build_counter(width: i64, kind: *i64, init: *i64, src: *i64, po_src: *i64) -> i64
called by 4: mainmainmainmain calls 1: fl_gate_to_lut4