A Tutorial for Using Altera Quartus II Computer-Aided...

14
© Sin Ming Loo, Department of Electrical and Computer Engineering, Boise State University, May 2004. Page 1 A Tutorial for Using Altera Quartus II Computer-Aided Design Software Altera Quartus II is a sophisticated programmable logic computer-aided design (CAD) software. It has a wide range of capabilities such as design entry, simulation, synthesis, verification, and device programming. In this course, we will be using the design entry (schematics capture technique) and simulation (waveform or timing sim- ulation) capabilities. Quartus II has been incorporated to this Digital Systems course to facilitate the learning pro- cess. There will be times when the theory presented during lecture may not make sense, this CAD software will provide the tool to put together a simple digital circuit to help understand the theory. Since Quartus II is an indus- trial strength CAD software, changes and updates to the software will take place all the time. However, during the duration of this course Quartus II Version 4.0 (full version) will be used. There is also a web edition with the simi- lar graphical user interface (limited capability) for use if you are to work at home. If you would like to install the web edition Quartus II software at home, you can obtain the 138 MB installation CD from me and follow the web address provided in getlicense.txt to get a software license after the software is installed. Since this is an industrial strength CAD software, thus the learning curve is potentially steep (especially the first few laboratories). So, be patient and ask question when you are working through this tutorial. 1. Introduction This tutorial assumes that you know the basic working of a computer. The goal of this tutorial is to show you how to enter a design into the software and how to generate the proper waveform input to test the working of your design. It is important to note that this software facilitates the learning processing, it does not in any way solve the problem for you unless you know something about what you trying to do. In the Quartus II design environment, each logic design is considered as a project. Thus, it is best to create a folder (or directory) to store all the files related to a particular project. The commands that we will use in this tuto- rial are accessed through menus located below the title bar. We will use the convention Menu 1 Command 2 to indicate that the user first selects one of the pull-down menu and then selects the command. Figure 1 shows the File New Project Wizard, where the user selects File pull-down menu then the New Project Wizard command. All selections are made by high-lighting and clicking the left mouse button. If the right mouse button click is required, it will be explicitly mentioned. Quartus II provides on-line documentation that answers many of the questions that you might have when using the software. The documentation can be accessed from the Help menu window. While using any application, pressing the F1 function key on the keyboard will take you directly to the Help documenta- tion. In addition, there is documentation that you can access at http://www.altera.com/software/quartus. In fact, there is another way that will help you during this learning process the person sitting next to you in the laboratory. 1. As shown in Figure 1, Menu may be File, Edit, Format, View, Special, Graphics, Table, Window, or Help. 2. Command is one of those commands that you can select under each Menu Figure 1: Menu selection

Transcript of A Tutorial for Using Altera Quartus II Computer-Aided...

Page 1: A Tutorial for Using Altera Quartus II Computer-Aided ...ece.boisestate.edu/~smloo/ee230summer2004/tutorial/Tutorial-1.pdf · A Tutorial for Using Altera Quartus II Computer-Aided

© Sin Ming Loo, Department of Electrical and Computer Engineering, Boise State University, May 2004. Page 1

A Tutorial for Using Altera Quartus II Computer-Aided Design Software

Altera Quartus II is a sophisticated programmable logic computer-aided design (CAD) software. It has a widerange of capabilities such as design entry, simulation, synthesis, verification, and device programming. In thiscourse, we will be using the design entry (schematics capture technique) and simulation (waveform or timing sim-ulation) capabilities. Quartus II has been incorporated to this Digital Systems course to facilitate the learning pro-cess. There will be times when the theory presented during lecture may not make sense, this CAD software willprovide the tool to put together a simple digital circuit to help understand the theory. Since Quartus II is an indus-trial strength CAD software, changes and updates to the software will take place all the time. However, during theduration of this course Quartus II Version 4.0 (full version) will be used. There is also a web edition with the simi-lar graphical user interface (limited capability) for use if you are to work at home. If you would like to install theweb edition Quartus II software at home, you can obtain the 138 MB installation CD from me and follow the webaddress provided in getlicense.txt to get a software license after the software is installed.

