ModNEF : MODular Neuromorphic Emulator for Fpga
Introduction
Overview
Dependencies
Library dependencies
- Python3 (Python v3.10.12 was used during development)
- rustc v1.59.0 or higher (rustc v1.72.1 was used during development)
- cargo v1.59.0 or higher (cargo v1.72.1 was used during development)
Driver dependencies
- rustc v1.59.0 or higher (rustc v1.72.1 was used during development)
- cargo v1.59.0 or higher (cargo v1.72.1 was used during development)
- maturin v1.1.0 or higher (maturin v1.1.0 was used during development)
- pkg-confgi linux package (v 0.29.2-1ubuntu3 was used during development)
- libudev-dev linux package (v 249.11-0ubuntu3.12 was used during development)
Examples and Network Paper dependencies
- torch (v 2.0.1)
- snntorch (v 0.7.0)
- tonic (v 1.4.3)
- torchvision (v 0.15.2)
- pyJoules (v 0.5.1)
- pandas (v 2.2.2)
- MNIST dataset
- NMNIST dataset
Installation
Automatic installation
The install.sh
script install all depencies of ModNEF library (only library and not example).
Manual installation
Step 1 : compile rust driver
Rust driver must be compiled first to correctly build ModNEF Python library.
- Install Maturin :
pip install maturin
(maturin version 1.1.0 was used during development) - Install rustserial dependencies :
sudo apt install pkg-config
sudo apt install libudev-dev
- Go to rust_driver directory :
cd rust_driver
-
optional (because build is also do during installation) build driver :
cargo build
- install driver :
pip install .
. DUring this phase, rust build is do.
Step 2 : install ModNEF python library
After rust driver installation you can install python library.
- Go to modneflib directory :
cd modneflib
- Install the library :
pip install .
-
optional Try to open modnef in python consol by typing :
from modnef import *
Check installation
The examples/check_installation
project is a simple project which integrate all ModNEF features in therms of tools and vhdl script.
The next step explain how
Create project
- Create vivado project
- From vivado add sources and import fpga_sources directory to you project
- Import Your top level and memory files generated by ModNEF architecture builder.
Run examples and network paper
To avoid the accumulation of files, only the binary network generated by SnnTorch is shared. To use the proposed network please follow the followings steps:
Example
ModNEF propose two differents example. The first example NetworkInference is a good introduction to ModNEF architecture builder and ModNEF drivers. The others example is Debugger that introduce ModNEF debugging and simulation tools.
Network Papers
We provides all presented network in the paper into NetworkPaper directory. To run these network please follows the following steps:
- Open a terminal is the subdirectory of network you want to run
- Run the command
python3 ./load_network.py
that will load the binary network and generate synaptic weight file. - Open the
arch_build.py
file and modify the constant value (starting by underscore) to correspond to your value. - Run
python3 ./arch_build.py
command that will generate VHDL architecture file and memory file. - Add VHDL and memory file to your vivado project.
- Generate the bitstream and put the circuit to your FPGA.
- In
inference.py
file, change the dataset path and the path to the USB board file. If you want to save the inference result, set the_SAVE
flag to true and modify the file name of output file. - Run
./inference.py
. The administrator access can be necessary.
Version note
This version of ModNEF is the updated version with snntorch based neurons model. The high level librairy differs from the presented version in paper.
License
The FPGA source of ModNEF is licensed under the CERN Open Hardware Licence Version 2 - Strongly Reciprocal and the software parts of, including Python librari and rust driver, are licensed under the GNU General Public License v3.0 or later. License files can be found under LICENSES/cern-ohl-s-2.0.txt for CERN-OHL-S-2.0 and LICENSES/GPL-3.0-or-later.txt for GPL-3.0.