ALBRA Contents How to Contact altera Typographic Conventions Introduction Design Flow Before You begin 1-2 What You will learn 1-2 Get started...... gn 1-6 Add a Pll megafunction 1-14 Add a multiplexer Assign cyclo III De nd pir Compile your project Program the device Verify in hard 1-43 Next Steps Altera Corporation i Contents Altera Corporation My First FPGA Design Tutorial ALBRA About this tutorial This tutorial provides comprehensive information that will help you understand how to create an Altera FPGa design and run it on your development board How to contact For the most up-to-date information about Altera products, refer to the Altera following table Information Type Contact (1) Technical support www.altera.com/mysupport/ Technical training www.altera.com/training/ custrain altera com Product literature www.alteracom/literature/ Altera literature services literature altera com FTP site ftp. altera. com Note to table (1) You can also contact your local Altera sales office or sales representative Typographic This document uses the typographic conventions shown below Conventions Visual cue Meaning Bold Type with Initial Command names, dialog box titles, checkbox options and dialog box options are Capital Letters shown in bold, initial capital letters. EXample: Save As dialog box bold type External timing parameters, directory names, project names, disk drive names, filenames, filename extensions and software utility names are shown in bold type. EXamples: fMAX, \designs directory, d: drive, chiptrip gdf file Italic Type with Initial Capital Document titles are shown in italic type with initial capital letters. Example: AN Letters 75: High-Speed Board Design Italic type Internal timing parameters and variables are shown in italic type Examples: tpia, n+1 Variable names are enclosed in angle brackets(< >)and shown in italic type EXample: , . pof file Altera Corporation Typographic Conventions My First FPGA Design Tutorial Visual cue Meaning Initial Capital Letters Keyboard keys and menu names are shown with initial capital letters. EXamples Delete key, the Options menu “ Subheading Title References to sections within a document and titles of on-line help topics are shown in quotation marks. EXample: Typographic Conventions Courier type Signal and port names are shown in lowercase Courier type. Examples: datal tdi, input. Active-low signals are denoted by suffix n, e.g., reset Anything that must be typed exactly as it appears is shown in Courier type. For example:c:\designs\tutorial\chiptrip gdf Also, sections of an actual file, such as a Report File, references to parts of files(e.g, the AHDL keyword SUBDESIGN), as well as logic function names(e.g, TRI)are shown in Courie 1..2.3.and Numbered steps are used in a list of items when the sequence of the items is a, b, c, etc important, such as the steps listed in a procedure Bullets are used in a list of items when the sequence of the items is not important The checkmark indicates a procedure that consists of one step only The hand points to information that requires special attention The caution indicates required information that needs special consideration and understanding and should be read prior to starting or continuing with the CAUTION procedure or process The warning indicates information that should be read prior to starting or ARNING continuing the procedure or processes The angled arrow indicates you should press the Enter key The feet direct you to more information on a particular topic Altera Corporation ALBRA 1. My First FPGA Design May 2007 Introduction Welcome to Altera and the world of programmable logic! This tutorial will teach you how to create a simple FpGa design and run it on your development board. The tutorial takes less than an hour to complete The following sections provide a quick overview of the design flow, explain what you need to get started, and describe what you will learn Design Flow The standard FPGa design flow starts with design entry using schematics or a hardware description language(HDL), such as Verilog hDL or VHDL. In this step, you create the digital circuit that is implemented inside the FPGA. The flow then proceeds through compilation, simulation, and programming and verification in the FPGA hardware(see Figure 1-1 Figure 1-1. Design Flow Design D Compile Simulate Program ardware Verify This tutorial guides you through all of the steps except for simulation Although it is not covered in this document, simulation is very important designs There are two types of simulation, RIL and timing. RTL(or re to learn, and there are entire applications devoted to simulating hardw functional) simulation allows you to verify that your code is manipulating the inputs and outputs appropriately Timing(or post place-and-route) simulation verifies that the design meets timing and functions appropriately in the device Ig See"Next Steps"on page 1-43 for links to further information about simulation Altera Corporation Introduction Before You begin This tutorial assumes the following prerequisites You generally know what an FPGA is. This tutorial does not explain the basic concepts of programmable logic You are somewhat familiar with digital circuit design and electronic design automation (eda) tools You have installed the Altera Quartus@ Ii software on your computer. If you do not have the Quartus II software, you can downloaditfromtheAlterawebsiteatwww.altera.com/download You have an Altera Cyclone( Ill Starter Board (or equivalent)on which you will test your project. Using a development board helps you to verify whether your design is really workin You have gone through the quick start guide and or the getting started user guide for your development kit. These documents ensure that you have Installed the required software e Determined that the development board functions properly and is connected to your computer Installed the uSB-BlasterTM driver, which allows you to program the fpga on the development board with your own design What You will learn In this tutorial, you will perform the following tasks Create a design that causes leds on the development board to blink at a speed that is controlled by an input button--This design is easy to create and gives you visual feedback that the design works. Of course, you can use your Cyclone Ill board to run other designs as well. For the led design, you will write verilog hdl code for a simple 32-bit counter,add a phase-locked loop(PLl) megafunction as the clock source, and add a 2-input multiplexer megafunction when the design is running on the board, you can press an input switch to multiplex the counter bits that drive 4 output leds Altera Corporation My First FPGA Design Tutorial My First FPGA Design concepts about Quartus II projects, such as entering a design using a schematic editor and HDL, compiling your design, and downloading it into the fpga on your development board Develop a foundation to learn more about FPGas--For example, you can create and download digital signal processing(Dsp)functions onto a single chip, or build a multi-processor system, or create anything else you can imagine all on the same chip You don t have to scour data books to find the perfect logic device or create your own asic All you need is your computer, your imagination, and the Cyclone Ill Starter board For information about Altera training classes(both on-line and in person), go to the Altera web site at mysupport. altera. com/etraining/or contact your local Altera sales representative Get started You begin this tutorial by creating a new Quartus ll project. A project is a set of files that maintain information about your fpga design th Quartus II Settings File(. qsf)and Quartus II Project File(. qpf) files are the primary files in a Quartus ll project. To compile a design or make pin assignments, you must first create a project 1. In the Quartus II software, select File> New Project Wizard. The Introduction page opens. See Figure 1-2 Altera Corporation My First FPGA Design Tutoria Get Started Figure 1-2. New Project Wizard: Introduction ew Project Wizard: Introduction luding the Name of the top-level desig Pre the sel les of the Settings dialog bo 2. Click Next 3. Enter the following information about your project: a. What is the working directory for this project? Enter a directory in which you will store your quartus Ii project files for this design, for example, c: altera\my first fpga File names, project names, and directories in the Quartus II software cannot contain spaces b. What is the name of this project? Type my first fpga project? Type my first fpga top. See Figure 1-3. C. What is the name of the top-level design entity for this Altera Corporation My First FPGA Design Tutorial