1. 软件安装 vsCode,下载插件verilog,verilog-utils
sudo apt-get install iverilog
sudo apt-get install gtkwave
通过iverilog执行编译,生成的文件通过vvp执行仿真,配合gtkwave可以实现图形化的波形显示查看
检测是否安装成功
which iverilog
which vvp
which gtkwave
vscode中新建文件编写Verilog文件
模拟仿真时加上去
$dumpfile("counter_tb.vcd"); //指定VCD文件的名字为counter_tb.vcd,仿真信息将记录到此文件
$dumpvars(0, counter_tb); //指定层次数为0,则counter_tb模块及其下面各层次的所有信号将被记录
module counter(out, clk, enable,reset);
output[7:0] out;
input clk, reset, enable;
reg[7:0] out;
always @ (posedge clk) begin
if(reset) begin
out <= 8'b0;
end else if(enable) begin
out <= out + 1;
end
end
endmodule
///
测试文件
`timescale 1ns/1ns
module counter_tb;
reg clk, enable, reset;
wire [7:0] out;
counter c1(.out(out), .clk(clk), .enable(enable), .reset(reset));
initial begin
enable = 1;
end
initial begin
clk = 0;
forever #10 clk = ~clk;
end
initial begin
reset = 1;
#15 reset = 0;
#1000 $finish;
end
initial
begin
$dumpfile("counter_tb.vcd"); //生成的vcd文件名称
$dumpvars(0, counter_tb); //tb模块名称
end
endmodule
iverilog -o "counter_tb.vvp" counter_tb.v counter.v 编译成一个vvp文件
vvp counter_tb.vvp vvp开始仿真,会生成一个在测试文件中通过$dumpfile("counter_tb.vcd")
指定的文件(counter_tb.vcd)。
GTKwave软件
gtkwave counter_tb.vcd
命令封装到一个批处理文件中
source_module="simple"
testbentch_module="simple_tb"
echo $source_module
echo $testbentch_module
iverilog -o $source_module".vvp" $source_module".v" $testbentch_module".v"
vvp -n $source_module".vvp"
gtkwave $source_module".vcd"
例化 选取点v文件的输入输出定义部分代码
粘贴到需要的地方点击右键选择command platette 后选择Verilog utils instation