FPGA QuartusII 13.0.1+ModelSim SE 10.1a聯合仿真以及Hello World測試程序


轉自:https://blog.csdn.net/pang9998/article/details/83447190

一、實驗環境(藍色粗體字為特別注意內容)

1,環境:Windows 7 Ultimate 32 bit、QuartusII 13.0.1 win32、ModelSim SE 10.1a win32

2,參考文獻:

①http://bbs.eeworld.com.cn/thread-530964-1-1.html
②https://www.cnblogs.com/Jezze/archive/2012/09/14/2684333.html
③https://www.cnblogs.com/yuesheng/archive/2011/06/25/2090385.html ④https://www.cnblogs.com/luckybag/articles/3803991.html
⑤http://www.eefocus.com/nightseas/blog/12-03/242395_7df71.html ⑥https://blog.csdn.net/ocean1171597779/article/details/25885105                                      ⑦
https://www.jb51.net/softs/561414.html                                                    ⑧https://blog.csdn.net/qq_18649781/article/details/81025650

 二、詳細步驟

2.1 QuartusII 13.0.1安裝&破解

1)按照參考文獻⑧的步驟,到度盤鏈接:https://pan.baidu.com/s/1I_6-9f0wvEpF_utkTjjsUQ 密碼:u6ef,將QuartusSetup-13.0.1.232還有破解器下載到電腦本地磁盤(cyclone好像不用下,QuartusSetup自帶,如果實在需要再下載,反正我下載下來安裝的時候提示我已經安裝過了,無語。。。)。

2)雙擊QuartusSetup-13.0.1.232.exe,選擇安裝位置,一路next將Quartus安裝到本地磁盤。最后,done!

3)如果你的電腦是32位,將破解器中的“Quartus_13.0_x86破解器.exe”復制到 “你的安裝路徑\quartus\bin”目錄下面,並且雙擊,將生成的"license"保存。

4)如果你的電腦是64位,將破解器中的“Quartus_13.0_x64破解器.exe”復制到 “你的安裝路徑\quartus\bin64”目錄下面,雙擊,將生成的"license"保存。

5)選擇對應版本,打開QuartusII,Tools->License Setup->(NIC)ID 選擇第一個作為CID復制之,關閉Quartus。

6)打開之前保存的"licence.dat",將(NIC)ID替換掉里面的xxxxxxx,打開Quartus 定位到Tools->License Setup,License file選擇剛剛修改的license.dat,出現以下界面說明破解完成

2.2 ModelSim SE 10.1a安裝&破解

ModelSim是業界唯一的單內核支持VHDL和Verilog混合仿真的仿真器,比Quartus自帶的仿真器要強大很多,它采用直接優化的編譯技術、Tcl/Tk技術、和單一內核仿真技術,編譯仿真速度快,編譯的代碼與平台無關,便於保護IP核,個性化的圖形界面和用戶接口,為用戶加快調錯提供強有力的手段,是FPGA/ASIC設計的首選仿真軟件。目前有se、de、pe等多個版本,對應Altera和Xilinx還有對應的OEM版本,所有的版本功能最強速度最快的就是se,反正也是要破解,自然就裝最強的版本了,和Altera網站上的modelsim的區別在於,se的版本我們需要自己編譯對應的庫,所以Altera和Xilinx的都是自帶對應的庫無需編譯的,像我這樣同時裝了Quartus II和ISE的,自然還是自己編譯方便一點。

1)按照參考文獻⑦,將modelsim se 10.1c emouse.rar下載到本地,解壓之。

2)雙擊modelsim-win32-10.1a-se.exe選擇安裝路徑,安裝之,最后彈出一個對話框,點擊“NO”即可。

3)將MentorKG.exe和crack.bat文件復制到安裝根目錄win32目錄下,運行crack.bat文件,生成txt文件后另存為LICENSE.TXT

4)我的電腦右鍵->屬性->高級->環境變量,新增系統環境變量LM_LICENSE_FILE,值為LICENSE.TXT的路徑,如:D:\modeltech_10.1a\LICENSE.TXT

