Quartus + Modesim完整波形仿真过程
此次要仿真的波形为一个简单的二分频电路。
首先打开我们的Quartus软件
点击新建新的工程
点击next
选择工程保存的位置及工程的名字,注意路径一定不能有中文,而且第二行和第三行的名字要一致,否则编译的时候会报错。新建完后继续next。
这里我们没有文件添加,直接next。
因为这里只涉及到波形仿真,没有必要选择器件,直接next。
这里注意仿真工具选择modesim,因为我这里用的是verilog,所以语言选择verilog。然后next。
点击finish。
点击file中的new
选择verilog file ,点击ok。
module test(
input clk,
input clr,
output reg half_clk);
always @(posedge clk or negedge clr)
if (!clr) half_clk <= 1'b0;
else half_clk = ~ half_clk;
endmodule
在.v文件中输入以上二分频的代码,点击编译。
编译通过。
编译通过后就要关联我们的modesim了,选择tools中的options
这里选择modesim的安装路径。
选择start test bench template writer
打开simulation下的test.vt文件。
// Copyright (C) 1991-2013 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 "10/11/2020 23:13:57"
// Verilog Test Bench template for design : test
//
// Simulation tool : ModelSim-Altera (Verilog)
//
`timescale 1 ps/ 1 ps
module test_vlg_tst();
// constants
// general purpose registers
reg eachvec;
// test vector input registers
reg clk;
reg clr;
// wires
wire half_clk;
// assign statements (if any)
test i1 (
// port map - connection between master ports and signals/registers
.clk(clk),
.clr(clr),
.half_clk(half_clk)
);
initial
begin
clk = 0;
clr = 0;
#100;
clr = 1;
#2000;
$stop;
// code that executes only once
// insert code here --> begin
// --> end
$display("Running testbench");
end
always
# 20 clk = ~clk;
// optional sensitivity list
// @(event1 or event2 or .... eventn)
begin
// code executes for every event on sensitivity list
// insert code here --> begin
always
@eachvec;
// --> end
end
endmodule
代码如上,其实主要是加入了信号的初始值。其他系统自动生成了。然后再编译一次,相当于保存刚刚修改的代码。
编译完成后,点击settings。
点击compile test bench,再点击test benches
点击new,
建立好名字,然后选择刚刚的.vt文件add,点击ok。
点击rtl仿真。
可以看到modesim中的波形正确,大功告成!