API Reference
Complete reference for the NMC Python SDK (import neurmorph), the CLI, the C runtime API (nrm_runtime.h), and the HAL shim interface.
Python SDK
Install with pip install nmc-cli. The SDK exposes compilation, calibration, inspection, and device management functions.
neurmorph.compile(model_path, target, calibrate=True, cal_file=None)Compile a TorchScript or ONNX model to a .snn binary. Returns a CompileResult object with output path, accuracy delta, and memory stats.
| Parameter | Type | Description |
|---|---|---|
| model_path | str / Path | Path to .pt or .onnx export |
| target | str | "nt3000" | "brainpulse2" | "syncore-v" |
| calibrate | bool | Run threshold calibration pass (recommended) |
| cal_file | str | None | Path to pre-computed .cal file (skips calibration pass if provided) |
neurmorph.inspect(snn_path)Parse a .snn binary and return a ModelInfo object with neuron count, layer topology, SRAM requirements, and calibration checksum.
neurmorph.deploy(snn_path, device)Flash a compiled .snn binary to a connected eval kit device. Device string format: nt3000:usb0.
CLI Reference
The nmc CLI is installed alongside the Python package. All commands support --json for machine-readable output and --verbose for pass-level diagnostics.
| Command | Description |
|---|---|
nmc compile <model> --target <chip> | Compile model to .snn binary |
nmc calibrate <model> --dataset <dir> | Run threshold calibration, save .cal file |
nmc inspect <binary.snn> | Print binary metadata and memory layout |
nmc deploy <binary.snn> --device <dev> | Flash binary to connected device |
nmc infer --device <dev> --sample <npy> | Run one inference and print result + latency |
nmc doctor | Check environment: Python, drivers, device detection |
nmc --version | Print NMC version |
C Runtime API
Include nrm_runtime.h in your embedded project. Requires a HAL shim implementation for your target chip.
| Function | Description |
|---|---|
nrm_load(model, data, arena) | Load .snn binary data into static arena. Returns 0 on success. |
nrm_step(model) | Execute one timestep window. Blocks until complete. |
nrm_reset(model) | Reset neuron state to post-load initial values. |
nrm_arena_init(arena, base, size) | Initialize static memory arena from a base pointer and byte size. |
nrm_get_output(model, buf, len) | Copy output spike vector to caller-allocated buffer. |
HAL Shim API
Port the runtime to a new chip by implementing the 8-function HAL shim. Provide your implementations in a C source file and link against the runtime library.
| Symbol | Signature | Description |
|---|---|---|
hal_spike_read | int(spike_t *buf, size_t n) | Read up to n spikes from input bus into buf |
hal_spike_write | int(const spike_t *buf, size_t n) | Write n spikes to output bus |
hal_mem_read | void(void *dst, addr_t src, size_t n) | Read n bytes from chip address space |
hal_mem_write | void(addr_t dst, const void *src, size_t n) | Write n bytes to chip address space |
hal_timer_us | uint32_t(void) | Return monotonic microsecond counter |
hal_sleep_us | void(uint32_t us) | Sleep for at least us microseconds |
hal_power_mode | void(nrm_power_t mode) | Set chip power state (ACTIVE | SLEEP | DEEP_SLEEP) |
hal_log | void(const char *msg) | Optional: output diagnostic string (may be a no-op) |