|
| 1 | +<img src="images/uart01_chip.svg" title="UART01-V Chip in Verilog" align="right" width="6.3%"> |
| 2 | +<br /> |
| 3 | +<br /> |
| 4 | + |
1 | 5 | # uart-verilog
|
2 | 6 |
|
3 |
| -8 bit UART includes tests, documentation, timing diagrams |
| 7 | +8 bit UART with tests, documentation, timing diagrams |
| 8 | + |
| 9 | +  For simulation and Electronic Design Automation |
| 10 | + |
| 11 | +#### Parameters |
4 | 12 |
|
5 |
| -The baud rate is parametrized; e.g.: |
| 13 | +Selected rates, e.g.: |
| 14 | +``` |
| 15 | +CLOCK_RATE = 12000000 |
| 16 | +``` |
6 | 17 | ```
|
7 | 18 | BAUD_RATE = 115200
|
8 | 19 | ```
|
| 20 | +Mode 8-N-1 or 8-N-2 (8 bits data, no parity, 1 or 2 stop bits). The default 2 stop bits: |
| 21 | +``` |
| 22 | +TURBO_FRAMES = 0 |
| 23 | +``` |
| 24 | +  trades off maximum bandwidth against more reliable communication |
| 25 | + |
| 26 | + |
| 27 | + |
| 28 | +#### Test benches |
| 29 | + |
| 30 | +Functional. |
| 31 | + |
| 32 | +  Direct to [the tests](tests/) |
| 33 | + |
| 34 | +Some text. |
| 35 | + |
| 36 | +#### Running the tests on your machine |
| 37 | + |
| 38 | +The test benches can be run using the open source simulator Icarus Verilog: [Installation][link-iverilogi], [Getting Started][link-iverilogs]. |
| 39 | + |
| 40 | +With it installed, you can run a command like the following that specifies the required input files and one output file (.vvp): |
| 41 | + |
| 42 | + > iverilog -g2012 -I.. -osimout.vvp -D"DUMP_FILE_NAME=\"1.vcd\"" 1.v |
| 43 | + |
| 44 | +  (This is run in the "tests" directory, and ".." thus references the device .v files or .vh files at root level.) |
| 45 | + |
| 46 | +It then requires a second step: Run the Icarus Verilog simulator/runtime to store all signal and timing data to a .vcd file (viewable signal trace): |
| 47 | + |
| 48 | + > vvp simout.vvp |
| 49 | + |
| 50 | +I combine these: |
| 51 | + |
| 52 | + > iverilog -g2012 -I.. -osimout.vvp -D"DUMP_FILE_NAME=\"1.vcd\"" 1.v && timeout 1 >NUL && vvp simout.vvp |
| 53 | + |
| 54 | +GTKWave viewer is used to view the trace (waveforms): [Installation][link-gtkwavei], [Getting Started][link-gtkwaves]. |
| 55 | + |
| 56 | +With GTKWave installed, just click on the .vcd file. However, to persist the view (the duration window, amount of zoom and the particular signals) that you want to see for that test bench, save it as a .gtkw file. The .gtkw file persists and is a consistent view, whereas .vcd, the data, can be regenerated at will. Thus runs can be compared. (If you haven't changed the HDL code, the runs will come out identical.) |
| 57 | + |
| 58 | +<img src="tests/images/13.png" title="Simulation waveform" width="50%"> |
| 59 | + |
| 60 | +#### Topics: Device and circuit simulation |
| 61 | + |
| 62 | +#### Related open source technology for device and circuit simulation: |
| 63 | + |
| 64 | +- [HDLs][link-web-hdls] · Hardware Description Languages |
| 65 | +- [EDA][link-web-eda] · Electronic Design Automation |
| 66 | +- [FPGAs][link-web-fpgas] · Field-Programmable Gate Arrays |
| 67 | + |
| 68 | +#### Related open source technology |
| 69 | + |
| 70 | +[IceChips][link-icechips] devices from 7400 TTL family |
| 71 | + |
| 72 | +[Icestudio][link-icestudio] and Apio built on top of IceStorm, Yosys, nextpnr |
| 73 | + |
| 74 | +[Yosys][link-yosys] synthesis by Claire Wolf |
| 75 | + |
| 76 | +[Icarus Verilog][link-iverilog] simulator by Stephen Williams |
| 77 | + |
| 78 | +[GTKWave][link-gtkwavei] for viewing waveforms |
| 79 | + |
| 80 | +## <!-- --> |
9 | 81 |
|
10 |
| -Mode 8-N-1 or 8-N-2 is parametrized. The designations mean: 8 bits data, no parity, 1 stop bit or 2 stop bits. |
| 82 | +© 2022-2023 Tim Rudy |
11 | 83 |
|
12 |
| -© 2022 Tim Rudy |
| 84 | +[link-icechips]: https://github.com/TimRudy/ice-chips-verilog |
| 85 | +[link-icestudio]: https://icestudio.io |
| 86 | +[link-web-hdls]: https://www.google.com/search?q=Hardware+Description+Languages |
| 87 | +[link-web-eda]: https://www.google.com/search?q=Electronic+Design+Automation |
| 88 | +[link-web-fpgas]: https://www.google.com/search?q=Field-Programmable+Gate+Arrays |
| 89 | +[link-yosys]: https://github.com/YosysHQ/yosys |
| 90 | +[link-iverilog]: http://iverilog.icarus.com |
| 91 | +[link-iverilogi]: https://steveicarus.github.io/iverilog/usage/installation.html |
| 92 | +[link-iverilogs]: https://steveicarus.github.io/iverilog/usage/getting_started.html |
| 93 | +[link-gtkwavei]: http://gtkwave.sourceforge.net |
| 94 | +[link-gtkwaves]: https://gtkwave.sourceforge.net/gtkwave.pdf |
0 commit comments