iverilog搭建简易仿真平台

iverilog搭建简易仿真平台

对于xsim和modelsim这种仿真测试平台,对操作系统要求过于严格,为了实现远程verilog编译仿真调试,我选择了linux+iverilog+gtkwave来搭建一个lite版的Verilog仿真环境。

由于之前对树莓派做了内网穿透,大致目标是在树莓派上搭建相应环境,通过iverilog编译生成仿真执行文件,运行后将得到的波形数据通过ssh X11转发到远程,即可查看生成波型。但树莓派的X11转发始终没有成功,初步怀疑是ssh远程时xorg服务没有默认输出显示器。由于最近时间较紧,只好取折中办法,通过远程到树莓派vnc服务器,从而在vnc界面上打开gtkwave。

软件安装

Debian环境安装

sudo apt install iverilog
sudo apt install gtkwave

安装完成之后可以上手

选取一个之前写好的vga显示程序

修改testbench文件:

在initial块插入如下代码:

    $dumpfile("tb.vcd");
    $dumpvars(0, tb_vga);

dumpfile表示写入波形的文件(这里注意文件扩展名,否则gtkwave不支持)

dumpvars设置指定层次数为0,即为tb_vga顶层模块及其下面各层次的所有信号将被记录

`timescale 1ns / 1ps
module tb_vga();
reg              clk;
reg              rst_n;
wire             u_vga_hs;
wire             u_vga_vs;
wire [11:0]            u_vga_rgb;

vga_board u_vga_board(
    .clk(clk),
    .rst_n(rst_n),
    .vga_hs(u_vga_hs),
    .vga_vs(u_vga_vs),
    .vga_rgb(u_vga_rgb)
);
    

always #5 clk = ~clk;

initial begin 
    $dumpfile("tb.vcd");
    $dumpvars(0, tb_vga);
    rst_n = 1;
    clk = 1;
    #100;
    rst_n = 0;
    #100;
    rst_n = 1;    
end
endmodule

iverilog执行

-y:指定绝对路径

后接空格,指定仿真文件(不得绝对路径后跟testbench文件)

iverilog -y ~/iverilog/iverilog_module/module/vga/ tb_vga.v 

如果不指明编译文件名称,则会自动生成一个a.out文件(这一点和gcc编译方式很像)

执行文件

➜  vga git:(master) ✗ ./a.out                                                       
VCD info: dumpfile tb.vcd opened for output.

需要终止仿真则ctrl+c

➜  vga git:(master) ✗ ./a.out
VCD info: dumpfile tb.vcd opened for output.
^C** VVP Stop(0) **
** Flushing output streams.
** Current simulation time is 2364130000 ticks.
> 

等待下一步指示

可选命令如下:

Commands can be from the following table of base commands,
or can be invocations of system tasks/functions.

cd       - Synonym for push.
cont     - Resume (continue) the simulation
finish   - Finish the simulation.
help     - Get help.
list     - List items in the current scope.
load     - Load a VPI module, a la vvp -m.
ls       - Shorthand for "list".
pop      - Pop one scope from the scope stack.
push     - Descend into the named scope.
step     - Single-step the scheduler for 1 event.
time     - Print the current simulation time.
trace    - Control statement tracing (on/off) when the code is instrumented.
where    - Show current scope, and scope hierarchy stack.

If the command name starts with a '$' character, it
is taken to be the name of a system task, and a call is
built up and executed.

直接finish结束仿真

远程vnc到服务器

➜  ~ gtkwave ~/verilog_project/module/vga/tb.vcd

即可通过gtkwave查看波形。

测试后,对于大型文件,仿真速度还是差点意思,但是作为四年前的arm芯片,不做过多要求。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值