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
.
- One-click compilation: Compile Verilog modules directly from the editor title bar
- Directory-wide compilation: Automatically compiles all Verilog files in the same directory
- Customizable output directory: Configure where compiled files are stored
- Integrated simulation: Launch
gtkwave
automatically to display simulation results - Flexible tool paths: Configure custom paths for
iverilog
andgtkwave
- 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
.v
and.vh
file extensions
- Iverilog: Verilog compiler and simulator
- GTKWave: Waveform viewer for VCD files
- VS Code: Version 1.50.0 or higher
-
Clone the repository:
git clone https://github.com/superphosphate/verilog-with-iverilog-gtkwave.git
-
Navigate to the project directory:
cd vscode-iverilog-gtkwave
-
Install dependencies:
npm install
-
Compile the extension:
npm run compile
-
Open the project in Visual Studio Code:
code .
-
Press
F5
to run the extension in a new Extension Development Host window
-
Build the extension package:
npm run prepack
-
Install the generated
.vsix
file in VS Code
- Open a Verilog file (
.v
or.vh
) in VS Code - You'll see two buttons in the editor title bar:
- Compile button (
▶️ ): Compiles the current module and all Verilog files in the directory - Simulate button (🐛): Runs the simulation and opens GTKWave
- Compile button (
- Open a Verilog file in the editor
- Press
Ctrl+Shift+P
(orCmd+Shift+P
on Mac) to open the command palette - Type and select:
Compile Verilog Module
to compile the current moduleSimulate with GTKWave
to run simulation and view results
- Write your Verilog code: Create your modules and testbenches
- 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
Configure the extension through VS Code settings (File > Preferences > Settings
):
iverilog.path
: Path to the Iverilog executable (default:/usr/bin/iverilog
)gtkwave.path
: Path to the GTKWave executable (default:/usr/bin/gtkwave
)
iverilog.outputDirectory
: Directory for compiled files (leave empty to use source directory)- Supports absolute paths:
C:\verilog_output
or/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:
iverilog.language
: Language setting (auto
,en
,zh-cn
)iverilog.useTerminal
: Use integrated terminal for commands (default:true
)
{
"iverilog.path": "C:\\iverilog\\bin\\iverilog.exe",
"gtkwave.path": "C:\\gtkwave\\bin\\gtkwave.exe",
"iverilog.outputDirectory": "./build/verilog",
"iverilog.language": "en",
"iverilog.useTerminal": true
}
- "Command not found" errors: Ensure
iverilog
andgtkwave
are installed and in your PATH - Compilation 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
- Windows: Use full paths with
.exe
extensions - Linux/macOS: Standard package manager installations should work out of the box
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
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 文件
- 自定义输出目录:配置编译文件的存储位置
- 集成仿真:自动启动
gtkwave
显示仿真结果 - 灵活的工具路径:为
iverilog
和gtkwave
配置自定义路径 - 终端集成:可选择在 VS Code 集成终端中运行命令
- 多语言支持:支持英文和简体中文界面
- 自动文件检测:支持
.v
和.vh
文件扩展名
- Iverilog:Verilog 编译器和仿真器
- GTKWave:VCD 文件的波形查看器
- VS Code:版本 1.50.0 或更高
-
克隆仓库:
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
在新的扩展开发宿主窗口中运行扩展
-
构建扩展包:
npm run prepack
-
在 VS Code 中安装生成的
.vsix
文件
- 在 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 文件。