code wiki / _hdl_build / rv64im_min_gpu.nx

rv64im_min_gpu.nx

buildroot/runtime/_hdl_build/rv64im_min_gpu.nx

14440 B280 linesdepth 3pulls 3 transitivereach 45 importersview sourcekind librarytopic rv64im
docsdependenciesstructsconstsfunctions

about

rv64im_min_gpu.nx -- a SOVEREIGN GPU-class command-submission controller device model (the 4th device class for the driver-from-spec arc, toward the GPU/CUDA/DirectX trajectory). Twin of rv64im_min_nvme.nx but for the GPU SUBMISSION model: a command RING in guest RAM, a write-to- submit DOORBELL, a monotonic FENCE/seqno the driver polls for completion, and a RESULTPEEK binding-proof register. It COMPOSES with the sovereign SPIR-V lane: a command packet MUST carry the SPIR-V magic 0x07230203 (a compute-shader dispatch) or the device refuses to execute -- so a GPU driver authored from an op-list spec drives a real SPIR-V-validated dispatch. The device models ONE controller window [0x10007000, 0x10008000) -- free of the virtio (0x10001/ 0x10002), nvme (0x10003-0x10005), nndev (0x10005), and mmu (0x10006) windows (additive). KEY behaviour: on a DOORBELL write the device fetches the command packet from RING_BASE (STRUCT_WALK: opcode + spirv_magic + operand + seqno), validates the SPIR-V magic, "executes" the dispatch, bumps FENCE to the submitted seqno, and latches RESULTPEEK = (operand<<16)|seqno. GPU/Vulkan/SPIR-V here is the last-mile interop PROBE + a measuring stick to EXCEED -- the emitted driver + the op-list shapes are Nishi-native (the device identity lives ENTIRELY in the spec; the canonical op-list emitter nx_drv_proto_emit knows zero GPU). Status: SEED. 2026-06-13. Enable + command-ring doorbell dispatch + SPIR-V-magic-gated fence/result. license_tier: ORIGINAL

dependencies 2 imports · 2 importers

nx_syscalls.nx nishi_hdl_primitives.nx rv64im_min_gpu.nx _gpu_run.nx rv64im_min_sim.nx

imports: nx_syscalls.nxnishi_hdl_primitives.nx

imported by: _gpu_run.nxrv64im_min_sim.nx

structs

83struct NxGpu

consts

25const NX_GPU_BASE: i64 = 0x10007000
26const NX_GPU_END: i64 = 0x10008000
36const NX_GPU_OFF_ID: i64 = 0x00
37const NX_GPU_OFF_CTRL: i64 = 0x04
38const NX_GPU_OFF_STATUS: i64 = 0x08
39const NX_GPU_OFF_RING_LO: i64 = 0x10
40const NX_GPU_OFF_RING_HI: i64 = 0x14
41const NX_GPU_OFF_DOORBELL: i64 = 0x20
42const NX_GPU_OFF_FENCE: i64 = 0x24
43const NX_GPU_OFF_RESULTPEEK: i64 = 0x28
46const NX_GPU_ID: i64 = 0x00475055 // RO identity const
47const NX_GPU_CTRL_EN: i64 = 1 // CTRL.EN = bit0
48const NX_GPU_STATUS_READY: i64 = 1 // STATUS.READY = bit0
49const NX_GPU_SPIRV_MAGIC: i64 = 0x07230203 // SPIR-V module magic -- the dispatch must carry it
56const NX_GPU_PKT_OFF_OPCODE: i64 = 0
57const NX_GPU_PKT_OFF_MAGIC: i64 = 4
58const NX_GPU_PKT_OFF_OPERAND:i64 = 8
59const NX_GPU_PKT_OFF_SEQNO: i64 = 12
62const NX_GPU_OPCODE_ECHO: i64 = 1 // (operand<<16)|seqno binding echo (the base round-trip)
63const NX_GPU_OPCODE_DOT8: i64 = 2 // int8 4-elem dot product -> RESULTPEEK
64const NX_GPU_OPCODE_MATMUL2: i64 = 3 // 2x2 int8 matmul tile (the V-RAM-005 primitive) -> packed RESULTPEEK
65const NX_GPU_PKT_OFF_CSEQ: i64 = 8 // DOT8: seqno @+8 (operand slot reused for the compute opcode)
66const NX_GPU_PKT_OFF_A: i64 = 16 // DOT8: 4 int8 a-values @+16..19
67const NX_GPU_PKT_OFF_B: i64 = 20 // DOT8: 4 int8 b-values @+20..23
70const NX_GPU_OK: i64 = 0
71const NX_GPU_ADDR_OUT_OF_RANGE: i64 = 1
74const NX_GPU_SLOT_CTRL: i64 = 0
75const NX_GPU_SLOT_STATUS: i64 = 1
76const NX_GPU_SLOT_RING_LO: i64 = 2
77const NX_GPU_SLOT_RING_HI: i64 = 3
78const NX_GPU_SLOT_FENCE: i64 = 4
79const NX_GPU_SLOT_RESULTPEEK: i64 = 5
80const NX_GPU_SLOT_DBELL: i64 = 6
81const NX_GPU_SLOT_N: i64 = 7

functions

89func nx_gpu_reset_storage(storage: *i64) -> i64
100func nx_gpu_init(c: *NxGpu, storage: *i64) -> i64
called by 1: main calls 1: nx_gpu_reset_storage
110func nx_gpu_addr_in_range(c: *NxGpu, addr: i64) -> i64
117func nx_gpu_dma_rd16(mem_buf: *u8, off: i64) -> i64
called by 1: nx_gpu_doorbell_dma
122func nx_gpu_dma_rd32(mem_buf: *u8, off: i64) -> i64
called by 1: nx_gpu_doorbell_dma
129func nx_gpu_dma_inrange(off: i64, w: i64, mem_size: i64) -> i64
called by 1: nx_gpu_doorbell_dma
134func nx_gpu_dma_rd8(mem_buf: *u8, off: i64) -> i64 { return mem_buf[off] as i64 }
called by 1: nx_gpu_doorbell_dma
136func nx_gpu_sext8(v: i64) -> i64 { let low: i64 = v & 0xff; if (low & 0x80) != 0 { return low | (0 - 256) } return low }
called by 1: nx_gpu_doorbell_dma
139func nx_gpu_read32(c: *NxGpu, addr: i64, value_out: *i64) -> i64
183func nx_gpu_doorbell_dma(c: *NxGpu, mem_buf: *u8, mem_base: i64, mem_size: i64) -> i64
251func nx_gpu_write32(c: *NxGpu, addr: i64, value: i64) -> i64
277func nx_gpu_fence(c: *NxGpu) -> i64