3 * links to community <https://nmigen.info/nmigen/latest/tutorial.html>
4 * Useful counter tutorial (gtkwave and verilog) for latest nmigen <https://nmigen.info/nmigen/latest/start.html>
5 * Robert Baruch's nmigen tutorials are really good:
6 <https://github.com/RobertBaruch/nmigen-tutorial>
7 * <https://github.com/GuzTech/ulx3s-nmigen-examples>
8 * <https://github.com/icebreaker-fpga/icebreaker-nmigen-examples>
9 * <https://github.com/kbob/nmigen-examples>
10 * <https://vivonomicon.com/2020/04/14/learning-fpga-design-with-nmigen/54>
11 * <https://www.youtube.com/watch?v=yDJNwxY05-s>
13 # Sanity Check (*You'll need it*) Tutorial - Simulation Waveforms, Verilog, Block Diagram
15 ## Testbench, GTKWave, Verilog Output
17 * nMigen code for counter and testbench here: <https://nmigen.info/nmigen/latest/start.html>
19 1. Create a file called "up_counter.py" containing the 16-bit up counter code from "Implementing a counter" section.
20 1. Create a file called "tb_up_counter.py" containing the testbench from "Testing a counter".
21 1. To the testbench file, add the import statement for the counter module (better get used to separating your sim/stimulus and module classes from the beginning):
23 from up_counter import UpCounter
25 1. Create a file called "conv_to_verilog.py" and copy the code from "Converting a counter" section. Also add the import statement as with the testbench.
27 1. Generate GTKWave .vcd file by running:
29 $python3 tb_up_counter.py
31 1. Launch GTKWave by calling:
33 $gtkwave up_counter.vcd
35 1. Now you should be able to inspect the signals and check counter behaviour (although the test bench also does this).
37 1. To generate the verilog equivalent, call the file we created earlier. The script will create a up_counter.v verilog file.
39 $python3 conv_to_verilog.py
41 ## Block Digram with Yosys
43 1. Open yosys in interactive mode and load the generated verilog file. Calling "show" should generate the diagram .dot file (as a temp file "~/.yosys_show.dot") and open it using xdot. *You may need to install xdot separately with apt*. Xdot is **interactive** (you can click on blocks and nodes!).
46 yosys> read_verilog up_counter.v
49 1. Outside of Yosys, you can run xdot directly:
51 $xdot ~/.yosys_show.dot
53 1. If you want to generate a static image, you can use graphviz's "dot" command to generate an image (for example PNG).
55 $dot ~/.yosys_show.dot -Tpng -o up_counter.png
57 1. Now you can improve your understanding with the nMigen, verilog, and block diagram views side-by-side!
59 [[!img nmigen_verilog_tb.png ]]