日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Quartus ii与Modelsim-altera 6.5b联调前仿真

發(fā)布時(shí)間:2024/9/21 编程问答 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Quartus ii与Modelsim-altera 6.5b联调前仿真 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
本實(shí)例使用的是Quartus ii9.1版本,Modelsim-altera版本是? Quartus ii9.1版本 ?對(duì)應(yīng)的6.5b版本。 本實(shí)例使用的是格雷碼計(jì)數(shù)器(Gray) ============================================================================= 首先打開Quatus ii,File->New Project Wizard.操作如下。 之后出現(xiàn)如下界面,單擊Next按鈕. 出現(xiàn)如下對(duì)話框,輸入工程位置:G:\GrayCounter,工程名為:GrayCounter,設(shè)置頂層文件:GrayCounter,此次試驗(yàn)比較簡(jiǎn)單,頂層文件和工程名就命名為一樣的。之后單擊 Next, ? 有以下對(duì)話框:再單擊Next。 ? ? 在對(duì)話框中設(shè)置FPGA為Cyclone II家族的,EP2C8Q208C8,單擊Next. 對(duì)話框中都默認(rèn),然后單擊Next, ? 有以下對(duì)話框,單擊Finish。 ???? Quartus中有以下界面:可以看到工程文件為:GrayCounter ?之后要新建一個(gè)verilog文件,File->New 選擇以下:verilog HDL File,單擊OK按鈕。 在verilog 文件中輸入:以下代碼: `timescale 1ps/1ps
module GrayCounter ? #(parameter N=5 ) ( input clk, input rst_n, output reg [N-1:0] gray );
reg [N-1:0] cnt; reg [N-1:0] temp; integer i;
always @ (posedge clk ,negedge rst_n) begin if(!rst_n) cnt <= 1'b0; else cnt <= cnt +1'b1; end
always @(cnt) begin temp[N-1] = cnt[N-1]; for(i=1; i<=N-1;i=i+1) temp[i-1] = cnt[i-1]^cnt[i]; end
always @ (posedge clk, negedge rst_n) begin ? if(!rst_n) gray<=1'b0; else ? begin gray<=temp; $display("gray=%b",gray); ? ? ? ?end end? endmodule 窗口如下: ? 然后保存verilog文件:Ctrl+S快捷鍵:出現(xiàn)以下對(duì)話框,文件名為GrayCounter,類型選擇Verilog文件類型,單擊保存。 保存之后原來的verilog1文件變?yōu)?#xff1a; GrayCounter.v文件。 ? ???之后編譯工程,Processing->Start Compilation,編譯工程。 ? . 編譯成功出現(xiàn)如下界面:?
接下來設(shè)置Modelsim的設(shè)置。 Tools->Option. ? ?在General->EDA tool options->Modelsim-Altera,設(shè)置Modelsim-Altera?的安裝路徑:G:\altera\91\modelsim_ae\win32aloem(選你自己的安裝路徑)
? 開始設(shè)置testbench的相關(guān)設(shè)置項(xiàng)。Processing->start test bench template writer,
生成的文件位置在這里:G:\GrayCounter\simulation\modelsim\GrayCounter.vt GrayCounter.vt是testbench文件,在modelsim6.5中也可以使用.v文件作為testbench文件,都是可行的。 這里順便說一下:為什么使用Modelsim-altera呢,因?yàn)?/span>modelsim6.5每次都要寫實(shí)例化文件,要要自己建立modelsim的工程,相對(duì)來說麻煩,而Modelsim-altera每次打開Quartus工程,設(shè)置一次就可以使用Modelsim-altera,實(shí)例化等基本內(nèi)容已經(jīng)寫好,省去很多時(shí)間。
GrayCounter.vttestbench文件內(nèi)容如下代碼: 這一步是建立一個(gè)仿真模板文件,模板文件提供了基本的寫法,具體的testbench文件內(nèi)容還要自己寫。 =============================================================== // Copyright (C) 1991-2009 Altera Corporation // Your use of Altera Corporation's design tools, logic functions? // and other software and tools, and its AMPP partner logic? // functions, and any output files from any of the foregoing? // (including device programming or simulation files), and any? // associated documentation or information are expressly subject? // to the terms and conditions of the Altera Program License? // Subscription Agreement, Altera MegaCore Function License? // Agreement, or other applicable license agreement, including,? // without limitation, that your use is for the sole purpose of? // programming logic devices manufactured by Altera and sold by? // Altera or its authorized distributors. ?Please refer to the? // applicable agreement for further details.
// ***************************************************************************** // This file contains a Verilog test bench template that is freely editable to ? // suit user's needs .Comments are provided in each section to help the user ? ? // fill out necessary details. ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? // ***************************************************************************** // Generated on "05/29/2012 13:41:48" // Verilog Test Bench template for design : GrayCounter //? // Simulation tool : ModelSim-Altera (Verilog) //?
`timescale 1 ps/ 1 ps module GrayCounter_vlg_tst(); // constants ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?? // general purpose registers reg eachvec; // test vector input registers reg clk; reg rst_n; // wires ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?? wire [4:0] ?gray;
// assign statements (if any) ? ? ? ? ? ? ? ? ? ? ? ? ? GrayCounter i1 ( // port map - connection between master ports and signals/registers ?? .clk(clk), .gray(gray), .rst_n(rst_n) ); initial ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? begin ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? // code that executes only once ? ? ? ? ? ? ? ? ? ? ? ? // insert code here --> begin ? ? ? ? ? ? ? ? ? ? ? ? ? // --> end ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?? $display("Running testbench"); ? ? ? ? ? ? ? ? ? ? ?? end ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? always ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?? // optional sensitivity list ? ? ? ? ? ? ? ? ? ? ? ? ?? // @(event1 or event2 or .... eventn) ? ? ? ? ? ? ? ? ? begin ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? // code executes for every event on sensitivity list ?? // insert code here --> begin ? ? ? ? ? ? ? ? ? ? ? ? ? @eachvec; ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? // --> end ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?? end ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? endmodule =================================================================================== 可以看出文件中提供了模塊的寫法和實(shí)例化調(diào)用,做以下修改,以適合我的工程。 修改GrayCounter.vt ? testbench文件之后,GrayCounter.vt ? testbench文件內(nèi)容如下: =================================================================================== `timescale 1 ps/ 1 ps module GrayCounter_vlg_tst(); reg clk; reg rst_n; ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?? wire [4:0] ?gray; GrayCounter i1( .clk(clk), .gray(gray), .rst_n(rst_n) ); initial? begin? $display("Running testbench"); ? ? clk =0; rst_n = 0; #5 rst_n = 1; ? ? ? ? ? #500000 $stop; ?? end ? always#1 clk = ~clk; ? ? ? endmodule =================================================================================== 接下來設(shè)置工程 ?設(shè)置GrayCounter工程: 在 工程上右鍵settings
在EDA tool settings->simulation中設(shè)置tool name:modelsim-altera ? 輸出文件格式選擇為verilog HDL,NativeLink settings選擇Compile testbench。
? 再單擊Test Benches
?在這順便說一句,最好不要勾選Run gate-level simulation automatically after compilation,我的Modelsim破解的不是特別好,因此不勾選這個(gè)選項(xiàng)。 ? ?再單擊Test Benches 單擊Test benches按鈕之后出現(xiàn)如下對(duì)話框:選擇New... ? 設(shè)置文件名:GrayCounter_vlg_tst 模塊名:GrayCounter? 實(shí)例名:i1? 在File name中單擊按鈕:? 彈出以下對(duì)話框: 選擇:G:\GrayCounter\simulation\modelsim\GrayCounter.vt,類型選擇All files,否則看不到GrayCounter.vt。 單擊打開按鈕 對(duì)話框如下: 單擊Add按鈕。 ? 對(duì)話框變?cè)贔ile name中變?yōu)?#xff1a;?設(shè)置完成之后Compile test bench文件為:GrayCounter_vlg_tst文件。最后單擊OK。 ?編譯工程: 調(diào)用RTL仿真:Tools->Run EDA Simulation Tool -> EDA RTL Simulation ? 在modelsim窗口中有以下:常用的有Transcript:命令輸出,包括display等的輸出,wave是波形顯示窗口,library是文件的列表 ?標(biāo)題如下: 對(duì)話框下面如下: 打開library標(biāo)簽: 最下面的work目錄:有GrayCounter_vlg_tst文件 在文件上右鍵Simulate without Optimization操作。 ? 軟件跳轉(zhuǎn)到:sim頁面中 在GrayCounter_vlg_tst文件上右鍵,Add->To wave -> All items in region。 ?? 在wave標(biāo)簽頁中有: 然后運(yùn)行,執(zhí)行run, 這時(shí)候波形看起來不是特清楚,需要調(diào)一下放大和縮小。 調(diào)節(jié)到合適位置波形如下: 可以看一下Transcript標(biāo)簽頁中有:display的輸出。

總結(jié)

以上是生活随笔為你收集整理的Quartus ii与Modelsim-altera 6.5b联调前仿真的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。