Metadata-Version: 2.4
Name: mrve32-snn
Version: 0.1.0
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Rust
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Topic :: System :: Emulators
Classifier: Topic :: System :: Hardware
Classifier: Typing :: Typed
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Dist: mrve32>=0.1,<0.2
Requires-Dist: numpy>=1.24
Requires-Dist: pytest>=7 ; extra == 'test'
Provides-Extra: test
License-File: LICENSE
Summary: SNN layer accelerator device module for the MRVE32 RISC-V emulator
Keywords: risc-v,snn,spiking-neural-network,neuromorphic,emulator
License-Expression: Apache-2.0
Requires-Python: >=3.10
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Changelog, https://github.com/vladimirmitnovitskiy/MRVE32/blob/main/CHANGELOG.md
Project-URL: Issues, https://github.com/vladimirmitnovitskiy/MRVE32/issues
Project-URL: Repository, https://github.com/vladimirmitnovitskiy/MRVE32

# 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](docs/snn-accelerator-v0.md).

- 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`](../../docs/devices.md).

## Rust

```rust
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();
```

## Python

```bash
pip install ../..          # mrve32 core first (not on PyPI yet)
pip install .
```

```python
from mrve32 import Emulator
from mrve32_snn import SnnAccelerator, SnnDriver, reference_step, pack_spikes

emu = Emulator()
emu.map_device(0x1000_0000, SnnAccelerator(max_inputs=1024, max_outputs=512))
dev = SnnDriver(emu, 0x1000_0000)   # host-side driver over the emulated bus
```

`reference_step` is the NumPy golden model of one timestep; the tests check
the Rust model against it bit-exactly.

