+++
title = "nMigen"
weight = 1
template = "page.html"

[extra]
logo = "images/migen@2x.png"
logo_size = 125
title = "nMigen"
+++


{% layout_centered_content() %}
##### nMigen is a reboot of Migen, a Python toolbox for building complex digital hardware.
{% end %}


nMigen is a reboot of [Migen](@/gateware/migen.md), our metaprogramming-based hardware description language. See the [Migen page](@/gateware/migen.md) for the basic ideas.

Although Migen works very well in production (it is used, for instance, in the [ARTIQ](@/experiment-control/artiq.md) experiment control system, and the <a href="https://www.amarisoft.com/" target="_blank" rel="noopener noreferrer">Amarisoft</a> base stations), its design could be improved in many fundamental ways. 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.

{% layout_text_img(src="images/side-graphic-min.png", alt="", textleft=true, shadow=false) %}


##### Environment

nMigen itself provides the core language, and is complemented by a number of external components. The nmigen-boards package contains definition files for various FPGA boards, providing information such as pin locations and clocks. The nmigen-stdio package provides libraries to interface to common I/O protocols such as I2C and SPI. The nmigen-soc package is a library that provides bus interconnect and configuration and status register (CSR) management. Finally, the HeavyX system uses all the previous components and integrates them into a complete system-on-chip solution, able to run Rust code on the <a href="https://github.com/lambdaconcept/minerva" target="_blank" rel="noopener noreferrer">Minerva RISC-V CPU core</a> entirely written in nMigen.

##### Documentation

Documentation for nMigen and its external components is rather limited at the moment. However, you can follow the <a href="http://blog.lambdaconcept.com/doku.php?id=nmigen:tutorial" target="_blank" rel="noopener noreferrer">tutorial by LambdaConcept</a>, and another <a href="https://github.com/RobertBaruch/nmigen-tutorial" target="_blank" rel="noopener noreferrer">tutorial by Robert Baruch</a>, as well as his video series on building a 6800 CPU on an FPGA with nMigen: <a href="https://www.youtube.com/watch?v=85ZCTuekjGA" target="_blank" rel="noopener noreferrer">part 1</a> <a href="https://www.youtube.com/watch?v=AQOXoKQhG3I" target="_blank" rel="noopener noreferrer">part 2</a> <a href="https://www.youtube.com/watch?v=aLQqOxnVMOQ" target="_blank" rel="noopener noreferrer">part 3</a> <a href="https://www.youtube.com/watch?v=xqMtyCu4lME" target="_blank" rel="noopener noreferrer">part 4</a>.

{% end %}

{% layout_centered_content(min_width=true, force_left=true, bg="background-image: url(/images/stripe.svg); background-repeat: no-repeat; background-size: auto 100%; padding-left: 40px;") %}

##### Code repositories

- <a href="http://github.com/m-labs/nmigen" target="_blank" rel="noopener noreferrer">nmigen</a>
- <a href="http://github.com/m-labs/nmigen-boards" target="_blank" rel="noopener noreferrer">nmigen-boards</a>
- <a href="http://github.com/m-labs/nmigen-stdio" target="_blank" rel="noopener noreferrer">nmigen-stdio</a>
- <a href="http://github.com/m-labs/nmigen-soc" target="_blank" rel="noopener noreferrer">nmigen-soc</a>
- <a href="https://git.m-labs.hk/m-labs/heavyx" target="_blank" rel="noopener noreferrer">heavyx</a>


{% end %}
