quartus Ⅱ 12.1 使用教程(2) modelsim 仿真

鑑於每次modelsim時間長了不用就忘記怎麼使用,所以這裏就直接寫一篇,以後忘記了直接來看這個使用教程

所要仿真的工程只是一個簡單的頻率輸出工程,將輸入的50M時鐘計數100次翻轉一次,然後輸出這個時鐘

原工程程序

module clk_out_test(
	i_clk,
	i_rst_n,
	clk_out

);

input		i_clk;
input		i_rst_n;
output	clk_out;

reg	[6:0] count;
reg			clk_out_reg;


always@(posedge i_clk or negedge i_rst_n)begin
		if(i_rst_n == 1'b0)
				count	<=	7'd0;
		else	if(count	==	7'd99)
				count	<=	7'd0;
		else
				count	<=	count	+ 1'b1;
end

always@(posedge i_clk or negedge i_rst_n)begin
		if(i_rst_n == 1'b0)
				clk_out_reg	<=	1'd0;
		else	if(count	==	7'd99)
				clk_out_reg	<=	~clk_out_reg;
		else
				clk_out_reg	<=	clk_out_reg;
end

assign	clk_out	=	clk_out_reg;

endmodule

仿真激勵文件

// Copyright (C) 1991-2012 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 "08/04/2019 18:04:20"
                                                                                
// Verilog Test Bench template for design : clk_out_test
// 
// Simulation tool : ModelSim (Verilog)
// 

`timescale 1 ps/ 1 ps
module clk_out_test_vlg_tst();
// constants                                           
// general purpose registers
// test vector input registers
reg i_clk;
reg i_rst_n;
// wires                                               
wire clk_out;

// assign statements (if any)                          
clk_out_test i1 (
// port map - connection between master ports and signals/registers   
	.clk_out(clk_out),
	.i_clk(i_clk),
	.i_rst_n(i_rst_n)
);
initial                                                
begin                                                  
i_clk = 0;
i_rst_n = 0;
#100
i_rst_n = 1'b1;
                                                                
end                                                    
always #10 i_clk = ~i_clk;                                               
                                                    
endmodule

打開modelsim

New-->Project

填寫工程名,以及modelsim存儲路徑,其它都可以選擇默認的,點擊OK

點擊這個添加我們上面提供的.v文件和激勵文件.vt文件

選擇.v文件,點擊打開

點擊OK

再次點擊Add Existing File添加.vt激勵文件

點擊打開

點擊OK

.v文件和.vt文件都添加進來了,點擊Close,關閉Add  items  to  the  project對話框(如果.v和.vt文件

在一個地方可以一次將兩個文件都添加進來)

可以從上圖看到.v和vt文件都是打問號的,所以需要重新編譯一次

點擊Compile-->Compile All(進行全編譯)

編譯成功,.v和.vt文件都沒有報錯

切換到Library 選項卡

打開work庫,這個是我們新建的庫,可以看到我們添加進去的.v和.vt文件

右擊這個激勵文件.vt文件選擇Simulate

右擊這個.vt文件選擇Add to -->Wave-> All items in region

我這裏設置仿真時間100us,設置時間太長有時容易卡,這個仿真比較簡單所以設置得比較小

選擇Simulate-->Run-->Run All 

點擊箭頭處進行全屏顯示

全屏的仿真結果和程序的效果是一樣的

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章