Since this is an industrial strength CAD software, thus the learning curve is potentially steep (especially thefirst few laboratories). So, be patient and ask question when you are working through this tutorial.

1. IntroductionThis tutorial assumes that you know the basic working of a computer. The goal of this tutorial is to show you howto enter a design into the software and how to generate the proper waveform input to test the working of yourdesign. It is important to note that this software facilitates the learning processing, it does not in any way solve theproblem for you unless you know something about what you trying to do.

In the Quartus II design environment, each logic design is considered as a project. Thus, it is best to create afolder (or directory) to store all the files related to a particular project. The commands that we will use in this tuto-rial are accessed through menus located below the title bar. We will use the convention Menu1 ⇒ Command2 toindicate that the user first selects one of the pull-down menu and then selects the command. Figure 1 shows the File⇒ New Project Wizard, where the user selects File pull-down menu then the New Project Wizard command. Allselections are made by high-lighting and clicking the left mouse button. If the right mouse button click is required,it will be explicitly mentioned. Quartus II provides on-line documentation that answers many of the questions thatyou might have when using the software. The documentation can be accessed from the Help menu window. Whileusing any application, pressing the F1 function key on the keyboard will take you directly to the Help documenta-tion. In addition, there is documentation that you can access at http://www.altera.com/software/quartus.

In fact, there is another way that will help you during this learning process → the person sitting next to you inthe laboratory.

1. As shown in Figure 1, Menu may be File, Edit, Format, View, Special, Graphics, Table, Window, or Help.2. Command is one of those commands that you can select under each Menu

Figure 1: Menu selection

Page 2: A Tutorial for Using Altera Quartus II Computer-Aided ...ece.boisestate.edu/~smloo/ee230summer2004/tutorial/Tutorial-1.pdf · A Tutorial for Using Altera Quartus II Computer-Aided

© Sin Ming Loo, Department of Electrical and Computer Engineering, Boise State University, May 2004. Page 2

2. Starting a New ProjectTo start working on a new design, we first have to create a new project. Quartus II provides a wizard to simplifythis task. To start the software, double clicking on the Quartus II 4.0 icon on the desktop. Depending on the speedof the computer, the software startup process may take a few seconds. Also, depending on the configuration/setupof the software, Quartus II may ask whether to check for software update (click No if this option shows up). Oncethe software has been successfully loaded, you will see the main Quartus II 4.0 display as shown in Figure 2.

Select File ⇒ New Project Wizard to reach an introduction to this new project wizard, click Next at this win-dow and it will take you to the window as shown in Figure 3. As you can see in Figure 3, the working directory ofthe project has been set to c:\tutorial\design1. The project name has been chosen to be design_schematic becausethe schematic capture design technique will be utilize as the designated design entry method. The top-level entrywill be design_schematic also. If you are not sure what it means by top-level, here is an explanation. Since the pre-requisite of this course is a programming course, the explanation will be given using a programming example. In aprogramming assignment or project that you have done previously, there is always one function that is designatedas the main function. Using C programming language as an example, main() is the top-level and other functions(files) that are used in main() can be thought of as component. When you have completed filling the boxes asshown in Figure 3, click Next. This message appears, “Directory c:\tutorial\design1 does not exist. Do you want tocreate it?” Since we have not yet created c:\tutorial\design1, click Yes, which will leads to Figure 4. Within thiswindow, the user/designer can specify existing file(s) to be included in this project, since we do not have any file toinclude, no changes are required in this window and click Next. This will lead you to Figure 5. We will solely beusing Quartus II for your design entry and simulation, no changes are required and click Next to go to Figure 6.

Figure 2: The main Quartus II screen

Page 3: A Tutorial for Using Altera Quartus II Computer-Aided ...ece.boisestate.edu/~smloo/ee230summer2004/tutorial/Tutorial-1.pdf · A Tutorial for Using Altera Quartus II Computer-Aided

© Sin Ming Loo, Department of Electrical and Computer Engineering, Boise State University, May 2004. Page 3

Figure 3: Specifying the project folder location and project name

Working directory

Project Name

Name ofTop-levelSchematic

