code wiki / (root) / nishi_hdl_primitives.nx

nishi_hdl_primitives.nx

buildroot/runtime/nishi_hdl_primitives.nx

10710 B258 linesdepth 2pulls 2 transitivereach 180 importersview sourcekind librarytopic nishi
docsdependenciesstructsconstsfunctions

about

nishi_hdl_primitives.nx -- Nishi HDL DSL primitive types. THE seed file for the NishiLang-hosted hardware description DSL. Defines just the type primitives -- Module, Wire, Reg, Bus, Clock -- so the first concrete user (rv64im_min_decoder.nx) has a vocabulary to express logic in. Status: SEED. 2026-05-26. Types only; behavior (simulation, netlist emit, synth) lands in follow-on commits per hdl/README.md deliverables checklist. Cardinal "bits up, additive intelligence": these types are the substrate the DSL builds on. Future commits add lex/parse/sim/ netlist layers ABOVE them, NOT replacements OF them. Why NishiLang-hosted vs free-standing DSL syntax: feedback-no-nxc2-c-extension-only-nishilang-forward -- the whole stack is NishiLang. Verilog/SystemVerilog/Chisel/Migen are external; substrate's HDL is just NishiLang types + functions. The "DSL" is a coding convention + a constructor library. Surface comparison: Verilog 2005: wire [7:0] data; Chisel (Scala): val data = Wire(UInt(8.W)) NishiHDL: let data: NxHdlWire = nx_hdl_wire_make(width=8) The width-typed value flows through Module-graph constructors; nishi-synth (future) reads the graph and emits a gate netlist.

dependencies 1 imports · 59 importers

nx_syscalls.nx nishi_hdl_primitives.nx nishi_synth.nx nishi_synth_gates.nx nx_amo_payload.nx nx_cell_sink.nx nx_emu_bench.nx nx_evo_isa_sov.nx nx_geneal_energy_sov.nx nx_isa_cf_sov.nx nx_isa_equiv_sov.nx nx_isa_loop_sov.nx

diagram shows first 10 each side; +0 more imports, +49 more importers in the complete lists below.

imports: nx_syscalls.nx

imported by: nishi_synth.nxnishi_synth_gates.nxnx_amo_payload.nxnx_cell_sink.nxnx_emu_bench.nxnx_evo_isa_sov.nxnx_geneal_energy_sov.nxnx_isa_cf_sov.nxnx_isa_equiv_sov.nxnx_isa_loop_sov.nxnx_isa_run_sov.nxnx_isa_synth_sov.nxnx_mulh_diag.nxnx_nxc_baremetal.nxnx_nxc_run.nxnx_rv64_amo_gate.nxnx_rv64_csr_trap_oracle.nxnx_rv64_fast.nxnx_rv64_fast_dev_gate.nxnx_rv64_fast_gate.nxnx_rv64_kernel_gate.nxnx_rv64_mmu_oracle.nxnx_rv64_qemu_fuzz.nxnx_rv64_qemu_oracle.nxnx_rv64_realc_gate.nxnx_rv64_run_bin.nxnx_rv64_sdeleg_oracle.nxnx_rv64_snapshot_gate.nxnx_rv64_timer_oracle.nxnx_rv64im_cpu_crosscheck.nxnx_rv64im_decoder_dump.nxnx_simtcore.nxnx_simtcore_gate.nxrv64im_min_alu.nxrv64im_min_clint.nxrv64im_min_cpu_crosscheck.nxrv64im_min_csr.nxrv64im_min_decoder.nxrv64im_min_decoder_proof.nxrv64im_min_elf_loader.nxrv64im_min_gfx_gate.nxrv64im_min_gpu.nxrv64im_min_hot_report.nxrv64im_min_kernel_boot_smoke.nxrv64im_min_mmu.nxrv64im_min_multi_tier_roi.nxrv64im_min_nndev.nxrv64im_min_nvme.nxrv64im_min_regfile.nxrv64im_min_sim.nxrv64im_min_sim_smoke.nxrv64im_min_symtab.nxrv64im_min_uart.nxrv64im_min_virtio.nxsynth_emit_alu.nxsynth_emit_alu_gates.nxsynth_emit_alu_gates_smoke.nxsynth_emit_regfile_gates.nxsynth_emit_regfile_gates_smoke.nx

