Modelsim simulation of PLL

Source: Internet
Author: User

After reading Modelsim learning materials for a long time, I wrote a simple PLL simulation experiment. This experiment simulates the 50 MHz clock input on the de2 board and outputs a MHz clock after the PLL.

At the same time, use the. Do file to replace annoying mouse operations.

First, a PLL module is provided in Quartus. The input is CLK, 50 MHz, and the output is clk_100.

Open the PLL. V file,

 
// ================================================ ========================================/// File Name: PLL. V // megafunction name (s): // altpll /// simulation library files (s ): // altera_mf // ========================================== ======================================

This header file tells us that the PLL requires a library named altera_mf.

Find this file in the EDA/sim_lib folder under the Quartus installation directory.

Compile the simulation file box. Do file as follows:

Create a project folder named PLL, and create two folders in it. SRC and Modelsim, Src store the source file and simulation file, and Modelsim store the. Do file.

SRC contains four files:

Pll_module:

 1   // 'Timescale 1 PS/1 PS  
2 Module Pll_module (
3 CLK,
4 Clk_100m
5 );
6
7 Input CLK;
8 Output Clk_100m;
9
10 PLL pll_u1 (
11 . Inclk0 (CLK ),
12 . C0 (clk_100m)
13 );
14
15 Endmodule

Pll_module_tb:

 1 'Timescale 1 PS/ 1 PS
2 Module Pll_module_tb;
3
4 Reg CLK;
5 Wire Clk_100m;
6
7 Pll_module U1 (
8 . CLK (CLK ),
9 . Clk_100m (clk_100m)
10 );
11
12 Initial
13 Begin
14 CLK = 0 ;
15 End
16
17 Always # 10000 CLK = ~ CLK;
18
19
20 Endmodule

 

 

In The Modelsim folder, assume the PLL. Do file.

PLL. Do:

 1 # Creat a work lib
2 Vlib work
3
4 # Map the work lib to current lib
5 Vmap work
6
7 # Compile the source files
8 Vlog D:/test/PLL/src/altera_mf.v
9 Vlog D:/test/PLL/src/PLL. v
10 Vlog D:/test/PLL/src/pll_module.v
11 Vlog D:/test/PLL/src/pll_module_tb.v
12
13 # Start Simulation
14 Vsim-novopt work. pll_module_tb
15
16 # Add Wave
17 Add wave-Hex /*
18
19 Run 500000000

This file contains four parts:

Create a working database with 1-2 rows as work. Note that # Is a comment.

The 4-5 rows map the created work Library to the Work work library in ModelSim.

8-11: Compile the above four source files.

14. The pll_modelsim_tb file in the behavior simulation work library. novopt indicates that optimization is prohibited.

17. The Hex is hex in hexadecimal notation, And/* is represented by all waveforms. You can also add the waveforms you want to see here.

19. simulation starts.

 

Then enter the do PLL. Do command in The Modelsim command line to start simulation, saving the mouse operation process.

Simulation results:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.