verilog-with-iverilog-gtkwave
v0.3.0
Published
A Visual Studio Code extension for compiling Verilog modules with Iverilog and simulating results with GTKWave.
Maintainers
Readme
verilog-with-iverilog-gtkwave
English
This project is a Visual Studio Code extension that allows users to easily compile Verilog modules using iverilog and visualize the simulation results with gtkwave.
Features
- One-click compilation: Compile Verilog modules directly from the editor title bar
- Directory-wide compilation: Automatically compiles all Verilog files in the same directory
- Verilog File Manager: Left sidebar tree view to manage which files are included in compilation
- Selective compilation: Choose which Verilog files to include or exclude from compilation
- Testbench detection: Automatically identifies and marks testbench files based on file naming conventions
- Customizable output directory: Configure where compiled files are stored
- Integrated simulation: Launch
gtkwaveautomatically to display simulation results - Flexible tool paths: Configure custom paths for
iverilogandgtkwave - Terminal integration: Option to run commands in VS Code's integrated terminal
- Multi-language support: English and Simplified Chinese interface
- Automatic file detection: Supports both
.vand.vhfile extensions
Requirements
- Iverilog: Verilog compiler and simulator
- GTKWave: Waveform viewer for VCD files
- VS Code: Version 1.50.0 or higher
Installation
1. From Source
Clone the repository:
git clone https://github.com/superphosphate/verilog-with-iverilog-gtkwave.gitNavigate to the project directory:
cd vscode-iverilog-gtkwaveInstall dependencies:
npm installCompile the extension:
npm run compileOpen the project in Visual Studio Code:
code .Press
F5to run the extension in a new Extension Development Host window
2. From Github Releases
- Go to the Github Releases page
- Download the latest
.vsixfile - Install the downloaded
.vsixfile in VS Code
3. From NPM Repository
Download the source code from npm using the following command:
npm i -D verilog-with-iverilog-gtkwaveFollow the installation steps from From Source.
Usage
Verilog File Manager
The extension adds a "Verilog Files" tree view to the Explorer sidebar that shows all Verilog files in your workspace:
- Green checkmark (✅): File is enabled for compilation
- Red X (❌): File is disabled from compilation
- "(testbench)" label: Automatically detected testbench files
- Click on file name: Opens the file in the editor
- Right-click menu: Toggle compilation status
Tree View Controls:
- Refresh button: Rescan workspace for Verilog files
- Enable All button: Enable all files for compilation
- Disable All button: Disable all files from compilation
Using Editor Title Bar Buttons
- Open a Verilog file (
.vor.vh) in VS Code - You'll see two buttons in the editor title bar:
- Compile button (▶️): Compiles the current module using enabled files from the tree view
- Simulate button (🐛): Runs the simulation and opens GTKWave
Using Command Palette
- Open a Verilog file in the editor
- Press
Ctrl+Shift+P(orCmd+Shift+Pon Mac) to open the command palette - Type and select:
Compile Verilog Moduleto compile the current moduleSimulate with GTKWaveto run simulation and view results
Workflow
- Write your Verilog code: Create your modules and testbenches
- Manage files: Use the tree view to enable/disable files for compilation
- Compile: Click the compile button or use the command palette
- Simulate: Click the simulate button to run the testbench
- View waveforms: GTKWave will open automatically with the generated VCD file
Configuration
Configure the extension through VS Code settings (File > Preferences > Settings):
Tool Paths
iverilog.path: Path to the Iverilog executable (default:/usr/bin/iverilog)gtkwave.path: Path to the GTKWave executable (default:/usr/bin/gtkwave)
Output Settings
iverilog.outputDirectory: Directory for compiled files (leave empty to use source directory)- Supports absolute paths:
C:\verilog_outputor/home/user/verilog_output - Supports relative paths:
./output,../build,output/debug - Relative paths are resolved relative to workspace root (if available) or source file directory
- Supports absolute paths:
Interface Settings
iverilog.language: Language setting (auto,en,zh-cn)iverilog.useTerminal: Use integrated terminal for commands (default:true)iverilog.useTreeView: Use tree view to manage compilation files (default:true)
Example Configuration
{
"iverilog.path": "C:\\iverilog\\bin\\iverilog.exe",
"gtkwave.path": "C:\\gtkwave\\bin\\gtkwave.exe",
"iverilog.outputDirectory": "./build/verilog",
"iverilog.language": "en",
"iverilog.useTerminal": true,
"iverilog.useTreeView": true
}Troubleshooting
Common Issues
"Command not found" errors: Ensure
iverilogandgtkwaveare installed and in your PATHCompilation fails: Check that all required Verilog files are in the same directory
No VCD file generated: Ensure your testbench includes VCD dump commands:
initial begin $dumpfile("wave.vcd"); $dumpvars(0, testbench); end
Platform-Specific Notes
- Windows: Use full paths with
.exeextensions - Linux/macOS: Standard package manager installations should work out of the box
Contributing
Contributions are welcome! Please feel free to:
- Submit pull requests for new features or bug fixes
- Open issues for bugs or feature requests
- Improve documentation
- Add support for additional Verilog tools
License
This project is licensed under the LGPL v3.0 License. See the LICENSE file for more details.
中文
这是一个 Visual Studio Code 扩展项目,让用户能够轻松使用 iverilog 编译 Verilog 模块,并使用 gtkwave 可视化仿真结果。
功能特性
- 一键编译:直接从编辑器标题栏编译 Verilog 模块
- 目录级编译:自动编译同一目录下的所有 Verilog 文件
- 自定义输出目录:配置编译文件的存储位置
- Verilog 文件管理器:位于左侧边栏树视图,用于管理在编译中包含哪些文件
- 选择性编译:选择要包含或排除在编译中的 Verilog 文件
- 测试平台检测:基于文件名,自动识别并标记测试平台文件
- 集成仿真:自动启动
gtkwave显示仿真结果 - 灵活的工具路径:为
iverilog和gtkwave配置自定义路径 - 终端集成:可选择在 VS Code 集成终端中运行命令
- 多语言支持:支持英文和简体中文界面
- 自动文件检测:支持
.v和.vh文件扩展名
系统要求
- Iverilog:Verilog 编译器和仿真器
- GTKWave:VCD 文件的波形查看器
- VS Code:版本 1.50.0 或更高
安装方法
1. 从源码安装
克隆仓库:
git clone https://github.com/superphosphate/verilog-with-iverilog-gtkwave.git进入项目目录:
cd vscode-with-iverilog-gtkwave安装依赖:
npm install编译扩展:
npm run compile在 Visual Studio Code 中打开项目:
code .按
F5在新的扩展开发宿主窗口中运行扩展
2. 从Github Releases安装
- 访问 Github Releases页面
- 下载最新的
.vsix文件 - 在 VS Code 中安装下载的
.vsix文件
3. 从npm安装
使用以下命令从npm下载源码:
npm install -g verilog-with-iverilog-gtkwave按照 从源码安装 的步骤进行之后的安装步骤。
使用方法
Verilog 文件管理器
该扩展在资源管理器侧边栏中添加了一个“Verilog Files”视图,显示工作区中的所有 Verilog 文件:
- √: 文件已启用编译
- X: 文件已禁用编译
- "(testbench)" 标签: 自动检测到的测试平台文件
- 单击文件名: 在编辑器中打开文件
- 右键菜单: 切换编译状态
视图控件:
- 刷新按钮: 重新扫描工作区中的 Verilog 文件
- 启用所有按钮: 启用所有文件进行编译
- 禁用所有按钮: 禁用所有文件的编译
使用编辑器标题栏按钮
- 在 VS Code 中打开 Verilog 文件(
.v或.vh) - 在编辑器标题栏中会看到两个按钮:
- 编译按钮:编译当前模块和目录中的所有 Verilog 文件
- 仿真按钮:运行仿真并打开 GTKWave
使用命令面板
- 在编辑器中打开 Verilog 文件
- 按
Ctrl+Shift+P(Mac 上为Cmd+Shift+P)打开命令面板 - 输入并选择:
编译 Verilog 模块来编译当前模块使用 GTKWave 模拟来运行仿真并查看结果
工作流程
- 编写 Verilog 代码:创建您的模块和测试台
- 管理文件:使用树视图启用/禁用要编译的文件
- 编译:点击编译按钮或使用命令面板
- 仿真:点击仿真按钮运行测试台
- 查看波形:GTKWave 将自动打开生成的 VCD 文件
配置设置
通过 VS Code 设置配置扩展(文件 > 首选项 > 设置):
工具路径
iverilog.path:Iverilog 可执行文件路径(默认:/usr/bin/iverilog)gtkwave.path:GTKWave 可执行文件路径(默认:/usr/bin/gtkwave)
输出设置
iverilog.outputDirectory:编译文件目录(留空则使用源文件目录)- 支持绝对路径:
C:\verilog_output或/home/user/verilog_output - 支持相对路径:
./output、../build、output/debug - 相对路径相对于工作区根目录(如果可用)或源文件目录解析
- 支持绝对路径:
界面设置
iverilog.language:语言设置(auto、en、zh-cn)iverilog.useTerminal:使用集成终端执行命令(默认:true)
配置示例
{
"iverilog.path": "C:\\iverilog\\bin\\iverilog.exe",
"gtkwave.path": "C:\\gtkwave\\bin\\gtkwave.exe",
"iverilog.outputDirectory": "./build/verilog",
"iverilog.language": "zh-cn",
"iverilog.useTerminal": true
}故障排除
常见问题
"找不到命令"错误:确保
iverilog和gtkwave已安装并在 PATH 中编译失败:检查所有必需的 Verilog 文件是否在同一目录中
未生成 VCD 文件:确保测试台包含 VCD 转储命令:
initial begin $dumpfile("wave.vcd"); $dumpvars(0, testbench); end
平台特定说明
- Windows:使用带
.exe扩展名的完整路径 - Linux/macOS:标准包管理器安装应该可以直接使用
贡献
欢迎贡献!您可以:
- 为新功能或错误修复提交拉取请求
- 为错误或功能请求打开问题
- 改进文档
- 添加对其他 Verilog 工具的支持
许可证
本项目采用 LGPL v3.0 许可证。详细信息请参见 LICENSE 文件。
