[Documentation]. Amy electronics-getting started with Modelsim designed using OpenGL

Source: Internet
Author: User
ArticleDirectory
    • Description
    • Platform
    • Content
    • Advanced Reading
    • Reference
Description

Part of this article, from my translation of the terasic DE2-115 in English entry documents.

 

Platform

Software: Modelsim-Altera 6.5e (Quartus II 10.0) Starter Edition

 

Content 1 design process

The basic process of Modelsim simulation is as follows:

Figure 1.1 Basic Process of Modelsim simulation

 

2. Start 2.1 create a project

After Modelsim is enabled, the screen is shown in figure 2.1.

Figure 2.1 Modelsim Screen

 

1. SelectFile> New> prejectCreate a new project. OpenedCreate ProjectIn the dialog box, you can specify the project name, path, and default library name. GenerallyDefault library nameIs work. The specified name is used to create a working folder in the project folder. As shown in Dialog Box 2.2, you can also select a. ini file to Map Library settings, or copy it directly to the project.

Figure 2.2 create a project dialog box

 

2. Follow the steps shown in Figure 2.3 to setProject nameIsLed_flow,Project locationIsD:/led_flow.

Figure 2.3 enter project information

 

When you clickOKButton appears at the bottom of the Main WindowProjectTag, as shown in Figure 2.4.

 

Figure 2.4 project tag

 

3.Add items to the ProjectAs shown in Figure 2.5.

Figure 2.5 Add a new project in the project

 

2.2 Add a new project to the Project

InAdd items to the ProjectThe dialog box includes the following options:

    • Create new file-- Use the source file editor to create a new file, such
    • Add existing file-- Add an existing file
    • Create Simulation-- Create a simulation configuration for the specified source file and simulation options
    • Create new folder-- Create a new organizational folder

1. ClickCreate new file. Open the window shown in Figure 2.6.

Figure 2.6 create a project folder

 

2. Enter the file name: led_flow, and select the file type as "OpenGL.

Figure 2.7 enter project file information

 

3. ClickOKTo close this dialog box. The new project file is displayed in the project window. Click Close to closeAdd items to the Project.

Figure 2.8 new design file led_flow.v

 

4. Double-click the led_flow.v file ).

Figure 2.9 led_flowCodeInput window

 

Enter the following test platform code in led_flow.v:

 
'Timescale 1ns/1 nsmodule led_flow; Reg clock_50m; Reg rst_n; wire [9: 0] led; led led_inst (. clk_50m (clock_50m ),. reset_n (rst_n ),. LED (LED); initial begin clock_50m = 0; while (1) #10 clock_50m = ~ Clock_50m; endinitialbegin rst_n = 0; while (1) #10 rst_n = 1; endinitialbegin $ display ($ time, "clock_50m = % d rst_n = % d led = % d ", clock_50m, rst_n, LED); endendmodule

After entering the code, clickSave.

Figure 2.10 enter the testbench code

 

5. SelectFile> New> source> OpenGL, Create a new OpenGL file, as shown in Figure 2.11.

Figure 2.11 create a new OpenGL File

 

6. Enter the following code, as shown in Figure 2.12.

 'timescale 1ns/1 nsmodule led (input clk_50m, // system clock 50 MHz input reset_n, // system reset output Reg [9:0] led // led); Reg [13:0] counter = 0; Reg [3:0] State = 0; 
Always @ (posedge clk_50m, negedge reset_n) if (! Reset_n) Counter <= 0; else counter <= counter + 1 'b1; always @ (posedge counter [13]) if (! Reset_n) State <= 0; else begin if (State = 4 'b1001) State <= 0; else state <= State + 1' B1; end always @ (posedge clk_50m, negedge reset_n) if (! Reset_n) led <= 0; else begin case (state) 4 'b0000: LED <= 10 'b00000 _ 00001; 4 'b0001: LED <= 10' b00000 _ 00010; 4 'b0010: LED <= 10' b00000 _ 00100; 4 'b0011: LED <= 10' b00000 _ 01000; 4 'b0100: LED <= 10' b00000 _ 10000; 4 'b0101: LED <= 10' b00001 _ 00000; 4 'b0110: LED <= 10' b00010 _ 00000; 4 'b0111: LED <= 10' b00100 _ 00000; 4 'b1000: LED <= 10' b01000 _ 00000; 4 'b1001: LED <= 10' b10000 _ 00000; default: LED <= 10' b00000 _ 00001; endcase end endmodule

Figure 2.12 new file input

 

7. SelectFile> Save, Enter the file name: LED. V, and clickSave, 2.13.

Figure 2.13 save led. v

 

8. SelectProject> Add to project> existing file, 2.14.

Figure 2.14 Add a file to the Project

 

9. ClickBrowse, Select led. V, 2.15.

Figure 2.15 select the file to be added to the project

 

10. ClickOpen, InAdd file to the ProjectWindow, clickOK.

 

2.3 compile files

InProjectUnder the tagStatusThe question mark of the column indicates that the file has not been compiled into the project, or the source file has been changed before the final compilation. To compile the file, selectCompile <compile all, Or right-clickProjectLabel, selectCompile> compile all.

 

1. If there is no error here, the message compiled successfully will beTranscriptWindow 2.6.

Figure 2.16 compiled successfully

 

3. Start simulation of simulation project 3.1

1. ClickLibraryIcon, selectWork, Click+To expand the options, and then selectLed_flow. Right-click and select compile, as shown in Figure 3.1.

Figure 3.1 click simulate

 

2. ClickSimulateTo the image shown in Figure 3.2.

 

Figure 3.2 simulation window

 

4. In Figure 3.2, clickLed_flow, Right-click, and selectAdd> to wave> all items in RegionAnd then click the left button. The image shown in Figure 3.3 is displayed.

Figure 3.3 Add to wave

 

3.2 simulation settings

1. After completing the last step, the waveform window appears.

Figure 3.4 waveform window

 

2. InRun LengthThe simulation duration of column input is10 ms, 3.5.

Figure 3.5 set Run Length

 

3. Click the run button, as shown in Figure 3.6.

Figure 3.6 Running Simulation

 

4. After running for several seconds, the simulation result shown in 3.9 is displayed.

Figure 3.7 show simulation results

 

5. ClickZoom outIcon to view the complete simulation waveform, as shown in Figure 3.8.

Figure 3.8 waveform window

 

6. Click+, ExpandLed_flow, As shown in Figure 3.9.

Figure 3.9 show Waveforms

 

By amplifying/downgrading the waveform, you can observe the value of the LED changes, that is, the timing effect of the LED. If it is transplanted to Quartus II, after the appropriate configuration, after comprehensive, timing analysis, pin distribution, configuration and download, you can achieve the effect of the horse running lamp.

 

So far, all the simulation processes have been completed.

 

Advanced Reading

1. Supported by Altera. Modelsim-Altera Software

 

Reference

1. terasic. de2_115_v.1.0_cdrom \ de2_115_tutorials \ modelsim_tutorialals

 

See also

[Study FPGA/FPGA with Amy]. [logical experiment document serialization plan]

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.