Skip to main content
Change of provenance

The repository or configuration that created this release differ from a previous release. View details.

PyPI Python CI License: Apache 2.0

mrve32-snn

SNN layer accelerator device module for the MRVE32 RISC-V emulator: a behavioural (golden) model of a memory-mapped spiking-layer accelerator, spec v0 draft.

  • LIF/IF neurons, i16 saturating potentials, i8 weights, reset by subtraction
  • one layer per START, local SRAM (spikes, weights, potentials, bias)
  • analytical cycle model, completion interrupt (MEIP)
  • the computation sits behind a swappable SnnBackend (default: ReferenceLif)

It plugs into the emulator through the public device interfaces only (BusDevice in Rust, the device C ABI in Python), like any third-party device; see docs/devices.md.

Install

pip install mrve32-snn        # also installs mrve32 and NumPy

Wheels exist for Linux, macOS and Windows, CPython 3.10 and newer. The emulator's own Python API is documented in docs/python.md.

Python

import numpy as np
import mrve32
from mrve32_snn import SnnAccelerator, SnnDriver, reference_step

emu = mrve32.Emulator()
emu.map_device(0x1000_0000, SnnAccelerator())
dev = SnnDriver(emu, 0x1000_0000)

rng = np.random.default_rng(0)
weights = rng.integers(-128, 128, size=(64, 32), dtype=np.int8)   # [n_in, n_out]
dev.load_layer(weights, v_th=100, leak_shift=4)

vmem = np.zeros(32, np.int16)
for t in range(10):
    spikes = rng.random(64) < 0.2
    out = dev.step(spikes)                    # write inputs, START, wait, read outputs
    expected, vmem = reference_step(spikes, weights, vmem, v_th=100, leak_shift=4)
    assert (out == expected).all() and (dev.read_vmem() == vmem).all()
print(dev.cycles, "cycles for the last step")

SnnDriver drives the device from Python through the emulated bus, with no firmware: useful to test models and data. Firmware programs the same registers itself; the driver's code is a readable reference for the programming sequence.

SnnAccelerator

SnnAccelerator(*, max_inputs=1024, max_outputs=512, weight_bytes=131072,
               t_setup=8, t_neuron=1, t_syn=1, lanes=8)

The device; map it with Emulator.map_device (a 1 MiB window). The arguments set its capacity and its timing model (how many cycles a step takes, spec §6). It raises the machine external interrupt when a step finishes, if enabled.

SnnDriver(emu, base)

Raises ValueError if there is no accelerator at base. Attributes: max_inputs, max_outputs, weight_bytes (read from the device), and n_in, n_out (the configured layer).

Method
load_layer(weights, *, v_th, leak_shift=0, bias=None) write int8[n_in, n_out] weights (and optional int16[n_out] bias) and configure the layer from their shape
configure(n_in, n_out, *, v_th, leak_shift=0, bias=False) set the layer size and neuron parameters only
write_bias(bias), write_vmem(vmem), read_vmem(n=None) bias and membrane potentials, int16
clear_vmem() reset all potentials to 0
write_input_spikes(spikes), read_output_spikes(n=None) boolean vectors
start(*, clear_vmem=False) start one timestep
wait(*, max_cycles=10_000_000, chunk=64) Emulator.tick until done; raises SnnError on a configuration error, TimeoutError if it never finishes
step(spikes_in) -> bool[n_out] write inputs, start, wait, acknowledge, return output spikes
enable_irq(enabled=True), ack_irq() the completion interrupt
status, busy, cycles, in_spikes, out_spikes, syn_ops status registers of the last step: cycles is its duration, syn_ops the number of synaptic accumulations (in_spikes × n_out)

Functions

  • reference_step(spikes_in, weights, vmem, *, v_th, leak_shift=0, bias=None) -> (spikes_out, vmem_out): one timestep in NumPy, bit-exact with the device (spec §5). Use it as the golden model in tests.
  • pack_spikes(spikes) -> uint32[] and unpack_spikes(words, n) -> bool[n]: convert between boolean vectors and the device's packed format (neuron k is bit k % 32 of word k // 32).

SnnError(code) is raised for a configuration error; code is one of ERR_INVALID_LAYER_SIZE, ERR_WEIGHTS_DO_NOT_FIT, ERR_INVALID_THRESHOLD. The module also exports the register offsets and bit masks of the specification (REG_CTRL, REG_STATUS, WEIGHTS_BASE, CTRL_START, STATUS_DONE, ...) for firmware-style access with emu.read_u32 and emu.write_u32.

Rust

cargo add mrve32 mrve32-snn
use mrve32::Bus;
use mrve32_snn::{SNN_WINDOW_SIZE, SnnAccelerator, SnnConfig};

let mut bus = Bus::new();
bus.map_device(0x1000_0000, SNN_WINDOW_SIZE, Box::new(SnnAccelerator::new(SnnConfig::default())))
    .unwrap();

Development

cargo test                          # Rust model and spec tests
pip install -e ".[test]"            # builds the extension; mrve32 from PyPI
pytest                              # Python tests, incl. the NumPy reference model

To work against a local checkout of MRVE32 instead of the published crate, add to .cargo/config.toml (not committed):

[patch.crates-io]
mrve32 = { path = "../MRVE32" }

