Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)
16642 Discussions

Complete Quartus/ModelSim-Altera project

Altera_Forum
Honored Contributor II
2,679 Views

Are there an simple but complete VHDL projects available for Quartus 14.0 that include a VHDL test bench file? Simple meaning that the design is a counter or shift register. It has been about 10 years since I used Quartus and it is very different. I would like a known good project to experiment with to get started again. 

 

Ideally a zip file with all the files and sub-folders already in the correct places. 

 

Scott
0 Kudos
12 Replies
Altera_Forum
Honored Contributor II
1,020 Views

Hey Scott, 

 

Do you have a development kit? If so, which one? (I might have an example project for it). 

 

Cheers, 

Dave
0 Kudos
Altera_Forum
Honored Contributor II
1,020 Views

Dave, 

 

This is my second reply. The first one hasn't shown up. 

 

I ordered a Terasic DE1-SoC. Using their golden top file I then translated it into VHDL adding some code so that a counter would cause some of the 7 segment digits to count up in hex. I am using the web tools for now. The code compiles without problem. Now I was trying to create a test bench. Most of my simulation experience was with .VEC files in the Maxplus and Maxplus II days. 

 

Scott
0 Kudos
Altera_Forum
Honored Contributor II
1,020 Views

Hi Scott, 

 

 

--- Quote Start ---  

 

I ordered a Terasic DE1-SoC 

 

--- Quote End ---  

 

Sorry, I don't have that one :) 

 

 

--- Quote Start ---  

 

I was trying to create a test bench 

 

--- Quote End ---  

 

You've got several options, depending on how complicated your system is. For example, lets say you use the ARM processor on the SoC and you connect to your hex display. What should you simulate; 

 

1. Everything? 

 

Eg., the whole ARM processor including booting U-Boot and/or Linux, and then running an application to toggle the I/O connected to your display 

 

2. The specific component you just designed? 

 

Eg., create a testbench with the hex display and the bus interface used to read/write to the hex display registers. 

 

Obviously (2) is what you really want to look at. The bus interface is what you really want to understand how to simulate, as once you understand how to interface your hex display to the ARM core, you've got the basics for interfacing anything. 

 

You've got a couple of ways you can interface to the hex display from a Qsys system (Altera's system builder); 

 

1. Use an existing component such as the PIO core, and then use that to control your hex display 

 

2. Create a _hw.tcl file that descibes your hex display as an Avalon-MM or AXI component 

 

I'd recommend understanding both methods. 

 

How does this sound? What parts of this description do you understand, and which parts do you not? 

 

Cheers, 

Dave
0 Kudos
Altera_Forum
Honored Contributor II
1,020 Views

Dave, 

 

I picked that board because it has a 1MHz A/D. The code will eventually be for several faster A/Ds. Too fast for the ARM to be directly involved. So, initially I will be working in logic only. Any simple example (no CPU) will do for now. I can port it to the board I have. A counter or shift register or some other function easy to follow. 

 

Scott
0 Kudos
Altera_Forum
Honored Contributor II
1,020 Views

 

--- Quote Start ---  

 

I picked that board because it has a 1MHz A/D. The code will eventually be for several faster A/Ds. Too fast for the ARM to be directly involved. So, initially I will be working in logic only. Any simple example (no CPU) will do for now. I can port it to the board I have. A counter or shift register or some other function easy to follow. 

 

--- Quote End ---  

 

 

This thread has a basic Modelsim simulation example; 

 

http://www.alteraforum.com/forum/showthread.php?t=32386 

 

Cheers, 

Dave
0 Kudos
Altera_Forum
Honored Contributor II
1,020 Views

Under ModelSimAltera-Help-PDF Documentation there is a Tutorials option. Ran through one. Then tried to get my own working. Not having much luck. The vhdl code is about 25 lines long. The pin declarations and related lines total about 245. The archive (qar file) is about 58kB. The simulation file was not included in the archive and is another 9kB. I would like to find someone willing look at them and help get the first version going. After that I can usually make progress. 

 

Scott
0 Kudos
Altera_Forum
Honored Contributor II
1,020 Views

Hi Scott, 

 

--- Quote Start ---  

 

I would like to find someone willing look at them and help get the first version going. After that I can usually make progress. 

 

--- Quote End ---  

 

I can take a look. Email me the archive file (my forum name is my email address). 

 

Cheers, 

Dave
0 Kudos
Altera_Forum
Honored Contributor II
1,020 Views

Hi Scott, 

 

Here's a Modelsim testbench of a hex display component. Follow through the readme.txt file ... 

 

