Repository for my Verilog assignment solutions plus a small Python automation helper. This is a showcase repository for the automation scripts, as well as my Verilog assignments solutions for Computer Organizations course offered by Sukarn Aggrawal, in my final year of Bachelor of Science.
| Script | Purpose |
|---|---|
verilog_automation.py |
Core automation: compile (iverilog), simulate (vvp), capture terminal (optional termshot), parse VCD, render GTKWave‑style waveform PNGs with annotated values. |
create_config.py |
Convenience generator: scans assignment folders and writes a JSON config listing .v files. |
vcd_info.py |
Raw VCD introspection utility (adapted from vcdvcd examples) to inspect structure/signals. |
test_termshot.py (optional) |
Quick check that termshot binary is in PATH. |
ExecuteVerliog.ps1 |
Simple PowerShell helper: compile provided Verilog sources with iverilog, run with vvp, optionally open the .vcd in GTKWave (-Plot). Useful for quick ad‑hoc runs on Windows. |
- Develop & quick test: On Windows, iterate rapidly using
ExecuteVerilog.ps1inside the assignment folder. Example:./ExecuteVerilog.ps1 -Files q1.v(add-Plotif you want to open GTKWave manually and have it installed). - Generate artifacts: After finishing (or when you want polished artifacts), run the Python automation with
verilog_automation.py <assignment>.jsonunder WSL/Linux/macOS. This produces the terminal screenshot (*_terminal.png) viatermshot(requires that binary in PATH) and waveform image (*_waveform.png). Windows native PowerShell typically cannot capture terminal images; WSL is recommended. - Bundle for submission: Use
BundleHomework.ps1 -Assignment <folder>to create<folder>_submission.zipcontaining all.v(and any.pdf) files. This relies on7zbeing installed and available in PATH.
Notes:
- Ensure the JSON config lists each Verilog source you need processed; regenerate with
create_config.pyif files are updated/added. - If
termshotis unavailable the automation will skip terminal PNG generation but still create waveform images (assuming VCD dumped). - Use WSL for a smoother toolchain if you're primarily on Windows (easier to install
termshot,gtkwave, and Python packages).
<repo_root>/
Asg1/ # Assignment folder (one per set)
q1.v
imgs/ # Generated images (terminal + waveform)
config/
Asg1.json # Generated config (one per assignment)
verilog_automation.py
create_config.py
vcd_info.py
requirements.txt
README.md
Runtime:
- Python 3.8+ (virtual env recommended)
- Packages:
matplotlib,vcdvcd(install viapip install -r requirements.txt) - Icarus Verilog (
iverilog,vvp) in PATH
Optional:
termshot(terminal screenshots) – https://github.com/homeport/termshotgtkwave(manual waveform viewing, not required for PNG export)wsl(if on Windows, for easier toolchain setup)
Automatically (all assignments with .v files):
python create_config.py <assignment_folder>Or hand‑write a minimal one (defaults in create_config.py):
{
"folder": "Asg1",
"files": [ { "name": "q1.v" } ]
}python verilog_automation.py config/Asg1.jsonOutputs land in Asg1/imgs/:
*_terminal.png– terminal run (iftermshotavailable)*_waveform.png– dark waveform with green traces + inline bin values
If you just want a fast manual compile/run (and optionally open GTKWave) without the Python pipeline, use the legacy script:
# Compile & simulate q1.v (produces q1.vvp and runs it)
./ExecuteVerliog.ps1 -Files q1.v
# Compile multiple files then open GTKWave on resulting q1.vcd
./ExecuteVerliog.ps1 -Files q1.v q1_tb.v -PlotThe Python automation is more feature‑rich (screenshots, annotated PNG waveforms); the PowerShell script remains for quick interactive edits.
| Field | Meaning | Default |
|---|---|---|
| folder | Assignment directory | — (required) |
| files[] | Array of file objects | — |
| files[].name | Verilog source | required |
| files[].vcd_file | VCD filename | <basename>.vcd |
| files[].variables | Limit signals plotted | all |
| files[].module | Module prefix to match | TEST |
| files[].plot | Enable waveform plotting | true |
- Waveform renderer applies a compact GTKWave‑like style.
- Multi‑bit values auto‑shown in hex when width multiple of 4, otherwise binary.
- Timing axis shown only on last subplot.
- Annotations are centred to avoid changing layout.
iverilog: command not found→ install Icarus Verilog / fix PATH- Missing waveforms → check
$dumpfile/$dumpvarsin testbench - No terminal PNG → install
termshotor skip - Empty plot → verify
modulematches hierarchical prefix in VCD