Installation and use of Modelsim
Preface
There are several common versions of Modelsim: SE (System Edition), PE (Personal Edition) and OEM (Orignal Equipment Manufactuce). This article is an introduction to the installation and usage of Modelsim SE version.
1. Download of Modelsim
Baidu network disk download link:
https://pan.baidu.com/s/1a9d-bq9RZmWrRV542X4IEA
Extraction code: ifte
Description:
This link comes from the official data download of Punctual Atom
Second, the installation of Modelsim
1. Unzip the compressed package
2. Run the executable program
3. The installation guide process
①Enter the welcom interface ②Select the
installation location
③Click Agree
④The installation starts
two message prompt boxes, the first time you are prompted whether to create a shortcut on the desktop, click "Yes", the second time it prompts whether to put the Modelsim executable file into the Path variable, when you select "Yes", you can execute Modelsim from the DOS prompt, here we select "Yes"
⑤Automatic installation is complete, select No
⑥Select Done
Three, Modelsim registration
For the specific process, please refer to the link below:
[FPGA——Tools]: Modelsim SE-64 10.4 download, crack, and installation process
Fourth, the use of Modelsim
step
- New Construction
- Write Verilog files and Testbench simulation files
- Compile the project
- Start the simulator and load the top level of the design
- Perform simulation
(1) Manual simulation
Directly use ModelSim software for simulation
1. Create a Modelsim project and add simulation files
Create a new folder "tb" under the "sim" folder of the LED water lamp project created by Quartus, then start the Modelsim software, and select File->Change in Modelsim Directory, in the pop-up dialog box, select the directory path as the newly created tb folder. To create a project in Modelsim, select File->New->Project, in the pop-up dialog box, enter the corresponding information, and then select OK.
The interface appears Create New File (create a new file), Add Existing File (add an existing file), Create Simulation (create a simulation) and Create New Folder (create a new folder). Here first select "Add Existing File" (add an existing file), find the "flow_led.v" file,
then select "Create New File" (create a new file), enter the corresponding information, and
finally, close Add items to the Project and
double-click "flow_led_tb" .v" file, add the following code and save
`timescale 1ns/1ns // 定义仿真时间单位1ns和仿真时间精度为1ns
module flow_led_tb(); // 测试模块
//parameter define
parameter T = 20; // 时钟周期为20ns
//reg define
reg sys_clk; // 时钟信号
reg sys_rst_n; // 复位信号
//wire define
wire [3:0] led;
//*****************************************************
//** main code
//*****************************************************
//给输入信号初始值
initial begin
sys_clk = 1'b0;
sys_rst_n = 1'b0; // 复位
#(T+1) sys_rst_n = 1'b1; // 在第21ns的时候复位信号信号拉高
end
//50Mhz的时钟,周期则为1/50Mhz=20ns,所以每10ns,电平取反一次
always #(T/2) sys_clk = ~sys_clk;
//例化flow_led模块
flow_led u0_flow_led (
.sys_clk (sys_clk ),
.sys_rst_n (sys_rst_n),
.led (led )
);
endmodule
说明:
In order to facilitate our simulation, here we need to slightly modify the code of the "flow_led.v" file, and set the maximum value of the timer counter to 10
else if (counter <24'd10)
counter <= counter + 1'b1;
2. Compile the simulation file
. Find these two commands in the menu bar [Compile]. You can also find the two commands in the shortcut toolbar or the right-click menu in the workspace.
3. Configure the simulation environment
in the ModelSim menu bar Find the [Simulate]→[Start Simulation...] menu and click, in the tab that appears, select the flow_led_tb module in the work library from the Design tab page, and uncheck it in the Optimization column (note that you must uncheck the optimization check , Otherwise you cannot observe the signal waveform), and then click [OK] to start the functional simulation, and keep the other tabs as default.
Right-click "u0_flow_led" and select the "Add Wave" option.
Select the simulation time as 1ms, and click the run button on the right
Simulation effect
(2) Automatic simulation (hybrid simulation)
Use other EDA tools such as Quartus II to call Modelsim for simulation
1. Select the EDA simulation tool to
open the Quartus II project, find the [Tool] → [Options] button in the menu bar, and on the left side of the opened page we find "EDA Tool Options" and click , Add Modelsim path, click [OK]
[Assignments] → [Settings] button, on the left side of the opened page we find "EDA Tool Settings" and click, set "Simulation" to "ModelSim, Verilog HDL", click [OK]
2. To write TestBench,
select [Processing]→[Start]→[Start TestBench Template Writer] button, a flow_led.vt file will be generated, and its content will be modified, saved and renamed flow_led_tb.vt
2. Configure the simulation environment
[Assigement 】→【Settings】button and open it, in the opened page, we find Simulation on the left and click, select "Compile Test bench", then click the [Test Benches] button behind, and then click the [New] button, then The "New Test Bench Settings" window as shown in the figure below will appear, enter the corresponding information, click the [Add] button to add to the bottom list
3. Run RTL simulation (functional simulation)
select [Tools] → [Run Simulation Tool ]→[RTL Simulation] button, the simulation will be automatically completed since then.
Reference
Link to related materials on Punctual Atom
http://www.openedv.com/docs/boards/fpga/zdyz_dafenqi.html