【HDL】Verilog HDL仿真工具iverilog(Icarus Verilog)

Icarus Verilog官网:http://iverilog.icarus.com/

 

1. iverilog的安装

Linux/Ubuntu:
官网给出的教程有点复杂,我试了一下直接用下面的命令就可以安装。
sudo apt-get install iverilog
sudo apt-get install gtkwave

 

2. iverilog的IDE

使用vscode+iverilog插件作为IDE。

iverilog插件,选择“mshr-h”这个作者创建的插件。

3.测试Demo

参考:https://www.bilibili.com/video/BV1Ef4y1X7wZ?from=search&seid=3262477841150114451

此Demo是演示“2输入与门”的仿真。仿真波形使用gtkwave工具。

首先创建如下工程目录结构。

and2.v

// 2-input and gate model

module and2 (
    input a,
    input b,
    output y
);
    
assign y = a & b;
endmodule

and2_tb.v

// Two-input and gate test-bench

`timescale 1s/100ms
`include "and2.v"

module and2_tb();
reg a;
reg b;
wire y;

and2 iand2(a, b, y);
initial begin
    $monitor("a=%b, b=%b, y=%b", a, b, y);
    $dumpfile("and2.vcd");  // 导出vcd文件
    $dumpvars(0, and2_tb);  // 导出and2_tb模块中的所有变量
    a = 0; b = 0; #10;
    a = 0; b = 1; #10;
    a = 1; b = 0; #10;
    a = 1; b = 1; #10;
    $finish;
end

endmodule

在vscode终端进行编译

编译后运行and2.out,输出如下:

其中and2.vcd即可用gtkwave工具打开进行波形仿真

打开效果如下

展开and2_tb的变量列表

然后进行波形仿真

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值