Duration: 1 week
Complexity: Beginner
Goal: Set up development environment and verify installation
This module covers the complete setup of your verification environment, including all required tools and dependencies. By the end of this module, you should have a working environment capable of running pyuvm testbenches.
This project includes automated installation scripts to simplify the setup process. You can use these scripts to install all tools automatically, or install them manually using the instructions in each section.
Quick Start (All-in-One Installation):
# Make scripts executable (Linux/Mac/WSL)
chmod +x scripts/*.sh
# Install all tools with default settings
./scripts/module0.sh
# Or install with custom options
./scripts/module0.sh --verilator-mode submodule --cocotb-mode pip --pyuvm-mode pipIndividual Tool Installation:
- Verilator:
./scripts/install_verilator.sh [--from-submodule|--system|--source] - cocotb:
./scripts/install_cocotb.sh [--pip|--from-submodule] [--venv DIR] - pyuvm:
./scripts/install_pyuvm.sh [--pip|--from-submodule] [--venv DIR]
Uninstallation:
- Uninstall all: Use individual uninstall scripts or remove tools manually
- Verilator:
./scripts/uninstall_verilator.sh [--system] [--keep-submodule] - cocotb:
./scripts/uninstall_cocotb.sh [--venv DIR] [--keep-submodule] - pyuvm:
./scripts/uninstall_pyuvm.sh [--venv DIR] [--keep-submodule]
For detailed usage of each script, see the corresponding installation sections below.
- Clone the repo and read
docs/MODULE0.mdfor toolchain expectations (GCC/Clang, Python 3.10+, Git, Make) - Confirm you have build essentials for Verilator (
sudo apt install build-essentialon Debian/Ubuntu) before running install scripts - Decide install modes: Verilator (
submodule/system/source), cocotb/pyuvm (piporsubmodule) — defaults work for most learners - Plan for a project-local venv at
.venv; activate it (source .venv/bin/activate) before any Python checks - No RTL or simulation in this module — success means every tool probe passes before Module 1
scripts/module0.sh— orchestrator for Verilator, cocotb, and pyuvm install plus verification probesscripts/install_verilator.sh— builds or links Verilator per--verilator-modescripts/install_cocotb.sh— installs cocotb into.venvor submodule treescripts/install_pyuvm.sh— installs pyuvm and pins course Python dependenciesdocs/MODULE0.md— assessment checklist mapping environment readiness to course progressrequirements.txt/pyproject.toml— dependency versions consumed by pip install paths
- Course root:
docs/,moduleN/,scripts/moduleN.sh,media/moduleN/for slides and video - Python 3.10+ virtual environment (
.venv) holds cocotb, pyuvm, and course dependencies - Verilator compiles RTL when modules include
dut/; cocotb bridges Python testbenches to the simulator - Orchestrator
scripts/module0.shinstalls and verifies Verilator, cocotb, and pyuvm in order
- Bottom layer: OS, compiler (GCC/Clang), Make/Ninja, Git
- Simulator layer: Verilator (default) produces fast cycle-accurate models from SystemVerilog/Verilog
- Testbench layer: cocotb (coroutine-driven) and pyuvm (UVM 1.2 in Python) share the same venv
- Artifacts: logs under module runs, optional VCD/FST waveforms from Make targets in later modules
- Install:
module0.sh→ dependency scripts → venv population → version probes (no compile/sim/check loop yet) - Build: not applicable — no DUT or Makefile targets in Module 0
- Sim: not applicable — cocotb/Verilator coupling is validated only via import and
--versionprobes - Check:
--verify-onlyaggregates pass/fail; all three tools must report OK before Module 1 labs
- No DUT or UVM hierarchy — focus is reproducible environment setup
- Later modules attach Python tests to RTL under
moduleN/dut/ - Self-check only validates tools; functional verification starts in Module 1
- Waveforms, scoreboards, and regression Makefiles appear from Module 1 onward
- Run
./scripts/module0.shfor full install or per-tool flags (--verilator-mode,--cocotb-mode,--pyuvm-mode) ./scripts/module0.sh --verify-onlyconfirmsverilator,cocotb-config, and importablepyuvm- Version probes (
verilator --version,python -c 'import cocotb') catch PATH and venv mistakes early
- Treat install as the first regression: every tool must pass before Module 1 labs
- Re-run
--verify-onlyafter OS updates or submodule pulls - Document failures in install logs; fix one layer at a time (compiler → Verilator → Python packages)
-
- From repo root:
./scripts/module0.sh(or selective--skip-*flags if tools already installed)
- From repo root:
-
- Activate venv:
source .venv/bin/activate
- Activate venv:
-
- Verify:
./scripts/module0.sh --verify-only— expect green checks for Verilator, cocotb, pyuvm
- Verify:
-
- Optional manual probes:
verilator --version,cocotb-config --version,python3 -c 'import pyuvm'
- Optional manual probes:
-
- Record pass in MODULE0 assessment checklist; proceed to Module 1 only when all probes succeed
- Pass criteria: all install scripts succeed and
--verify-onlyreports required tools present - Optional: run a minimal cocotb compile in Module 1 only after Module 0 passes
- Assessment checklist in
docs/MODULE0.mdmaps environment readiness to course progress
-
Operating System Support
- Linux (Ubuntu/Debian, CentOS/RHEL, Fedora)
- macOS (Intel and Apple Silicon)
- Windows (WSL2 recommended)
-
Hardware Requirements
- Minimum 4GB RAM (8GB+ recommended)
- 10GB free disk space
- Multi-core processor recommended
-
Software Prerequisites
- Python 3.8+ (3.10+ recommended)
- Git
- C/C++ compiler (GCC, Clang, or MSVC)
- Make or Ninja build system
-
Python Installation
- Installing Python 3.10+ on Linux
- Installing Python 3.10+ on macOS
- Installing Python 3.10+ on Windows/WSL2
- Verifying Python installation
-
Virtual Environment Management
- Using
venv(Python built-in) - Using
conda(Anaconda/Miniconda) - Using
uvorrye(modern Python package managers) - Best practices for virtual environments
- Using
-
Package Management
- pip basics
- requirements.txt management
- Dependency resolution
-
What is Verilator?
- Open-source Verilog/SystemVerilog simulator
- Fast compilation and simulation
- Integration with cocotb
-
Automated Installation (Recommended)
- Using the installation script:
# Install from git submodule (default - builds from source) ./scripts/install_verilator.sh --from-submodule # Install from system package manager ./scripts/install_verilator.sh --system # Build from source (clones if submodule doesn't exist) ./scripts/install_verilator.sh --source
- The script automatically:
- Checks for existing installations
- Installs system dependencies (build tools, libraries)
- Sets up git submodule in
tools/verilator/ - Builds and installs Verilator
- Verifies the installation
- Using the installation script:
-
Manual Installation Methods
-
Linux Installation
- Ubuntu/Debian:
sudo apt-get install verilator - CentOS/RHEL:
sudo yum install verilatororsudo dnf install verilator - Fedora:
sudo dnf install verilator - Building from source (latest features)
- Ubuntu/Debian:
-
macOS Installation
- Homebrew installation:
brew install verilator - MacPorts installation (alternative)
- Building from source
- Homebrew installation:
-
Windows/WSL2 Installation
- Installing in WSL2 Ubuntu:
sudo apt-get install verilator - Building from source in WSL2
- Verifying installation
- Installing in WSL2 Ubuntu:
-
-
Uninstallation
# Uninstall and remove submodule ./scripts/uninstall_verilator.sh # Uninstall but keep git submodule ./scripts/uninstall_verilator.sh --keep-submodule # Also uninstall system package (if installed via package manager) ./scripts/uninstall_verilator.sh --system
-
Verification Steps
- Check Verilator version:
verilator --version - Run simple Verilator test
- Verify compilation works
- Check Verilator version:
-
What is cocotb?
- Coroutine-based testbench framework
- Python testbenches for hardware
- Simulator abstraction layer
-
Automated Installation (Recommended)
- Using the installation script:
# Install via pip in virtual environment (default) ./scripts/install_cocotb.sh --pip --venv .venv # Install from git submodule (development/editable mode) ./scripts/install_cocotb.sh --from-submodule --editable --venv .venv # Install in system Python (not recommended) ./scripts/install_cocotb.sh --pip --no-venv
- The script automatically:
- Creates/uses virtual environment (default:
.venv) - Sets up git submodule in
tools/cocotb/(if using submodule mode) - Installs dependencies
- Installs cocotb (via pip or from source)
- Verifies the installation
- Creates/uses virtual environment (default:
- Using the installation script:
-
Manual Installation Methods
- pip installation (recommended):
python3 -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate pip install cocotb
- Development installation from source
- Version pinning for stability:
pip install cocotb==2.0.0
- pip installation (recommended):
-
Uninstallation
# Uninstall from virtual environment (default) ./scripts/uninstall_cocotb.sh --venv .venv # Uninstall from system Python ./scripts/uninstall_cocotb.sh --no-venv # Keep git submodule ./scripts/uninstall_cocotb.sh --keep-submodule
-
Simulator Configuration
- Verilator configuration
- Icarus Verilog configuration (alternative)
- ModelSim/QuestaSim configuration (if available)
- GHDL configuration (VHDL support)
-
Environment Variables
COCOTB_REDUCED_LOG_FMTMODULEandTESTCASESIMvariable for simulator selection
-
Verification Steps
- Import cocotb successfully:
python3 -c "import cocotb; print(cocotb.__version__)" - Run simple cocotb test
- Verify simulator integration
- Import cocotb successfully:
-
What is pyuvm?
- Python implementation of UVM 1.2
- Works with cocotb
- Full UVM methodology support
-
Automated Installation (Recommended)
- Using the installation script:
# Install via pip in virtual environment (default) ./scripts/install_pyuvm.sh --pip --venv .venv # Install from git submodule (development/editable mode) ./scripts/install_pyuvm.sh --from-submodule --editable --venv .venv # Install in system Python (not recommended) ./scripts/install_pyuvm.sh --pip --no-venv
- The script automatically:
- Creates/uses virtual environment (default:
.venv) - Sets up git submodule in
tools/pyuvm/(if using submodule mode) - Installs dependencies
- Installs pyuvm (via pip or from source)
- Verifies the installation
- Creates/uses virtual environment (default:
- Using the installation script:
-
Manual Installation Methods
- pip installation:
source .venv/bin/activate # Activate virtual environment pip install pyuvm
- Installation from source (development)
- Version selection and compatibility:
pip install pyuvm==2.9.0
- pip installation:
-
Uninstallation
# Uninstall from virtual environment (default) ./scripts/uninstall_pyuvm.sh --venv .venv # Uninstall from system Python ./scripts/uninstall_pyuvm.sh --no-venv # Keep git submodule ./scripts/uninstall_pyuvm.sh --keep-submodule
-
Dependencies
- Understanding pyuvm dependencies
- Resolving dependency conflicts
- Updating pyuvm
-
Verification Steps
- Import pyuvm successfully:
python3 -c "import pyuvm; print(pyuvm.__version__)" - Check pyuvm version
- Run simple pyuvm test
- Verify UVM classes available
- Import pyuvm successfully:
-
Recommended IDEs
- VS Code with Python extension
- PyCharm (Community or Professional)
- Vim/Neovim with LSP
- Emacs with Python support
-
VS Code Configuration
- Python extension setup
- Pylance/Pyright configuration
- Debugging configuration
- Task runner setup for simulations
- Extension recommendations
-
PyCharm Configuration
- Python interpreter setup
- Virtual environment configuration
- Run configurations for tests
- Debugging setup
-
Editor Configuration
- Python formatting (Black, Ruff)
- Linting (pylint, flake8, ruff)
- Type checking (mypy, pyright)
- Code formatting on save
-
Directory Structure
- Source code organization
- Test directory structure
- DUT (Design Under Test) organization
- Configuration files
tools/directory for git submodules (Verilator, cocotb, pyuvm)
-
Git Submodules Management
- Tools are managed as git submodules in the
tools/directory - Initialize submodules:
./scripts/init_submodules.shorgit submodule update --init --recursive - Update submodules:
./scripts/update_submodules.shorgit submodule update --remote - Add new submodule:
./scripts/add_submodule.sh <repo_url> <path> - Remove submodule:
./scripts/remove_submodule.sh <path>
- Tools are managed as git submodules in the
-
Makefile/Configuration
- Simple Makefile for running tests
- pytest configuration
- cocotb Makefile setup
- Environment variable management
-
Version Control
- Git initialization
- .gitignore for Python and simulation (include
.venv/,__pycache__/, build artifacts) - Initial commit structure
- Git submodules in
.gitmodulesfile
-
Prerequisites
- Ensure all tools are installed:
./scripts/module0.sh --verify-only - Activate virtual environment:
source .venv/bin/activate(if using venv) - Verify tools are accessible
- Ensure all tools are installed:
-
Simple DUT Creation
- Basic Verilog module (e.g., AND gate)
- Simple testbench structure
-
cocotb Test
- Basic cocotb test structure
- Clock generation
- Signal driving and reading
- Running the test (requires Verilator and cocotb to be installed)
-
pyuvm Test
- First UVM test class
- Basic UVM phases
- Running pyuvm test (requires cocotb and pyuvm to be installed)
- Understanding output
-
Python Issues
- Python version conflicts
- Virtual environment activation problems
- Package installation failures
-
Verilator Issues
- Compilation errors
- Missing dependencies
- Version compatibility
- Path issues
-
cocotb Issues
- Simulator not found
- Import errors
- Environment variable problems
- Module loading issues
-
pyuvm Issues
- Import errors
- Version compatibility
- Dependency conflicts
-
IDE Issues
- Python interpreter not found
- Import resolution problems
- Debugging not working
- Python 3.10+ installed and working
- Virtual environment created and activated (or use
./scripts/module0.shwhich creates it automatically) - Verilator installed and verified
- Using script:
./scripts/install_verilator.sh --from-submodule - Verify:
verilator --version
- Using script:
- cocotb installed and verified
- Using script:
./scripts/install_cocotb.sh --pip --venv .venv - Verify:
python3 -c "import cocotb; print(cocotb.__version__)"
- Using script:
- pyuvm installed and verified
- Using script:
./scripts/install_pyuvm.sh --pip --venv .venv - Verify:
python3 -c "import pyuvm; print(pyuvm.__version__)"
- Using script:
- All tools verified together:
./scripts/module0.sh --verify-only - IDE configured and working
- First test runs successfully
- Can create and run simple testbench
- Understand basic project structure
- Know how to get help when stuck
./scripts/module0.sh— install Verilator, cocotb, and pyuvm with default modes into.venv./scripts/module0.sh --verilator-mode system --cocotb-mode pip --pyuvm-mode pip— explicit mode selection./scripts/module0.sh --skip-verilator— refresh Python packages only when Verilator already present
./scripts/module0.sh --verify-only— probeverilator,cocotb-config, andimport pyuvmwithout mutating the systemverilator --version— confirms simulator on PATH after submodule or system installpython3 -c "import cocotb, pyuvm; print('OK')"— quick venv sanity check outside the orchestrator
which verilator && cocotb-config --version— separate PATH issues from Python import failuressource .venv/bin/activate— required before manual Python probes if--no-venvwas not used- Re-run
--verify-onlyafter OS updates, submodule pulls, or venv recreation
By the end of this module, you should be able to:
- Install and configure all required tools
- Set up a Python virtual environment
- Install and verify Verilator
- Install and verify cocotb
- Install and verify pyuvm
- Configure your IDE for verification work
- Create a basic project structure
- Run a simple verification test
- Troubleshoot common installation issues
-
Installation Verification
- Use
./scripts/module0.sh --verify-onlyto check all installations - Or verify each tool independently:
- Verilator:
verilator --version - cocotb:
python3 -c "import cocotb; print(cocotb.__version__)" - pyuvm:
python3 -c "import pyuvm; print(pyuvm.__version__)"
- Verilator:
- Document any issues encountered
- Use
-
Environment Setup
- Option A (Automated): Run
./scripts/module0.shto install everything - Option B (Manual):
- Create a virtual environment:
python3 -m venv .venv - Activate it:
source .venv/bin/activate - Install tools individually using the scripts or manually
- Create a virtual environment:
- Create a requirements.txt file with installed packages:
source .venv/bin/activate pip freeze > requirements.txt
- Option A (Automated): Run
-
First Test
- Create a simple Verilog module
- Write a cocotb test for it
- Run the test successfully
-
IDE Configuration
- Set up your preferred IDE
- Configure Python interpreter to use
.venv/bin/python - Test debugging functionality
-
Project Structure
- Create a well-organized project structure
- Set up version control (git submodules for tools are already managed)
- Create initial documentation
- Understand the
tools/directory structure (git submodules)
- Can install all required tools independently
- Can set up Python virtual environment
- Can verify Verilator installation
- Can verify cocotb installation
- Can verify pyuvm installation
- Can configure IDE for verification work
- Can create and run a simple test
- Can troubleshoot common issues
- Understands project structure best practices
After completing this module, proceed to Module 1: Python and Verification Basics to learn the fundamental concepts needed for verification.
-
Installation Scripts:
- All scripts are located in the
scripts/directory - Run
./scripts/module0.sh --helpfor detailed usage - Individual script help:
./scripts/install_<tool>.sh --help
- All scripts are located in the
-
Verilator Documentation: https://verilator.org/
-
cocotb Installation Guide: https://docs.cocotb.org/en/stable/install.html
-
pyuvm Installation Guide: https://pyuvm.readthedocs.io/en/latest/installation.html
-
Python Virtual Environments: https://docs.python.org/3/tutorial/venv.html
-
Git Submodules: https://git-scm.com/book/en/v2/Git-Tools-Submodules