structs

135struct NxHdlModule

consts

38const NX_HDL_WIDTH_MIN: i64 = 1
39const NX_HDL_WIDTH_MAX: i64 = 512
51const NX_HDL_KIND_WIRE: i64 = 0 // combinational; resolves each clock edge
52const NX_HDL_KIND_REG: i64 = 1 // sequential; holds value across edges
53const NX_HDL_KIND_INPUT: i64 = 2 // module port, driven by parent
54const NX_HDL_KIND_OUTPUT: i64 = 3 // module port, driven by self
55const NX_HDL_KIND_INOUT: i64 = 4 // bidirectional port (MMIO buses)
56const NX_HDL_KIND_CLOCK: i64 = 5 // clock domain root
57const NX_HDL_KIND_RESET: i64 = 6 // reset signal (sync or async)
58const NX_HDL_KIND_CONST: i64 = 7 // compile-time constant
59const NX_HDL_KIND_N_KINDS: i64 = 8
68const NX_HDL_OK: i64 = 0
69const NX_HDL_BAD_WIDTH: i64 = 1
70const NX_HDL_BAD_KIND: i64 = 2
71const NX_HDL_WIDTH_MISMATCH: i64 = 3 // connect of incompatible widths
72const NX_HDL_KIND_MISMATCH: i64 = 4 // e.g., wire driven by another wire
73const NX_HDL_GRAPH_FULL: i64 = 5 // module-graph capacity exceeded
74const NX_HDL_DRIVER_CONFLICT: i64 = 6 // multiple drivers on a wire
75const NX_HDL_N_VERDICTS: i64 = 7
92const NX_HDL_HANDLE_NONE: i64 = 0 - 1
95const NX_HDL_RESET_ACTIVE_HIGH: i64 = 0
96const NX_HDL_RESET_ACTIVE_LOW: i64 = 1
97const NX_HDL_RESET_SYNC: i64 = 0
98const NX_HDL_RESET_ASYNC: i64 = 1
104const NX_HDL_MODULE_MAX_SIGNALS: i64 = 8192 // RV64IM-min core + full ALU (divider+mulh+W-variant)
105const NX_HDL_MODULE_MAX_CHILDREN: i64 = 256 // sub-module instantiations
122const NX_HDL_SIGNAL_STRIDE_BYTES: i64 = 32
125const NX_HDL_SIGNAL_FIELD_KIND: i64 = 0
126const NX_HDL_SIGNAL_FIELD_WIDTH: i64 = 1
127const NX_HDL_SIGNAL_FIELD_DRIVER: i64 = 2
128const NX_HDL_SIGNAL_FIELD_NAME: i64 = 3

functions

41func nx_hdl_width_is_valid(w: i64) -> i64
called by 1: nx_hdl_signal_alloc
61func nx_hdl_kind_is_valid(k: i64) -> i64
called by 1: nx_hdl_signal_alloc
77func nx_hdl_verdict_is_valid(v: i64) -> i64
150func nx_hdl_signal_kind(m: *NxHdlModule, handle: i64) -> i64
called by 1: nx_hdl_connect
156func nx_hdl_signal_width(m: *NxHdlModule, handle: i64) -> i64
called by 1: nx_hdl_connect
162func nx_hdl_signal_driver(m: *NxHdlModule, handle: i64) -> i64
called by 1: nx_hdl_connect
174func nx_hdl_signal_alloc(m: *NxHdlModule, kind: i64, width: i64) -> i64
187func nx_hdl_wire(m: *NxHdlModule, width: i64) -> i64
191func nx_hdl_reg(m: *NxHdlModule, width: i64) -> i64
195func nx_hdl_input(m: *NxHdlModule, width: i64) -> i64
199func nx_hdl_output(m: *NxHdlModule, width: i64) -> i64
203func nx_hdl_clock(m: *NxHdlModule) -> i64
207func nx_hdl_reset(m: *NxHdlModule) -> i64
221func nx_hdl_connect(m: *NxHdlModule, sink: i64, source: i64) -> i64
245func nx_hdl_module_init(m: *NxHdlModule, name: *u8, name_len: i64,
called by 3: mainmainmain