Figure 4: A window to include existing file(s) to this new project

Page 4: A Tutorial for Using Altera Quartus II Computer-Aided ...ece.boisestate.edu/~smloo/ee230summer2004/tutorial/Tutorial-1.pdf · A Tutorial for Using Altera Quartus II Computer-Aided

© Sin Ming Loo, Department of Electrical and Computer Engineering, Boise State University, May 2004. Page 4

It is at this location that we specify the target device of our design. Since we will only use the schematic designentry and waveform simulation capabilities, the design selection is not important at this point in time. However, apotential prototying board that we can in this course contain a Flex 10K device, select the device family as shownin Figure 6 and click Next. This will lead you to a window specifying a specific device. You should specify adevice as shown in Figure 7 and click Next. This will take you to Figure 8, a summary of project settings. Click Fin-ish.

Figure 5: A window to include other EDA tools

Figure 6: A window to specify target device family

Page 5: A Tutorial for Using Altera Quartus II Computer-Aided ...ece.boisestate.edu/~smloo/ee230summer2004/tutorial/Tutorial-1.pdf · A Tutorial for Using Altera Quartus II Computer-Aided

© Sin Ming Loo, Department of Electrical and Computer Engineering, Boise State University, May 2004. Page 5

Figure 7: A window to specify target device

Figure 8: A summary of project settings

Page 6: A Tutorial for Using Altera Quartus II Computer-Aided ...ece.boisestate.edu/~smloo/ee230summer2004/tutorial/Tutorial-1.pdf · A Tutorial for Using Altera Quartus II Computer-Aided

© Sin Ming Loo, Department of Electrical and Computer Engineering, Boise State University, May 2004. Page 6

3. Design Entry Using Schematic CaptureThere are more than one design entry methods in Quartus II. Two of the most notable techniques are schematiccapture and hardware description language. This section shows you how to enter a simple design using the BlockEditor (schematic capture entry technique). As a simple example, we will use the symbols from the diagram to puttogether a schematic diagram for f1 = a + b and f2 = ab. The circuit diagram for f1 and f2, as well as the truth tables,are shown in Figure 9. This section also shows you how to enter f1 and f2 into Quartus II and verify the correctnessof the designed circuit using the waveform simulation.

Step 1: Draw the Schematic Diagram using Block EditorAt the Quartus II window, select File ⇒ New. Under Device Design Files tab, select Block Diagram/Schematic File(Figure 10) and click OK (This will take you to Figure 11). A total of five design entry methods is shown in Figure10. These options will be discuss as the course progress.

Figure 9: Example logic functions and truth tables

a b f10 0 0

0 1 1

1 0 1

1 1 1

a b f20 0 0

0 1 0

1 0 0

1 1 1

Figure 10: Type of design entry file

Page 7: A Tutorial for Using Altera Quartus II Computer-Aided ...ece.boisestate.edu/~smloo/ee230summer2004/tutorial/Tutorial-1.pdf · A Tutorial for Using Altera Quartus II Computer-Aided

© Sin Ming Loo, Department of Electrical and Computer Engineering, Boise State University, May 2004. Page 7

Step 2: Importing Symbols to BDF fileThe block diagram editor contains several libraries with circuit elements (symbols) that can be imported into ourschematic. To implement f1 and f2, we will use the primitives library. To access the library, double clicking any-where on the blank schematic diagram. It will bring up the symbol window as shown in Figure 12. By clicking onthe “+” next to “c:/altera/quartus/libraries/”, then the “+” next to “primitives”, and finally the “+” next to “logic”, youwill have what you see in Figure 12. Now select and2 and click OK, place and2 at the desire location by clicking inthe block1.bdf window. Then go back to the symbol library by double clicking in the block1.bdf window to get theor2 symbol, again under c:/altera/quartus/libraries ⇒ primitives ⇒ logic. The symbols can be rotated to the desireposition. You can do so by selecting the symbol and go to Edit menu to select the desire command. There is anothertrick to get multiple copy of one symbol. First, hold down the ctrl key. Then, click and drag the mouse away fromthe desire gate symbol to be copied. Now, arrange the symbols as shown in Figure 13.