5)運行Modelsim

2.3 編寫測試程序

按照參考文獻①

第一步:新建工程
File --> New Project Wizard...


1.選擇工程目錄,指定工程名及設計入口,一般情況下建議工程目錄,工程名稱及設計入口同名,不能有中文路徑;
2.添加已有文件,如果新建的工程,則直接跳過;
3.器件選擇,需要與實際用到的器件相同,Family選擇Cyclone IV E,Available device這里選擇EP4CE6F17C8;
4.設置工具,一般直接next跳過;
5.信息確認,如果無誤則點擊Finish完成;

修改默認配置:
Assignments --> Device...
--> Device and Pin Option...


Unused Pins:未用到引腳選擇,As input tri-stated;
Valtage 引腳默認電壓值,選擇 3.3-V LVTTL;

第二步:建立HDL文件
File--> New...
Design Files --> Verilog HDL File內容如下:


   
   
   
           
  1. /*
  2. * 功能描述:流水燈演示
  3. */
  4. module demo (
  5. input clk, // 時鍾輸入(外部50MHz晶振)
  6. input rst_n, // 復位按鍵
  7. output reg [ 3: 0] led // 4位LED
  8. );
  9. // 寄存器定義
  10. reg [ 31: 0] timer; // 用於定時器計數
  11. // 計時時鍾
  12. always @(posedge clk or negedge rst_n)
  13. begin
  14. if(~rst_n)
  15. timer <= 0;
  16. else if(timer == 32'd200_000_000)
  17. timer <= 0;
  18. else
  19. timer <= timer + 1'b1; // 通過脈沖數計算時間
  20. end
  21. // 檢測時鍾的下降沿和復位的下降沿
  22. always @(posedge clk or negedge rst_n)
  23. begin
  24. if (~rst_n) // 復位信號低電平有效
  25. led <= 4'b0000; // LED燈輸出全為低,四個LED燈滅
  26. // 時鍾下降沿
  27. else
  28. begin
  29. // 50HMz的時鍾下,50個時鍾為1us
  30. if(timer == 32'd50_000_000)
  31. led <= 4'b0001;
  32. else if (timer == 32'd100_000_000)
  33. led <= 4'b0010;
  34. else if (timer == 32'd150_000_000)
  35. led <= 4'b0100;
  36. else if (timer == 32'd200_000_000)
  37. led <= 4'b1000;
  38. end
  39. end
  40. endmodule

保存文件,名稱與之前設置的入口文件相同;(不然會出現報錯①)

第三步:綜合
點擊Analysis & Synthesis進行綜合;

成功

第四步:引腳分配
Assignments --> Pins Planner打開引腳分配頁面進行分配;

雙擊引腳對應的Location,彈出引腳選擇下拉列表


按照原理圖上分配對應的引腳:
CLK   --> E1
LED0 --> E10
LED1 --> F9
LED2 --> C9
LED3 --> D9
I/O Standard 根據實際電路選擇電平標准,這里選擇3.3-V LVTTL;
同一個Bank的引腳的電平標准必須相同;


注意事項:
必須綜合之后,才能進行引腳分配,否則系統並不知道你用了哪些引腳;

第五步:編譯
雙擊Complile Design進行全編譯;

或者點擊

第六步:下載測試
通過JTAG下載至RAM
點擊Program Device打開編譯器;
點擊Add File...添加output_files目錄下生成的sof文件;
點擊Start即可進行下載;
下載完成后會自動運行,掉電后會丟失;

固化至配置芯片
文件轉換:
File --> Convert Programming Files...
Programming file type:
選擇文件格式,指定為jic格式,JTAG Indirect Configuration File(.jic)
Configuration device:
選擇配置芯片型號,與目標板上的型號一致(EPCS16)
Flash Loader:與目標板上FPGA的類別一致;
Sof Data:選擇編譯好的sof文件;
點擊Generate生成jic目標文件;
(此時可選擇Save Conversion Setup... 保本配置參數,以便下次調入)
下載固化
點擊Program Device打開編譯器;
點擊Add File...添加output_files目錄下生成的jic文件;
點擊Start即可進行下載;
下載完成后,不會自動運行,需要重上電才能正常運行;

注意事項:
一般只有在完成調試完成后,交付測試時才需要固化,而在調試過程中,則沒必要進行固化下載;

2.4 Modelsim聯合仿真

1)按照參考文獻②,第一次用modelsim+quartus的時候需要在quartus中設置modelsim的路徑,quartus->tools->options->general->EDA tool options ,在右邊選擇modelsim的安裝路徑\win32,如下圖:

2)點擊Quartus->Assignments->Settings

 

選擇Simulation->Tool name選擇ModelSim

先選擇TestBenche None,點擊OK

3)建立TestBench模板

我們可以通過Quartus自動生成一個Testbench的模板,選擇Processing -> Start -> Start Test Bench Template Writer,等待完成后打開剛才生成的Testbench,默認是保存在simulation\modelsim文件夾下的.vt格式文件

Quartus打開文件,到“工程目錄\simulation\modelsim"下找到.vt文件,打開,

按照參考文獻⑤的語法規則編寫Testbench,填寫完成后內容如下


   
   
   
           
  1. // Copyright (C) 1991-2013 Altera Corporation
  2. // Your use of Altera Corporation's design tools, logic functions
  3. // and other software and tools, and its AMPP partner logic
  4. // functions, and any output files from any of the foregoing
  5. // (including device programming or simulation files), and any
  6. // associated documentation or information are expressly subject
  7. // to the terms and conditions of the Altera Program License
  8. // Subscription Agreement, Altera MegaCore Function License
  9. // Agreement, or other applicable license agreement, including,
  10. // without limitation, that your use is for the sole purpose of
  11. // programming logic devices manufactured by Altera and sold by
  12. // Altera or its authorized distributors. Please refer to the
  13. // applicable agreement for further details.
  14. // *****************************************************************************
  15. // This file contains a Verilog test bench template that is freely editable to
  16. // suit user's needs .Comments are provided in each section to help the user
  17. // fill out necessary details.
  18. // *****************************************************************************
  19. // Generated on "10/27/2018 18:41:50"
  20. // Verilog Test Bench template for design : demo
  21. //
  22. // Simulation tool : ModelSim (Verilog)
  23. //
  24. `timescale 1 ps/ 1 ps
  25. module demo_vlg_tst();
  26. // constants
  27. // general purpose registers
  28. reg eachvec;
  29. // test vector input registers
  30. reg clk;
  31. reg rst_n;
  32. // wires
  33. wire [ 3: 0] led;
  34. parameter PERIOD = 20;
  35. // assign statements (if any)
  36. demo i1 (
  37. // port map - connection between master ports and signals/registers
  38. .clk(clk),
  39. .led(led),
  40. .rst_n(rst_n)
  41. );
  42. initial
  43. begin
  44. // code that executes only once
  45. // insert code here --> begin
  46. #0 clk = 1'b0;
  47. rst_n = 1 'b0;
  48. #5 rst_n = 1'b1;
  49. // --> end
  50. $display( "Running testbench");
  51. end
  52. always #(PERIOD/2)clk=~clk;
  53. endmodule

也就是對模板進行下面的修改,並保存

復制*_vlg_test 

4)回到Quartus->Assignments->Settings->Simulation

點擊Test Benches-》New,Test bench name粘貼剛才復制的名字,Top level module in test bench自動填充雍陽的名字,勾選Use test bench to perform VHDL timing simulation,填寫i1,File name選擇"工程目錄\simulation\modelsim"下的.vt文件,最后點擊Add,OK關閉對話框,至此,設置完成!!下面開始仿真。

5)點擊Tools -》Run Simulation tool-》RTL Simulation

漂亮的仿真界面出來啦~~~

FPGA開發環境 QuartusII+ModelSim SE配置完成!這個過程中可能會出現以下問題

①Error: Top-level design entity "simulate" is undefined

按照參考文獻⑥,將模塊名和.v文件名改為一致即可。

 

 

 

 

 

 

 

 

 

 

 

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM