91欧美超碰AV自拍|国产成年人性爱视频免费看|亚洲 日韩 欧美一厂二区入|人人看人人爽人人操aV|丝袜美腿视频一区二区在线看|人人操人人爽人人爱|婷婷五月天超碰|97色色欧美亚州A√|另类A√无码精品一级av|欧美特级日韩特级

0
  • 聊天消息
  • 系統(tǒng)消息
  • 評(píng)論與回復(fù)
登錄后你可以
  • 下載海量資料
  • 學(xué)習(xí)在線課程
  • 觀看技術(shù)視頻
  • 寫(xiě)文章/發(fā)帖/加入社區(qū)
會(huì)員中心
創(chuàng)作中心

完善資料讓更多小伙伴認(rèn)識(shí)你,還能領(lǐng)取20積分哦,立即完善>

3天內(nèi)不再提示

Windows上使用iverilog+gtkwave仿真

FPGA之家 ? 來(lái)源:FPGA之家 ? 2023-04-28 14:06 ? 次閱讀
加入交流群
微信小助手二維碼

掃碼添加小助手

加入工程師交流群

使用Verilog編寫(xiě)好了功能模塊以及對(duì)應(yīng)的testbench之后,一般需要對(duì)其功能進(jìn)行仿真測(cè)試。由于工作場(chǎng)合、必須使用正版軟件,然而ModelSim的license又非常有限、經(jīng)常出現(xiàn)的狀況是一方在使用其進(jìn)行仿真、另一方就不能夠進(jìn)行仿真了。

在這個(gè)情況下,可以有的選擇包括:

1、繼續(xù)等待別人用完,然后再使用ModelSim進(jìn)行仿真;

2、使用集成在VIVADO里的simulation工具(ISE下自帶的是ISim),基本可以勝任絕大多數(shù)的功能仿真任務(wù);操作也很簡(jiǎn)單,直接Run Simulation就可以了;

3、使用開(kāi)源的工具:iverilog+gtkwave工具。

下面對(duì)第三種方式的操作流程進(jìn)行記錄。系統(tǒng)環(huán)境為Windows7

從官網(wǎng)下載包含iverilog+GTKWave的安裝包,地址為http://bleyer.org/icarus/。安裝好之后開(kāi)始逐步執(zhí)行命令。(或者也可以將命令編寫(xiě)在一個(gè)腳本文件中。)

本文所仿真的verilog小實(shí)例如下,是一個(gè)簡(jiǎn)單的loadable四位加一計(jì)數(shù)器:(代碼來(lái)自在學(xué)習(xí)testbench期間在網(wǎng)上找到的Lattice公司的“A Verilog HDL Test Bench Primer”手冊(cè)中的示例代碼)

//-------------------------------------------------
// File: count16.v
// Purpose: Verilog Simulation Example
//-------------------------------------------------
`timescale 1 ns / 100 ps
module count16 (count, count_tri, clk, rst_l, load_l, enable_l, cnt_in,
oe_l);
output [3:0] count;
output [3:0] count_tri;
input clk;
input rst_l;
input load_l;
input enable_l;
input [3:0] cnt_in;
input oe_l;
reg [3:0] count;
// tri-state buffers
assign count_tri = (!oe_l) ? count : 4'bZZZZ;
// synchronous 4 bit counter
always @ (posedge clk or negedge rst_l)
    begin
        if (!rst_l) begin
            count <= #1 4'b0000;
        end
        else if (!load_l) begin
            count <= #1 cnt_in;
        end
        else if (!enable_l) begin
            count <= #1 count + 1;
        end
    end
endmodule //of count16

為其編寫(xiě)的testbench文件如下:

//-------------------------------------------------
// File: cnt16_tb.v
// Purpose: Verilog Simulation Example
// Test Bench
//-----------------------------------------------------------
`timescale 1 ns / 100 ps
module cnt16_tb ();
//---------------------------------------------------------
// inputs to the DUT are reg type
reg clk_50;
reg rst_l, load_l, enable_l;
reg [3:0] count_in;
reg oe_l;
//--------------------------------------------------------
// outputs from the DUT are wire type
wire [3:0] cnt_out;
wire [3:0] count_tri;
//---------------------------------------------------------
// instantiate the Device Under Test (DUT)
// using named instantiation
count16 U1 ( .count(cnt_out),
.count_tri(count_tri),
.clk(clk_50),
.rst_l(rst_l),
.load_l(load_l),
.cnt_in(count_in),
.enable_l(enable_l),
.oe_l(oe_l)
);
//----------------------------------------------------------
// create a 50Mhz clock
always
#10 clk_50 = ~clk_50; // every ten nanoseconds invert
//-----------------------------------------------------------
// initial blocks are sequential and start at time 0
initial
        begin            
            $dumpfile("cnt16_tb.vcd");
            $dumpvars(0,cnt16_tb);
        end

initial
begin
$display($time, " << Starting the Simulation >>");
clk_50 = 1'b0;
// at time 0
rst_l = 0;
// reset is active
enable_l = 1'b1;
// disabled
load_l = 1'b1;
// disabled
count_in = 4'h0;
oe_l = 4'b0;
// enabled
#20 rst_l = 1'b1;
// at time 20 release reset
$display($time, " << Coming out of reset >>");
@(negedge clk_50); // wait till the negedge of
// clk_50 then continue
load_count(4'hA);
// call the load_count task
// and pass 4'hA
@(negedge clk_50);
$display($time, " << Turning ON the count enable >>");
enable_l = 1'b0;
// turn ON enable
// let the simulation run,
// the counter should roll
wait (cnt_out == 4'b0001); // wait until the count
// equals 1 then continue
$display($time, " << count = %d - Turning OFF the count enable >>",
cnt_out);
enable_l = 1'b1;
#40;
// let the simulation run for 40ns
// the counter shouldn't count
$display($time, " << Turning OFF the OE >>");
oe_l = 1'b1;
// disable OE, the outputs of
// count_tri should go high Z.
#20;
$display($time, " << Simulation Complete >>");
$stop;
// stop the simulation
end
//--------------------------------------------------------------
// This initial block runs concurrently with the other
// blocks in the design and starts at time 0
/*initial
begin
// $monitor will print whenever a signal changes
// in the design
$monitor($time, " clk_50=%b, rst_l=%b, enable_l=%b, load_l=%b,
count_in=%h, cnt_out=%h, oe_l=%b, count_tri=%h", clk_50, rst_l,
enable_l, load_l, count_in, cnt_out, oe_l, count_tri);
end*/


//--------------------------------------------------------------
// The load_count task loads the counter with the value passed
task load_count;
    input [3:0] load_value;
    begin
        @(negedge clk_50);
        $display($time, " << Loading the counter with %h >>", load_value);
        load_l = 1'b0;
        count_in = load_value;
        @(negedge clk_50);
        load_l = 1'b1;
    end
endtask //of load_count


endmodule //of cnt16_tb

為了方便執(zhí)行,編寫(xiě)了批處理腳本,如下:

set iverilog_path=C:iverilogin;
set gtkwave_path=C:iveriloggtkwavein;
set path=%iverilog_path%%gtkwave_path%%path%

set source_module=count16
set testbentch_module=cnt16_tb


iverilog -o "%testbentch_module%.vvp" %testbentch_module%.v %source_module%.v
vvp -n "%testbentch_module%.vvp"

set gtkw_file="%testbentch_module%.gtkw"
if exist %gtkw_file% (gtkwave %gtkw_file%) else (gtkwave "%testbentch_module%.vcd")

pause

首先,設(shè)置iverilog和GTKWave可執(zhí)行文件路徑到PATH。由于工作場(chǎng)合下、本人只是所使用電腦系統(tǒng)的普通用戶(hù)權(quán)限、而不是管理員權(quán)限,所以不方便為本機(jī)系統(tǒng)添加環(huán)境變量,所以需要在開(kāi)始執(zhí)行上述操作。

然后設(shè)置兩個(gè)變量,后面會(huì)使用

testbentch_module設(shè)置為testbench文件的模塊名

source_module設(shè)置為DUT模塊名

然后使用iverilog編譯verilog

-o指定輸出文件名,這里使用模塊名+.vvp

之后指定源文件

在制定源文件的時(shí)候可以用通配符*,如本人用的批處理中通常使用這種方式指定RTL文件:set rtl_file="../rtl/*.v"。

然后使用vvp開(kāi)始仿真,參數(shù)為上面iverilog的輸出文件

之后開(kāi)始仿真數(shù)據(jù)波形顯示

設(shè)置了一個(gè)變量,為GTKWave保存文件的文件名,這里使用模塊名+.gtkw

然后判斷GTKWave保存文件是否存在,若存在則直接使用GTKWave打開(kāi)該.gtkw文件,否則打開(kāi)剛仿真生成的.vcd文件。

這里有兩點(diǎn)需要注意:

1、vvp命令使用了-n選項(xiàng)是為了讓testbench在執(zhí)行完測(cè)試流程之后自動(dòng)結(jié)束,也可以不在執(zhí)行命令這里使用-n、而通過(guò)在testbench文件的initial塊中添加"$finish"命令來(lái)結(jié)束。(testbentch中結(jié)束仿真推薦用$finish而不用$stop;因?yàn)?finish可以直接結(jié)束仿真并退出,而不需要手動(dòng)退出,這樣運(yùn)行類(lèi)似以上例子批處理后可以直接打開(kāi)GTKWave窗口)

2、為了讓vvp命令有輸出,需要在testbench文件中額外添加一個(gè)initial塊,在上面的代碼中為:

initial
        begin            
            $dumpfile("cnt16_tb.vcd");
            $dumpvars(0,cnt16_tb);
        end

dumpfile的內(nèi)容為輸出的vcd文件名,可以隨意指定,這里指定為testbench模塊名;

dumpvar的參數(shù)需要為testbench的模塊名。

添加了這兩個(gè)命令之后就可以將生成的波性文件保存在本地。

在GTKWave中打開(kāi)的仿真波形結(jié)果如下圖所示:

b1b12b32-e583-11ed-ab56-dac502259ad0.png

直接運(yùn)行iverilog -help或iverilog則會(huì)顯示以下幫助信息,顯示了iverilog支持的參數(shù)

Usage: iverilog [-ESvV] [-B base] [-c cmdfile|-f cmdfile]
                [-g1995|-g2001|-g2005|-g2005-sv|-g2009|-g2012] [-g]
                [-D macro[=defn]] [-I includedir]
                [-M [mode=]depfile] [-m module]
                [-N file] [-o filename] [-p flag=value]
                [-s topmodule] [-t target] [-T min|typ|max]
                [-W class] [-y dir] [-Y suf] source_file(s)

此外,如果運(yùn)行批處理需要在DOS窗口查看verilog中$display的打印,有時(shí)iverilog編譯打印的信息較多時(shí)會(huì)導(dǎo)致部分信息無(wú)法查看,所以需要加大DOS窗口的高度:在DOS窗口標(biāo)題欄右鍵->默認(rèn)值->布局中設(shè)置屏幕緩沖區(qū)中高度為較大的值(如1000)即可。

審核編輯:湯梓紅

聲明:本文內(nèi)容及配圖由入駐作者撰寫(xiě)或者入駐合作網(wǎng)站授權(quán)轉(zhuǎn)載。文章觀點(diǎn)僅代表作者本人,不代表電子發(fā)燒友網(wǎng)立場(chǎng)。文章及其配圖僅供工程師學(xué)習(xí)之用,如有內(nèi)容侵權(quán)或者其他違規(guī)問(wèn)題,請(qǐng)聯(lián)系本站處理。 舉報(bào)投訴
  • 仿真
    +關(guān)注

    關(guān)注

    54

    文章

    4488

    瀏覽量

    138333
  • WINDOWS
    +關(guān)注

    關(guān)注

    4

    文章

    3702

    瀏覽量

    94098
  • Verilog
    +關(guān)注

    關(guān)注

    30

    文章

    1374

    瀏覽量

    114547
  • 計(jì)數(shù)器
    +關(guān)注

    關(guān)注

    32

    文章

    2317

    瀏覽量

    98229
  • 開(kāi)源
    +關(guān)注

    關(guān)注

    3

    文章

    4222

    瀏覽量

    46195

原文標(biāo)題:Windows上使用iverilog+gtkwave仿真

文章出處:【微信號(hào):zhuyandz,微信公眾號(hào):FPGA之家】歡迎添加關(guān)注!文章轉(zhuǎn)載請(qǐng)注明出處。

收藏 人收藏
加入交流群
微信小助手二維碼

掃碼添加小助手

加入工程師交流群

    評(píng)論

    相關(guān)推薦
    熱點(diǎn)推薦

    E203用iverilog12仿真時(shí),run_test一直卡怎么解決?

    求助!!一直卡在這里進(jìn)行不下去了,請(qǐng)問(wèn)大佬們這是為什么呀?每個(gè)步驟都是按照教程來(lái)的!iverilog用的12,ubuntu 20.04
    發(fā)表于 01-10 07:07

    基于樹(shù)莓派5的RTL仿真體驗(yàn)

    《基于樹(shù)莓派5的RTL仿真體驗(yàn)》 對(duì)于FPGA或者RTL愛(ài)好者來(lái)講,樹(shù)莓派5開(kāi)發(fā)板可以運(yùn)行RTL仿真,仿真工具使用iverilog,波形工具使用gt
    發(fā)表于 04-30 17:35

    在Ubuntu安裝iverilog 12.0方法

    安裝步驟如下: 1、打開(kāi)終端并更新軟件包列表: 復(fù)制代碼:sudo apt update 2、下載安裝編譯iverilog 12.0需要的依賴(lài)項(xiàng): 復(fù)制代碼:sudo apt install
    發(fā)表于 10-24 12:24

    Iverilog仿真e203_hbirdv2跑RISC-V指令測(cè)試用例

    環(huán)境:Ubuntu20.04、Iverilog12.0、gtkwave3.3.103 內(nèi)容:Iverilog仿真e203_hbirdv2跑RISC-V指令測(cè)試用例 要點(diǎn): 下載安
    發(fā)表于 10-27 08:24

    Hummingbirdv2 E203 仿真排坑之路

    source regen.sh 4 跑仿真 這里僅以iverilg為例 4.1 iverilog 安裝 這里有個(gè)大坑: 不能直接用sudo 安裝,因?yàn)檫@樣安裝的版本是10,我們
    發(fā)表于 10-31 09:22

    樹(shù)莓派在windows仿真的方法

    樹(shù)莓派在windows仿真的方法是一個(gè)超簡(jiǎn)單的方式,其實(shí)是QEMU模擬器+樹(shù)莓派系統(tǒng)的‘傻瓜包’”,壓縮文件,500m。解壓后,run.bat[hide]下載地址: http://sourceforge.net/project
    發(fā)表于 06-29 16:03

    SpinalHDL是如何讓仿真跑起來(lái)的

    一些比較貼合具體業(yè)務(wù)場(chǎng)景的測(cè)試條件下往往需要前后很多腳本或調(diào)用C模型來(lái)進(jìn)行生成測(cè)試數(shù)據(jù)和最后的數(shù)據(jù)驗(yàn)證,構(gòu)建case的便捷性稍顯不足(在《FPGA圖像處理—老細(xì)新說(shuō)》一文中,這里的仿真測(cè)試如果用
    發(fā)表于 07-25 15:09

    基于Windows系統(tǒng)的SpinalHDL開(kāi)發(fā)環(huán)境搭建步驟

    ;仿真工具使用verilator+gtkwave,為了便捷安裝使用Iverilog軟件(此軟件集成GTKWave),安裝verilator軟件在wi
    發(fā)表于 10-24 15:40

    如何在ARM使用Clang for Windows進(jìn)行編譯

    Windows on Arm筆記本電腦編譯C/C++應(yīng)用程序。 此原生工具鏈意味著您可以在該設(shè)備為基于Arm的設(shè)備開(kāi)發(fā)軟件而不是在另一臺(tái)主機(jī)上交叉編譯或使用仿真來(lái)運(yùn)行Clang的
    發(fā)表于 08-08 06:56

    在/vsim下執(zhí)行make run_test SIM=iverilog時(shí)報(bào)錯(cuò)怎么解決?

    Error: VVP input file 10.3 can not be run with run time version 12.0 (stable) 求助大佬,在/vsim下執(zhí)行make run_test SIM=iverilog時(shí)收到上面的報(bào)錯(cuò),嘗試重裝iverilog
    發(fā)表于 08-12 08:29

    Windows平臺(tái)的分布式實(shí)時(shí)仿真系統(tǒng)

    Windows平臺(tái)的分布式實(shí)時(shí)仿真系統(tǒng)
    發(fā)表于 10-31 09:20 ?10次下載
    <b class='flag-5'>Windows</b>平臺(tái)的分布式實(shí)時(shí)<b class='flag-5'>仿真</b>系統(tǒng)

    如何使用Icarus Verilog+GTKWave來(lái)進(jìn)行verilog文件的編譯和仿真

    Windows+Linux+MacOS,并且源代碼開(kāi)源。通過(guò)tb文件可以生成對(duì)應(yīng)的仿真波形數(shù)據(jù)文件,通過(guò)GTKWave可以查看仿真波形圖,支持將Verilog轉(zhuǎn)換為VHDL文件。 1.
    的頭像 發(fā)表于 07-27 09:16 ?6687次閱讀
    如何使用Icarus Verilog+<b class='flag-5'>GTKWave</b>來(lái)進(jìn)行verilog文件的編譯和<b class='flag-5'>仿真</b>

    全平臺(tái)輕量開(kāi)源verilog仿真工具iverilog+GTKWave使用教程

    如果你只是想檢查Verilog文件的語(yǔ)法是否有錯(cuò)誤,然后進(jìn)行一些基本的時(shí)序仿真,那么Icarus Verilog 就是一個(gè)不錯(cuò)的選擇。相比于各大FPGA...
    發(fā)表于 01-26 19:14 ?5次下載
    全平臺(tái)輕量開(kāi)源verilog<b class='flag-5'>仿真</b>工具<b class='flag-5'>iverilog+GTKWave</b>使用教程

    verilog仿真工具編譯

    Icarus Verilog(以下簡(jiǎn)稱(chēng)iverilog )號(hào)稱(chēng)“全球第四大”數(shù)字芯片仿真器,也是一個(gè)完全開(kāi)源的仿真器。
    的頭像 發(fā)表于 08-15 09:11 ?9638次閱讀

    利用vcs+verdi仿真工具蜂鳥(niǎo)E200系列處理器仿真分析

    開(kāi)源RISC-V Hummingbird E203(蜂鳥(niǎo)E203)的仿真工具是開(kāi)源的iverilog,這里利用vcs+verdi仿真工具進(jìn)行仿真
    的頭像 發(fā)表于 11-17 10:28 ?4328次閱讀