• Stars
    star
    630
  • Rank 71,328 (Top 2 %)
  • Language
    Python
  • License
    Other
  • Created almost 6 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A refreshed Python toolbox for building complex digital hardware. See https://gitlab.com/nmigen/nmigen

This repos has moved to https://gitlab.com/nmigen/nmigen

nMigen

A refreshed Python toolbox for building complex digital hardware

Although nMigen is incomplete and in active development, it can already be used for real-world designs. The nMigen language (nmigen.hdl.ast, nmigen.hdl.dsl) will not undergo incompatible changes. The nMigen standard library (nmigen.lib) and build system (nmigen.build) will undergo minimal changes before their design is finalized.

Despite being faster than schematics entry, hardware design with Verilog and VHDL remains tedious and inefficient for several reasons. The event-driven model introduces issues and manual coding that are unnecessary for synchronous circuits, which represent the lion's share of today's logic designs. Counterintuitive arithmetic rules result in steeper learning curves and provide a fertile ground for subtle bugs in designs. Finally, support for procedural generation of logic (metaprogramming) through "generate" statements is very limited and restricts the ways code can be made generic, reused and organized.

To address those issues, we have developed the nMigen FHDL, a library that replaces the event-driven paradigm with the notions of combinatorial and synchronous statements, has arithmetic rules that make integers always behave like mathematical integers, and most importantly allows the design's logic to be constructed by a Python program. This last point enables hardware designers to take advantage of the richness of the Python language—object oriented programming, function parameters, generators, operator overloading, libraries, etc.—to build well organized, reusable and elegant designs.

Other nMigen libraries are built on FHDL and provide various tools and logic cores. nMigen also contains a simulator that allows test benches to be written in Python.

See the doc/ folder for more technical information.

nMigen is based on Migen, a hardware description language developed by M-Labs. Although Migen works very well in production, its design could be improved in many fundamental ways, and nMigen reimplements Migen concepts from scratch to do so. nMigen also provides an extensive compatibility layer that makes it possible to build and simulate most Migen designs unmodified, as well as integrate modules written for Migen and nMigen.

The development of nMigen has been supported by M-Labs and LambdaConcept.

HLS?

nMigen is not a "Python-to-FPGA" conventional high level synthesis (HLS) tool. It will not take a Python program as input and generate a hardware implementation of it. In nMigen, the Python program is executed by a regular Python interpreter, and it emits explicit statements in the FHDL domain-specific language. Writing a conventional HLS tool that uses nMigen as an internal component might be a good idea, on the other hand :)

Installation

nMigen requires Python 3.6 (or newer), Yosys 0.9 (or newer), as well as a device-specific toolchain.

pip install git+https://github.com/m-labs/nmigen.git
pip install git+https://github.com/m-labs/nmigen-boards.git

Introduction

TBD

Supported devices

nMigen can be used to target any FPGA or ASIC process that accepts behavioral Verilog-2001 as input. It also offers extended support for many FPGA families, providing toolchain integration, abstractions for device-specific primitives, and more. Specifically:

  • Lattice iCE40 (toolchains: Yosys+nextpnr, LSE-iCECube2, Synplify-iCECube2);
  • Lattice MachXO2 (toolchains: Diamond);
  • Lattice ECP5 (toolchains: Yosys+nextpnr, Diamond);
  • Xilinx Spartan 3A (toolchains: ISE);
  • Xilinx Spartan 6 (toolchains: ISE);
  • Xilinx 7-series (toolchains: Vivado);
  • Xilinx UltraScale (toolchains: Vivado);
  • Intel (toolchains: Quartus).

FOSS toolchains are listed in bold.

Migration from Migen

If you are already familiar with Migen, the good news is that nMigen provides a comprehensive Migen compatibility layer! An existing Migen design can be synthesized and simulated with nMigen in three steps:

  1. Replace all from migen import <...> statements with from nmigen.compat import <...>.
  2. Replace every explicit mention of the default sys clock domain with the new default sync clock domain. E.g. ClockSignal("sys") is changed to ClockSignal("sync").
  3. Migrate from Migen build/platform system to nMigen build/platform system. nMigen does not provide a build/platform compatibility layer because both the board definition files and the platform abstraction differ too much.

Note that nMigen will not produce the exact same RTL as Migen did. nMigen has been built to allow you to take advantage of the new and improved functionality it has (such as producing hierarchical RTL) while making migration as painless as possible.

Once your design passes verification with nMigen, you can migrate it to the nMigen syntax one module at a time. Migen modules can be added to nMigen modules and vice versa, so there is no restriction on the order of migration, either.

Community

nMigen discussions take place on the M-Labs IRC channel, #m-labs at freenode.net. Feel free to join to ask questions about using nMigen or discuss ongoing development of nMigen and its related projects.

License

nMigen is released under the very permissive two-clause BSD license. Under the terms of this license, you are authorized to use nMigen for closed-source proprietary designs.

Even though we do not require you to do so, these things are awesome, so please do them if possible:

  • tell us that you are using nMigen
  • put the nMigen logo on the page of a product using it, with a link to https://nmigen.org
  • cite nMigen in publications related to research it has helped
  • send us feedback and suggestions for improvements
  • send us bug reports when something goes wrong
  • send us the modifications and improvements you have done to nMigen as pull requests on GitHub

See LICENSE file for full copyright and license info.

