vsCode+Icarus verilog+GTKwave编写并仿真模块例化verilog

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

 

 

  • 0
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值