code wiki / _hdl_build / rv64im_min_clint.nx

rv64im_min_clint.nx

buildroot/runtime/_hdl_build/rv64im_min_clint.nx

9256 B240 linesdepth 3pulls 3 transitivereach 45 importersview sourcekind librarytopic rv64im
docsdependenciesstructsconstsfunctions

about

rv64im_min_clint.nx -- Core-Local Interruptor (CLINT) MMIO device. Drives the kernel's preemptive timer. Two memory-mapped registers: MTIME (0x0200BFF8, 64-bit RO from CPU side) Monotonic counter; advances 1 per fabric-clock tick. Kernel reads it on every preempt-tick handler to measure latency. MTIMECMP[0] (0x02004000, 64-bit RW) Per-hart compare register. When MTIME >= MTIMECMP[0], the CLINT asserts MTIP on the hart; the CPU takes a machine-timer interrupt (mcause = (1 << 63) | 7) if mstatus.MIE and mie.MTIE are both set. Kernel rearms by writing MTIMECMP[0] = MTIME + TICK_CYCLES. Tier A FPGA: single-hart only, so MTIMECMP[N] for N>0 is absent. The full RISC-V CLINT spec also defines MSIP (software interrupt) at 0x02000000, but the kernel never uses it -- omitted here per the spec's "must implement enough that kernel boots" cardinal. Memory map (matches QEMU virt machine; kernel hardcodes these): 0x02000000 MSIP[0] -- NOT IMPLEMENTED in Tier A (4 bytes) 0x02004000 MTIMECMP[0] -- 8 bytes 0x02004008..0x0200BFF7 sparse; reads/writes return 0 0x0200BFF8 MTIME -- 8 bytes 0x0200C000 end of region Status: SEED. 2026-05-26. Register storage + access + interrupt generation. Synth target: 2 64-bit flop registers + comparator + memory-region address decoder. Tier A FPGA: trivial.

dependencies 2 imports · 35 importers

nx_syscalls.nx nishi_hdl_primitives.nx rv64im_min_clint.nx _gpu_run.nx _nvme_diag.nx nx_bootcap.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 nx_isa_run_sov.nx

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

imports: nx_syscalls.nxnishi_hdl_primitives.nx

imported by: _gpu_run.nx_nvme_diag.nxnx_bootcap.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_nishios_window.nxnx_nxc_baremetal.nxnx_nxc_run.nxnx_rv64_amo_gate.nxnx_rv64_csr_trap_oracle.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.nxrv64im_min_cpu_crosscheck.nxrv64im_min_elf_loader.nxrv64im_min_gfx_gate.nxrv64im_min_hot_report.nxrv64im_min_kernel_boot_smoke.nxrv64im_min_sim.nxrv64im_min_sim_smoke.nx

structs

62struct NxClint
186struct NxClintPorts

consts

36const NX_CLINT_BASE: i64 = 0x02000000
37const NX_CLINT_MSIP_BASE: i64 = 0x02000000
38const NX_CLINT_MTIMECMP_BASE: i64 = 0x02004000
39const NX_CLINT_MTIME_ADDR: i64 = 0x0200BFF8
40const NX_CLINT_END: i64 = 0x0200C000
43const NX_CLINT_OK: i64 = 0
44const NX_CLINT_ADDR_OUT_OF_RANGE: i64 = 1
45const NX_CLINT_BAD_ALIGNMENT: i64 = 2 // 8-byte access required
55const NX_CLINT_SLOT_MTIME: i64 = 0
56const NX_CLINT_SLOT_MTIMECMP: i64 = 1
57const NX_CLINT_SLOT_MTIP: i64 = 2
58const NX_CLINT_SLOT_N: i64 = 3
60const NX_CLINT_INIT_MTIMECMP: i64 = 0x7FFFFFFFFFFFFFFF // INT64_MAX
181const NX_CLINT_WIDTH_ADDR: i64 = 32 // physical address space
182const NX_CLINT_WIDTH_DATA: i64 = 64
183const NX_CLINT_WIDTH_VERDICT: i64 = 4
184const NX_CLINT_WIDTH_MTIP: i64 = 1

functions

67func nx_clint_init(c: *NxClint, storage: *i64) -> i64
79func nx_clint_addr_in_range(addr: i64) -> i64
91func nx_clint_read64(c: *NxClint, addr: i64, value_out: *i64) -> i64
113func nx_clint_write64(c: *NxClint, addr: i64, value: i64) -> i64
144func nx_clint_update_mtip(c: *NxClint) -> i64
161func nx_clint_mtip_get(c: *NxClint) -> i64
called by 1: nx_rv64im_sim_step
173func nx_clint_tick(c: *NxClint) -> i64
200func nx_clint_build(m: *NxHdlModule, ports: *NxClintPorts) -> i64