"Electricity! It's like magic!"

More Repositories

1

migen

A Python toolbox for building complex digital hardware
Python
1,092
star
2

artiq

A leading-edge control system for quantum information experiments
Python
426
star
3

misoc

The original high performance and small footprint system-on-chip based on Migenâ„¢
C
290
star
4

milkymist

SoC design for Milkymist One - LM32, DDR SDRAM, 2D TMU, PFPU
Verilog
145
star
5

lm32

LatticeMico32 soft processor
Verilog
96
star
6

pythonparser

Python
71
star
7

rust-atomic_ring_buffer

Atomic ring buffer is a fixed-size multi-producer multi-consumer queue that works on bare-metal systems.
Rust
49
star
8

tdc-core

A 26ps RMS time-to-digital converter (TDC) core for Spartan-6 FPGAs
Verilog
46
star
9

VexRiscv-verilog

Using VexRiscv without installing Scala
Verilog
32
star
10

dslite2svd

Converter of register descriptions from the TI DSLite format to CMSIS SVD format
Rust
32
star
11

jesd204b

JESD204B core for Migen/MiSoC
Python
31
star
12

flickernoise

Video synthesis software for the Milkymist One
C
30
star
13

nmigen-boards

Board and connector definition files for nMigen
Python
27
star
14

uclibc-lm32

uClibc with LM32 architecture support
C
19
star
15

nmigen-soc

System on Chip toolkit for nMigen
Python
17
star
16

ionpak

A modern, low-cost universal controller for hot-cathode ionization vacuum gauges. (WIP)
Rust
16
star
17

liboscparse

Liblo (OSC library) without GNU/Autocrap and network dependent non-portable code
C
13
star
18

microscope

Finding the bacteria in rotting FPGA designs.
Python
13
star
19

mtk

The Milkymist GUI toolkit (Genode FX based), because X11 sucks!
C
13
star
20

nmigen-stdio

Industry standard I/O for nMigen
Python
11
star
21

sipyco

Simple Python Communications
Python
9
star
22

openwrt-milkymist

OpenWRT with Milkymist support
C
9
star
23

ek-tm4c1294xl-demo

An example of programming the TI EK-TM4C1294XL development board in Rust
Rust
9
star
24

rtems-yaffs2

YAFFS2 with RTEMS support (new API)
C
7
star
25

llvm-lm32

LLVM with LatticeMico32 support patch (JPBonn tree)
C++
7
star
26

scripts

Various script files and Makefiles to build Milkymist One software
Shell
7
star
27

mixxeo-soc

System-on-chip design and software for the Mixxeo
C
7
star
28

fjmem-m1

FJMEM core for flashing Mixxeo and Milkymist One
Verilog
6
star
29

clang-lm32

Clang with LatticeMico32 support
C++
6
star
30

board-m1

Milkymist One PCB design files
Prolog
6
star
31

lwip

lwip mirror
C
5
star
32

adc2tcp

Rust
4
star
33

cairoplot3

Python 3 port of Cairoplot
Python
4
star
34

nu-servo

Novogorny Urukul Servo
Python
4
star
35

artiq-comtools

Lightweight ARTIQ communication tools
Python
4
star
36

bugs

Old Milkymist repos. Only kept for historical purposes :)
4
star
37

autotest-m1

Automated testing program for the Milkymist One
C
4
star
38

misp

Milkymist Software Platform (experimental)
C
4
star
39

extras-m1

JTAG adapter, leaflet, case CAD files, ...
Prolog
4
star
40

elf2flt-lm32

elf2flt with LM32 architecture support
Shell
4
star
41

datasheets-m1

Datasheets for the parts of the "Milkymist One" board
3
star
42

compiler-rt-lm32

LLVM compiler-rt with LM32 support
C
3
star
43

flickernoise-handbook

Handbook for the Flickernoise VJ application
3
star
44

clang-demos

Sample programs to demonstrate Clang/LLVM on LM32
Assembly
3
star
45

buildbot-config

Internal Buildbot configuration for M-Labs projects. Superseded by https://git.m-labs.hk/m-labs/nix-scripts
Python
3
star
46

drtio_transceiver_test

Transceiver test and demonstration for ARTIQ DRTIO
Python
3
star
47

phaser

Jupyter Notebook
2
star
48

mixxeo-mech

Mixxeo mechanical design
IDL
2
star
49

bscan_spi_kc705

Gateware to allow JTAG serial flash programming on KC705 with xc3sprog
VHDL
2
star
50

artiq-hardware

ARTIQ hardware project
TeX
2
star
51

migen-extradoc

More Migen documentation and tutorials
TeX
2
star
52

novatech409b

ARTIQ controller for the Novatech 409B DDS
Python
1
star
53

aq_ni6733

ARTIQ NDSP for NI 6733 DAC systems (untested/experimental)
Python
1
star
54

conda-recipes

Recipes for conda packages required by M-Labs software
Batchfile
1
star
55

thorlabs_tcube

ARTIQ controller for Thorlabs Tcube devices
Python
1
star
56

cossin

cos(z), sin(z) generator in migen using block ROM and linear interpolation
Jupyter Notebook
1
star
57

ethernet-yakshaving

Python
1
star
58

sayma_test

Test designs for Sayma boards (ddr3, drtio, amc-rtm link, jesd204b)
Python
1
star