Figure 11: Quartus II Block Editor window

Page 8: A Tutorial for Using Altera Quartus II Computer-Aided ...ece.boisestate.edu/~smloo/ee230summer2004/tutorial/Tutorial-1.pdf · A Tutorial for Using Altera Quartus II Computer-Aided

© Sin Ming Loo, Department of Electrical and Computer Engineering, Boise State University, May 2004. Page 8

Step 3: Importing Input and Output SymbolsWith the gate symbols imported, it is time to import the input and output ports of the circuit (access the outsideworld!). To import the input and output ports, follow c:/altera/quartus/libraries ⇒ primitives ⇒ pin to input and out-put symbol. We need two input and two output symbols. Once the import process is completed, you should have

Figure 12: Quartus II Block Editor window

Figure 13: Imported symbols

Page 9: A Tutorial for Using Altera Quartus II Computer-Aided ...ece.boisestate.edu/~smloo/ee230summer2004/tutorial/Tutorial-1.pdf · A Tutorial for Using Altera Quartus II Computer-Aided

© Sin Ming Loo, Department of Electrical and Computer Engineering, Boise State University, May 2004. Page 9

Figure 14. It is also the time to save the bdf file. Click on the diskette icon on the top left corner and save the bdf filewith filename design_schematic.bdf.

Step 4: Assigning Input/Output Pin NamesWe will need to change the input and output pin names. Let’s change “pin_name” to “a”. You can do so by doubleclicking at pin_name which will activate the change function. You can erase the existing name and type in the newpin name. Now, make these changes, “pin_name” to “a”, “pin_name2” to “b”, “pin_name3” to “f2”, and “pin_name4”to “f1”.Step 5: Connecting SymbolsThe next step is to draw wires to connect the symbols. The method to draw the wire could be frustrating at first, soyou really need to be patient on this one and practice until you get good at it (or get the instructor/lab instructor tohelp you). If you point the mouse cursor to the wire end of the input symbol, you will see the cursor turns into a “+”symbol. At this time you can click on the wire end of the input symbol and drag the wire to the desire length or con-nect to the desire component. The desire location is to connect input a to one of the and2’s and or2’s gate input.Under the View pull-down menu, there is a function to magnify the schematic diagram if this will help you whileyou are connecting the wires. To connect a terminal to the middle of the wire, start at the terminal and go to thewire.

Figure 14: Imported symbols

Figure 15: Circuit with all symbols connected with wires

Page 10: A Tutorial for Using Altera Quartus II Computer-Aided ...ece.boisestate.edu/~smloo/ee230summer2004/tutorial/Tutorial-1.pdf · A Tutorial for Using Altera Quartus II Computer-Aided

© Sin Ming Loo, Department of Electrical and Computer Engineering, Boise State University, May 2004. Page

4. Synthesizing/Compiling the CircuitWith the circuit put together, we need to synthesize the circuit as shown in Figure 15 before we can start the simu-lation. During this process, the tool (Quartus II) will help us verify whether there is any error in the circuit that youhave just put together. Circuit synthesis is similar to using a software compiler to compile your C program or Javaprogram. The difference is that software compiler generates code for execution by processor. The synthesis processusually generate hardware for some kind of programming logic or to design application specific circuit. Select Pro-cessing ⇒ Start Compilation to start the synthesis process. In fact, there is also a short cut for this since you will bedoing quite a few synthesis (or compilation)! Do you see the a solid Mahogany (maybe red) triangle (like the iconon your VCR and DVD play button)?

If the compilation is successful, you will get the following screen (Figure 16). If the compilation failed, checkthe wire connections, then recompile. If it still does not compile, get the instructor to help you. The second screendisplays a summary of the compilation. It shows the resources utilization of the target device. We will discussabout this as the course progresses.

There is one thing worthy of mentioning! Click OK at the Full Compilation was successful screen. Then selectthe Fitter Equations as shown in Figure 17. The logic circuit that you entered may not be the minimized equation.The equation shown in Fitter Equations file is the minimized equation that will be implemented. During thiscourse, you will have problems where you need to minimize the number of gates used, this will be a good tool tohelp you confirm your solution to a particular problem.

