fpga-stuff ========== Just a playground for me to figure out FPGAs, Verilog, etc. I found the [TinyFPGA BX](https://www.crowdsupply.com/tinyfpga/tinyfpga-ax-bx#products) I had bought a while ago, so I'm using that with one of my [Mini-I/O 16](https://www.tindie.com/products/salfter/mini-io-16/) boards (of which I should finish assembling the latest batch and put them back up for sale :-) ), so most of the code targets that board for synthesis with the open-source [Yosys](https://yosyshq.net/yosys/)/[nextpnr](https://github.com/YosysHQ/nextpnr)/[icestorm](https://github.com/YosysHQ/icestorm) toolchain. Some (slightly) older projects use [Icarus Verilog](https://github.com/steveicarus/iverilog) for simulation, but the [tutorial](https://zipcpu.com/tutorial/) I'm currently following uses [Verilator](https://www.veripool.org/verilator/). Before I found my TinyFPGA BX, I was considering picking up an UPduino. That's why there are some UPduino-related bits in here. You might find the tinyfpga-template useful for your own projects; it's the icestorm template from [the TinyFPGA BX repo](https://github.com/tinyfpga/TinyFPGA-BX), modified to use nextpnr instead of arachne-pnr and with Verilator support added (use ```make verilate``` to simulate). Build Notes (Arch Linux) ------------------------ It's pretty straightforward if you have AUR enabled: ```yay -S --noconfirm yosys nextpnr icestorm verilator``` should do the trick. This also applies to Arch on WSL, but uploading bitstreams to the TinyFPGA BX is a bit tricky. USB passthrough needs to be set up according to [this page](https://learn.microsoft.com/en-us/windows/wsl/connect-usb). When you issue the ```usbipd attach``` command, though, the reset button on the board needs to be pressed after the board is disconnected from Windows...listen for the disconnect sound after you hit Enter on the command. Otherwise, the board never gets connected to WSL. I suspect it's a bit of weirdness in the TinyFPGA BX USB bootloader. Build Notes (Windows) --------------------- WSL works (with the caveat regarding programming described above), but a native toolchain can be installed with [MSYS2](https://www.msys2.org/): ```pacman -S --noconfirm git make mingw-w64-ucrt-x86_64-yosys mingw-w64-ucrt-x86_64-nextpnr mingw-w64-ucrt-x86_64-icestorm mingw-w64-ucrt-x86_64-verilator``` iverilog and gtkwave are also available if you need them (and gtkwave won't need an X server): ```pacman -S --noconfirm git make mingw-w64-ucrt-x86_64-iverilog mingw-w64-ucrt-x86_64-gtkwave``` To enable MSYS2 within VSCodium/VSCode terminals, [this](https://www.msys2.org/docs/ides-editors/) was useful. Verilator should be called with ```-CFLAGS -DVL_TIME_CONTEXT``` in the options to avoid link errors. This won't break Verilator on Linux AFAICT. I haven't gotten tinyprog to install within MSYS2. Instead, install [Python](https://www.python.org/downloads/windows/), pop open a cmd.exe or PowerShell window, and issue ```pip install tinyprog```. The executable will be located somewhere like ```%AppData%\..\Local\Programs\Python\Python313\Scripts```. Translate this to a UN*X-style path (on my computer, it was ```/c/Users/salfter/AppData/Local/Programs/Python/Python313/Scripts```) and add it to your PATH.