该项目旨在使用 Verilator
和 Cocotb
进行 Verilog 设计的仿真、测试与开发。项目集成了 NVBoard 进行可视化调试,并通过 GTKWave 进行波形分析,结构清晰且易于扩展。
verilog-project-gen/
├── config/ # 配置文件目录
│ └── alu_test.ini # ALU 测试的 INI 配置文件
├── obj_dir/ # Verilator 生成的中间对象目录
├── scripts/ # 实用脚本
│ └── generate_alu_config.py # 用于生成 ALU 配置的 Python 脚本
├── sim_build/ # Cocotb 仿真构建目录
├── src_cxx/ # C++ 源代码目录
│ ├── auto_bind.cpp # 自动生成的 NVBoard 引脚绑定代码
│ └── main.cpp # 仿真主程序入口
├── src_rtl/ # Verilog 源代码目录
│ ├── alu.v # ALU Verilog 模块
│ ├── pins.nxdc # NVBoard 引脚配置
│ └── top.v # 顶层 Verilog 模块
├── tests/ # Python 测试脚本目录
│ └── test_alu.py # 针对 ALU 模块的 Cocotb 测试脚本
├── wave/ # 波形文件和 GTKWave 配置
│ ├── dump.vcd # 仿真生成的波形文件
│ └── gtks.gtkw # GTKWave 配置文件
├── .gitignore
├── Makefile
└── README.md
-
仿真与测试:
- 使用
Verilator
作为主要的 Verilog 仿真工具。 - 基于
Cocotb
的 Python 测试平台,支持高级验证功能。
- 使用
-
波形分析:
- 仿真后生成波形文件(
dump.vcd
)。 - 集成
GTKWave
进行信号可视化。
- 仿真后生成波形文件(
-
NVBoard 支持:
- 使用 NVBoard 进行交互式硬件调试。
- Verilator:Verilog 仿真器,用于编译和运行设计。
- Cocotb:基于 Python 的验证框架。
- Python:运行测试脚本和生成配置文件。
- NVBoard:硬件调试可视化工具(需配置
NVBOARD_HOME
环境变量)。 - GTKWave:波形可视化工具。
-
配置环境变量:
export NVBOARD_HOME=/path/to/nvboard export VERILATOR_ROOT=/path/to/verilator
-
安装 Python 依赖:
pip install cocotb
使用 Verilator
编译 Verilog 源文件:
运行带或不带波形生成的仿真:
make build # 不带波形生成的仿真
make wave # 带波形生成的仿真
make test # 运行 Cocotb 测试
make test # 运行 Cocotb 测试
使用 GTKWave 打开波形文件:
make wave
生成 NVBoard 引脚绑定并运行仿真:
make nvb
默认情况下,NVBoard 会使用带时钟的仿真。如需不带时钟的仿真,请使用:
make nvb COMB=1
清理所有生成文件:
make clean-all
src_rtl/alu.v
:ALU 模块的 Verilog 源代码。src_rtl/top.v
:顶层 Verilog 模块。src_rtl/pins.nxdc
:NVBoard 引脚配置。
src_cxx/main.cpp
:Verilator 仿真入口文件。src_cxx/auto_bind.cpp
:自动生成的 NVBoard 引脚绑定代码。
tests/test_alu.py
:基于 Cocotb 的 ALU 模块测试脚本。scripts/generate_alu_config.py
:生成 ALU 配置的 Python 脚本, 作为示例和框架参考。
make help
dir Create necessary directories for build and wave files.
config Run the configuration script to generate ALU configuration.
test Run Cocotb testbench using the specified simulator.
build Build the project using Verilator without waveform tracing.
wave Build the project using Verilator with waveform tracing.
nvboard-bind Generate NVBoard pin bindings from the configuration file.
nvb Build and run the project with NVBoard simulation.
nvb COMB=1 Build and run NVBoard for combinational logic(without clk).
clean-all Clean all build files, simulation results, and configurations.