Figure 16: Compilation status

Figure 17: Location to find the minimize equation

ab

a + b

Page 11: A Tutorial for Using Altera Quartus II Computer-Aided ...ece.boisestate.edu/~smloo/ee230summer2004/tutorial/Tutorial-1.pdf · A Tutorial for Using Altera Quartus II Computer-Aided

© Sin Ming Loo, Department of Electrical and Computer Engineering, Boise State University, May 2004. Page

In addition to the Fitter Equations that we talked about. The printer icons on the left side of Figure 17 corre-spond to a summary of all the task carried out during the synthesis/compilation process.

5. Simulating the CircuitWith successful compilation, this means that there is no error in our circuit, we can now simulate the circuit. Beforethe circuit can be verify, it is necessary to create the waveforms, or called test vectors, as the input signals. TheQuartus II Waveform Editor is used to create the waveforms.

To create the waveforms, we need to start the Waveform Editor. You can do so by File ⇒ New. Then, select theOther Files tab and Vector Waveform File. Click OK when the proper selection as shown in Figure 18 has beenmade.

Figure 18: Select Vector Waveform File to prepare waveform

Figure 19: Blank Waveform file

DoubleClick Here

Page 12: A Tutorial for Using Altera Quartus II Computer-Aided ...ece.boisestate.edu/~smloo/ee230summer2004/tutorial/Tutorial-1.pdf · A Tutorial for Using Altera Quartus II Computer-Aided

© Sin Ming Loo, Department of Electrical and Computer Engineering, Boise State University, May 2004. Page

Let’s save the file using the name design_schematic.vwf. The first simulation setup is to set the simulation endtime. Set the desire simulation to run from 0 to 20 ns by selecting Edit ⇒ End Time. Next, we need to bring all theinput and output signals into the waveform file. Double click in the area with text “Double Click Here“ as shown inFigure 19. The screen as shown in Figure 20 appears. Click on the Node Finder button. At the Node Finder win-dow, change the Filter to Pin: all and click on the List button on the right hand side (Figure 21).

Select all the signal on the left window by holding down the ctrl key on the keyboard and select using the leftmouse button. Then, click on the greater (>) button at around the middle of Figure 21 to add the selected signals tothe right side window. Then, click OK. Click OK once more at the Insert Node or Bus window.

Once the process is completed, you will see four signals in your waveform file. Now, you need to make surethat Snap to Grid is off. You can check this by View ⇒ Snap To Grid (not depressed equal to off!). Now, you areready to add the waveform freely! Using the mouse pointer and left mouse button, select the area as shown in Fig-ure 22. Then, click on the “1” Button as shown in Figure 22. Continue modify the waveform according to Figure 23.

We are almost ready to simulate the design! There is one setup that we need to change. You should followAssignments ⇒ Settings (Figure 24). Then, select Simulator on the left window and change the Simulation Mode toFunctional. Click OK.

Figure 20: Insert Node of Bus

Figure 21: Select signals

Page 13: A Tutorial for Using Altera Quartus II Computer-Aided ...ece.boisestate.edu/~smloo/ee230summer2004/tutorial/Tutorial-1.pdf · A Tutorial for Using Altera Quartus II Computer-Aided

© Sin Ming Loo, Department of Electrical and Computer Engineering, Boise State University, May 2004. Page

Figure 22: Add waveform

HighlightArea

“1” button

Figure 23: Completed waveform

Page 14: A Tutorial for Using Altera Quartus II Computer-Aided ...ece.boisestate.edu/~smloo/ee230summer2004/tutorial/Tutorial-1.pdf · A Tutorial for Using Altera Quartus II Computer-Aided

© Sin Ming Loo, Department of Electrical and Computer Engineering, Boise State University, May 2004. Page

Almost there! Now issue, Processing ⇒ Generate Functional Simulation Netlist. Click Yes to save change to wave-form. Click OK at the Functional Simulation netlist generation was successful. Finally, issue Processing ⇒ StartSimulation. A new waveform window will appear with the output signals.

Figure 24: Functional simulation

Figure 25: Functional simulation results