Hexadecimal Display Example --------------------------- 8/9/2014 D. W. Hawkins (dwh@ovro.caltech.edu) This example shows how to use Modelsim to test a hexadecimal display component. The source code shows two methods for using VHDL to drive a hexadecimal display 1. A VHDL component; see src/hex_display.vhd 2. A VHDL function; see src/hex_display_pkg.vhd The testbench test/hex_display_tb.vhd creates an instance of both components and drives 4-bit hex values onto their input puts. The hex display package defines another function that decodes the 7-bit hex display output and converts it back to a 4-bit value. The testbench uses that function to check that the display values are correct. The simulation can be run as follows; 1. Unzip the example, eg., into c:\temp\hex_display 2. Start Modelsim 3. Change directory to the example, i.e., type the following ModelSim> cd {c:\temp\hex_display} where "ModelSim>" is the prompt, so does not need to be typed in. The paranthasis {} around the path make sure that a Windows path back-slashed are correctly interpreted by Tcl. You can also use Tcl paths, i.e., ModelSim> cd c:/temp/hex_display 4. Run the simulation script ModelSim> source scripts/sim.tcl This script contains Modelsim commands. Read it to understand the compilation sequence. The output from this script run using Modelsim-ASE 10.1b (from Quartus 12.1sp1) is as follows; # # Hex display testbench simulation script # --------------------------------------- # # * Setup paths # * Setup Modelsim work # * Build the code # Model Technology ModelSim ALTERA vcom 10.1b Compiler 2012.04 Apr 27 2012 # -- Loading package STANDARD # -- Loading package TEXTIO # -- Loading package std_logic_1164 # -- Loading package NUMERIC_STD # -- Compiling package hex_display_pkg # -- Compiling package body hex_display_pkg # -- Loading package hex_display_pkg # Model Technology ModelSim ALTERA vcom 10.1b Compiler 2012.04 Apr 27 2012 # -- Loading package STANDARD # -- Loading package TEXTIO # -- Loading package std_logic_1164 # -- Compiling entity hex_display # -- Compiling architecture behave of hex_display # * Build the testbench # Model Technology ModelSim ALTERA vcom 10.1b Compiler 2012.04 Apr 27 2012 # -- Loading package STANDARD # -- Loading package TEXTIO # -- Loading package std_logic_1164 # -- Loading package NUMERIC_STD # -- Compiling package log_pkg # -- Compiling package body log_pkg # -- Loading package log_pkg # Model Technology ModelSim ALTERA vcom 10.1b Compiler 2012.04 Apr 27 2012 # -- Loading package STANDARD # -- Loading package TEXTIO # -- Loading package std_logic_1164 # -- Loading package NUMERIC_STD # -- Loading package hex_display_pkg # -- Loading package log_pkg # -- Compiling entity hex_display_tb # -- Compiling architecture test of hex_display_tb # # Testbench procedure # -------------------- # # hex_display_tb - Run the testbench # The script defines a Tcl procedure called hex_display_tb that loads the hex_display_tb testbench, populates the wave window, and then runs the simulation. Read sim.tcl to see the procedure. 5. Run the simulation testbench ModelSim> hex_display_tb The output after running this command is # vsim -novopt hex_display_tb # Loading std.standard # Loading std.textio(body) # Loading ieee.std_logic_1164(body) # Loading ieee.numeric_std(body) # Loading std.env(body) # Loading work.hex_display_pkg(body) # Loading work.log_pkg(body) # Loading work.hex_display_tb(test) # Loading work.hex_display(behave) # # ============================================================================== # Hex display testbench # ============================================================================== # # ============================================================================== # 1: Check the hex display component # ============================================================================== # 0 ns: checking values 0h to Fh # 160 ns: checks pass # # ============================================================================== # 2: Check the hex displayfunction # ============================================================================== # 160 ns: checking values 0h to Fh # 320 ns: checks pass # # ============================================================================== # Simulation complete # ============================================================================== # ** Note: stop # Time: 370 ns Iteration: 0 Instance: /hex_display_tb # Break in Process line__78 at C:/temp/hex_display/test/hex_display_tb.vhd line 162 Viola! You have two working hex display drivers. Now create a Quartus design and confirm that they synthesize to exactly the same logic.  

Enjoy! 

 

Cheers, 

Dave
0 Kudos
Altera_Forum
Honored Contributor II
1,020 Views

Dave, 

 

Thank you. A request. How would the same simulation be done using the GUI? I tried a few times a few different ways. Lots of compile errors. 

 

Scott
0 Kudos
Altera_Forum
Honored Contributor II
1,020 Views

 

--- Quote Start ---  

 

A request. How would the same simulation be done using the GUI? I tried a few times a few different ways. Lots of compile errors. 

 

--- Quote End ---  

 

I've no idea, since I never run Modelsim from the Quartus GUI. 

 

What is the reason you want to run Modelsim from Quartus?  

 

To some degree, the tools have separate purposes; you use Modelsim to design your HDL code via testbenches, and then use Quartus for synthesis (which checks you have used synthesizeable HDL code). The lines begin to blur a little when you start to use Quartus to create HDL for you, eg., a Qsys system, but even then, you can have the Quartus GUI open and the Modelsim window open, and not need Quartus to launch Modelsim for you. In fact that would be a pain, since you would have to repopulate the Modelsim wave window each time Quartus relaunched it. 

 

Cheers, 

Dave
0 Kudos
Altera_Forum
Honored Contributor II
1,020 Views

ModelSim-Altera has it's own GUI. The tutorials I ran used that. I used to do everything command line driven but some tools I use no longer give that option so I am adapting. 

 

Scott
0 Kudos
Altera_Forum
Honored Contributor II
1,019 Views

Hi Scott, 

 

--- Quote Start ---  

ModelSim-Altera has it's own GUI. The tutorials I ran used that. I used to do everything command line driven but some tools I use no longer give that option so I am adapting. 

 

--- Quote End ---  

 

Ah, sorry, I misinterpreted your question. 

 

If you followed the Modelsim tutorials, then I think it produces a log file. If you look at that log file, it essentially uses all the commands I wrote in the sim.tcl script. 

 

You can use the Modelsim GUI to build; hex_display_pkg.vhd, hex_display.vhd, and hex_display_tb.vhd, and then figure out whatever the GUI equivalent to "vsim hex_display_tb" is and then whatever the GUI command for "do scripts/hex_display_tb.do" is. Personally I've never had much of a reason to use the GUI "GUI" elements, when the Tcl console works great! (And arguably, it is part of the GUI) :) 

 

Cheers, 

Dave
0 Kudos
Reply