Skip to content

Latest commit

 

History

History
125 lines (101 loc) · 6.08 KB

2310B.md

File metadata and controls

125 lines (101 loc) · 6.08 KB

Tip 2310B: Setting up cocotb and iverilog on Windows

Prerequisites

Test basic stuff:

  • Check PATH. In Command Prompt just run path. In PowerShell, run echo $env:path. Make sure MSYS2/MingGW bin dirs are in there. For example, on my machine: PATH=...;C:\msys64\usr\bin;C:\msys64\mingw64\bin;C:\msys64\ucrt64\bin;...
  • make --version
    GNU Make 4.4.1
    Built for x86_64-pc-msys
    Copyright (C) 1988-2023 Free Software Foundation, Inc.
    ...
    
  • py --version => Python 3.12.0
  • py -m pip --version => pip 23.2.1 from C:\... (python 3.12)
  • gcc --version
    gcc.exe (Rev1, Built by MSYS2 project) 13.2.0
    Copyright (C) 2023 Free Software Foundation, Inc.
    
  • pacman --version
     .--.                  Pacman v6.0.2 - libalpm v13.0.2
    / _.-' .-.  .-.  .-.   Copyright (C) 2006-2021 Pacman Development Team
    \  '-. '-'  '-'  '-'   Copyright (C) 2002-2006 Judd Vinet
     '--'
    

Steps

cocotb

  1. Create a .venv in your project, if you want, and optionally give it a specific prompt (like venv:myproject). For example:
    • Using VSCode:
      1. CTRL+SHIFT+P, find 'Python: Create Environment'
      2. Choose 'Venv'
      3. If you're using a workspace with multiple projects, choose the project in which you want to make the .venv
      4. Select your Python interpreter
      5. Right-click your project and open a new Integrated Terminal; Activate.ps1 should automatically run and (.venv) will be in the prompt.
    • Using the venv command:
      1. Go into your project directory.
      2. Run py -m venv .venv --prompt venv:myproject
      3. Do: echo '*' >> .venv\.gitignore
      4. Run .\venv\Scripts\Activate.ps1
  2. Before installing the cocotb package directly, check first whether there's a requirements.txt file that includes it.
    • If so, just run py -m pip install -r requirements.txt
    • Otherwise, run: py -m pip install cocotb

iverilog

This assumes you've got pacman installed (my --version is 6.0.2) which probably came as part of MSYS2 (see Prerequisites).

I'm following from here.

  1. List available versions of iverilog by running: pacman -Ss iverilog:
    > pacman -Ss iverilog
    mingw32/mingw-w64-i686-iverilog 1~11.0.r9168.gd480c4d7-1 (mingw-w64-i686-eda)
        Icarus Verilog, is a Verilog simulation and synthesis tool (mingw-w64)
    mingw64/mingw-w64-x86_64-iverilog 1~11.0.r9168.gd480c4d7-1 (mingw-w64-x86_64-eda)
        Icarus Verilog, is a Verilog simulation and synthesis tool (mingw-w64)
    ucrt64/mingw-w64-ucrt-x86_64-iverilog 1~11.0.r9168.gd480c4d7-1 (mingw-w64-ucrt-x86_64-eda)
        Icarus Verilog, is a Verilog simulation and synthesis tool (mingw-w64)
    
  2. Choose the version you want to install. Which one was right for me? When I originally set up MSYS2, it seems I settled on making 'MSYS2 UCRT64' my default shell, so I'll go with the ucrt64 version, though apparently you might be able to install all 3.
  3. Install the package for your chosen version, e.g. pacman -S mingw-w64-ucrt-x86_64-iverilog
  4. After this, iverilog.exe was not in my PATH, but I was able to run it from my MSYS2 UCRT64 shell, and evidently its path is:
    • Windows path: C:\msys64\ucrt64\bin\iverilog.exe
    • Equivalent Unix path: /ucrt64/bin/iverilog So edit Windows env vars and make sure PATH includes your path to ...\ucrt64\bin. I already had C:\msys64\usr\bin and C:\msys64\mingw64\bin but had to add C:\msys64\ucrt64\bin.
  5. Re-launch any shells/terminals. For VSCode, this probably means relaunching the whole app.
  6. Run iverilog -V and it will hopefully spit out version info:
    > iverilog -V
    Icarus Verilog version 12.0 (devel) (s20150603-1391-gd480c4d7d)
    ...
    

Alternative iverilog installers for Windows

For pre-built Windows installers: http://bleyer.org/icarus/

For instructions on building from source: https://iverilog.fandom.com/wiki/Installation_Guide#Compiling_on_MS_Windows_(MinGW)

gtkwave

  1. Search: pacman -Ss gtkwave
  2. Let's go with ucrt64 version again: pacman -S mingw-w64-ucrt-x86_64-gtkwave
  3. Test: gtkwave
  4. GTKWave might appear blurry or oversized if High DPI is used in Windows. While GTKWave is running, right-click it in the taskbar, go to Properties => Compatibility => Settings => Change high DPI settings => then tick Override high DPI scaling behavior and set Scaling performed by: to Application. Launch it again, and it should look much clearer and at a normal size.
  5. Create a .gtkwaverc file. For Windows, per the GTKWave documentation PDF we actually need to create a file called gtkwave.ini in the current working directory (say, of your project, where your VCD file will be written):
    # ~/.gtkwaverc
    
    # Use, for example, the following for generic monospaced-fonts:
    # fontname_signals Monospace 15
    
    fontname_waves Consolas 9
    
    # By making signal names larger, we can make the waveforms taller too:
    fontname_signals Consolas 15
    
    splash_disable 1
    fill_waveform 1
    disable_mouseover 0
    
    # Grid lines are pale blue:
    color_grid 336699
    
    # Z values are light purple:
    color_mid bb33ff
    
    NOTE: You can override this by supplying the -r YourRCFile option to gtkwave. For more gtkwaverc examples, including defining custom hotkeys, see this.

Writing tests

  • See my efforts in 0156