License

Apache-2.0, see LICENSE.

Metadata

Release files for mrve32-snn 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Change of provenance

The repository or configuration that created these release files differ from that of a previous release.

We recommend inspecting the repository and configuration before proceeding. View details.

Source distribution (sdist)

Source distribution for mrve32-snn 0.2.0
File Size Uploaded Provenance Actions
mrve32_snn-0.2.0.tar.gz 30.8 kB With provenance Details for mrve32_snn-0.2.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for mrve32-snn 0.2.0
File Actions
mrve32_snn-0.2.0-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details for mrve32_snn-0.2.0-cp310-abi3-win_amd64.whl
mrve32_snn-0.2.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details for mrve32_snn-0.2.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
mrve32_snn-0.2.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details for mrve32_snn-0.2.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
mrve32_snn-0.2.0-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details for mrve32_snn-0.2.0-cp310-abi3-macosx_11_0_arm64.whl
mrve32_snn-0.2.0-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details for mrve32_snn-0.2.0-cp310-abi3-macosx_10_12_x86_64.whl

Total release size: 1.2 MB

Release files / mrve32_snn-0.2.0.tar.gz

Change of provenance

This file belongs to a release with changed provenance: the repository or configuration that created the release files differ from that of a previous release.

We recommend inspecting the repository and configuration before proceeding. View details.

Download URL mrve32_snn-0.2.0.tar.gz
Size 30.8 kB
Tags Source
SHA-256 checksum
How to use checksums
e63db45799dfee878e6c3291d0482f8c7f1e1bb9f6d49722da59eb79ba4f504b
BLAKE2b-256 checksum
How to use checksums
8f66b68176c139702bd151b5e8f2b6f6ff3718aaa15ca69f0dad3590c62fd562
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.

Transparency log

Release files / mrve32_snn-0.2.0-cp310-abi3-win_amd64.whl

Change of provenance

This file belongs to a release with changed provenance: the repository or configuration that created the release files differ from that of a previous release.

We recommend inspecting the repository and configuration before proceeding. View details.

Download URL mrve32_snn-0.2.0-cp310-abi3-win_amd64.whl
Size 139.9 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
86c1c18fcca0f9c7a29a973c463f21550db332061a2991b550870cddbca707a1
BLAKE2b-256 checksum
How to use checksums
e6392261cb2735f72ccd60d2f4e93abc619acfd249909550f6052102a73c6a3d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.

Transparency log

Release files / mrve32_snn-0.2.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Change of provenance

This file belongs to a release with changed provenance: the repository or configuration that created the release files differ from that of a previous release.

We recommend inspecting the repository and configuration before proceeding. View details.

Download URL mrve32_snn-0.2.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 280.6 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
6922f2a5b8de96c8bafe7ec5f52d8ca48028fb84f891536b7cbc8b775c4dc09f
BLAKE2b-256 checksum
How to use checksums
aae8419acb1b5a66fa275f8b66df5a4faae1de600a46cab286a9f7964a264710
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.

Transparency log

Release files / mrve32_snn-0.2.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Change of provenance

This file belongs to a release with changed provenance: the repository or configuration that created the release files differ from that of a previous release.

We recommend inspecting the repository and configuration before proceeding. View details.

Download URL mrve32_snn-0.2.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 275.3 kB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
54c99f41241c03ad681969154984870c1b5159881126546cf6a199902e313164
BLAKE2b-256 checksum
How to use checksums
ce7c84c283d7be9d45e5d46f6285d3ec6c9c1d52560b6bfd14903aa7968259b4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.

Transparency log

Release files / mrve32_snn-0.2.0-cp310-abi3-macosx_11_0_arm64.whl

Change of provenance

This file belongs to a release with changed provenance: the repository or configuration that created the release files differ from that of a previous release.

We recommend inspecting the repository and configuration before proceeding. View details.

Download URL mrve32_snn-0.2.0-cp310-abi3-macosx_11_0_arm64.whl
Size 242.6 kB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
464664de1696e4a1d6d9b6b856dd00e10b3df31f65f61865541f09da2570a313
BLAKE2b-256 checksum
How to use checksums
476b36b9b179e844e0d1c4e5185c242ef290ad6439682f8f6c46a4162bd8f5c7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.

Transparency log

Release files / mrve32_snn-0.2.0-cp310-abi3-macosx_10_12_x86_64.whl

Change of provenance

This file belongs to a release with changed provenance: the repository or configuration that created the release files differ from that of a previous release.

We recommend inspecting the repository and configuration before proceeding. View details.

Download URL mrve32_snn-0.2.0-cp310-abi3-macosx_10_12_x86_64.whl
Size 243.2 kB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
76cda88bed94446a06e45cce7a916a6e1ff3d626b6a4353e7c15c0e764888f90
BLAKE2b-256 checksum
How to use checksums
3b4d6c5fffa0bb8defe42d9e2d20e97398e03e02c7a94c46a60b42bc8b147bbb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.

Transparency log

Security for mrve32-snn 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Change of provenance

The repository and configuration that created this release differ from a previous release.

While this could reflect a routine change by the project maintainers, it may also indicate that the release files have been compromised.

Select from 6 files

Attestation for mrve32_snn-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page