™Nios Embedded Processor Hardware Tutorial Altera Corporation 101 Innovation Drive San Jose, CA 95134 (408) 544-7000 http://www.altera.comNios Embedded Processor Hardware Tutorial Version 1.0 November 2000 Altera, the Altera logo, and MAX+PLUS II are registered trademarks of Altera Corporation in the United States and other countries. AMPP, APEX, APEX 20K, APEX 20KE, Atlas, BitBlaster, ByteBlaster, ByteBlasterMV, MasterBlaster, MegaLAB, MegaWizard, EP20K100, Quartus, and the Quartus logo are trademarks and/or service marks of Altera Corporation in the United States and other countries. Product design elements and mnemonics used by Altera Corporation are protected by copyright and/or trademark laws. Altera Corporation acknowledges the trademarks of other organizations for their respective products or services mentioned in this document, including the following: Microsoft is a registered trademark and Windows and Windows NT are trademarks of Microsoft Corporation. Altera reserves the right to make changes, without notice, in the devices or the device specifications identified in this document. Altera advises its customers to obtain the latest version of device specifications to verify, before placing orders, that the information being relied upon by the customer is current. Altera warrants performance of its semiconductor products to current specifications in accordance with Altera’s standard warranty. Testing and other quality control techniques are used to the extent ...
This tutorial introduces you to the Nios™embedded processor. It shows you how to use the Quartus™software to create and process your own Nios embedded processor design that interfaces with components provided on the Nios development board. The sections in this tutorial guide you through the steps necessary to create, compile, and download a 32-bit Nios embedded processor design, callednios_system_module. A Nios system module is composed of a Nios embedded processor and its associated system peripherals and interconnections. After you create thenios system_moduledesign, you can download it into _ an Altera®APEX™device. When you download the design to the device, the system module pins are logically connected to pins on the APEX device. The external physical pins on the APEX device are in turn connected to other hardware components on the Nios development board, allowing the Nios embedded processor to interface with RAM, flash memory, LEDs, LCDs, switches, and buttons. The tutorial is divided into the following three sections: ■“Design Entry”on page 3teaches you how to create the Nios system module in a Block Design File (.bdf) using theMegaWizard Plug-In Manager™- Nios System Builder. This section also teaches you how to connect the system module ports to pins in the APEX device. ■“Compilation”on page 33teaches you how to compile the Nios embedded processor system module using Compiler settings, pin assignments, and EDA tool settings to control compilation processing. ■“Programming”on page 43teaches you how to use the Quartus Programmer and the ByteBlasterMV™cable to download the design to an APEX device. It also teaches you how to download the design to a flash memory device provided on the Nios development board.
Altera Corporation
1
Nios Embedded Processor Hardware Tutorial
2
1
This tutorial assumes that you have completed the following prerequisite items: ■Installed the following software on a PC: –Quartus software version 2000.05, with support for the APEX EP20K200E device, as described in the Quartus Installation and Licensing for PCsmanual –Exemplar Logic LeonardoSpectrum software version 1999.1j licensed for Verilog HDL. If you have a VHDL license, replace references to Verilog HDL with VHDL in this tutorial. –Nios embedded processor –GNUPro®Nios software development tools ■Set up the Nios development board, as described in the Nios Embedded Processor Quick Start Guide ■Installed the ByteBlaster driver, as described in the Quartus Installation and Licensing for PCsmanual ■Learned the basic features and operation of the Quartus software, as described in theQuartus Tutorialmanual.
Tutorial Files
This tutorial assumes that you create and save your files in a working directory on thed:drive on your computer. If your working directory is on another drive, substitute the appropriate drive name. The Nios embedded processor installation creates the following directories in the\altera\excaliburdirectory by default:
Directory Name: Description: _ \nios documentationContains documentation for the Nios embedded processor, Nios development board, and GNUPro Toolkit. plam_sosgnsidee_s\inContains Nios sample designs, including the \reference_design_32_bit\reference_designproject that loads on the Nios development board automatically upon power up. The nios_system_moduledesign you create in this tutorial is based on thereference_design.
Altera Corporation
Design Entry
Nios Embedded Processor Hardware Tutorial
The following tutorial sections guide you through the steps needed to create thenios_system_moduleproject, and then explain how to create a top-level BDF that contains the Nios system module. You create and instantiate the Nios system module using theMegaWizard Plug-In Manager.
Create a Quartus Project
1. Start the Quartus Software
In this section, you start the Quartus software and begin creating your project. To start the Quartus software, perform one of the following steps: vChoosePrograms > Altera > Quartus 2000.05(Windows Start menu). or vTypequartusrat the command prompt. The Quartus window opens.
2. Create a Project
To create a new project, follow these steps: 1. ChooseNew(File menu). TheDesign Filestab of theNewdialog box appears automatically. 2. Click theProject Filestab.
Altera Corporation
3
Nios Embedded Processor Hardware Tutorial
4
3. 4. 5. 6. 7.
8.
In theProject Filestab, selectProject File. ClickOK. TheNew Projectdialog box appears. To specify the project directory, type d:\Altera\Excalibur\nios_tutorialin theProject directorybox. In theProject namebox, typenios_system_moduleas the name of the project. In theTop-level design entitybox, make sure nios_system_moduleis specified as the name of the top-level design entity of the project. See the following illustration:
ClickOK. When the Quartus software asks you if you want to create the new directory, clickYes. The project is now created. The top-level design entity name appears in theHierarchiestab of the Project Navigator window. See the following illustration:
Top-level design entity name
Altera Corporation
Nios Embedded Processor Hardware Tutorial
Create a Nios System Module
This section describes how to create the top-level BDF that contains a Nios system module. After creating a design file, you can use theMegaWizard Plug-In Managercreate the Nios embedded processor and configureto system peripherals. Next, you create the connections from the Nios embedded processor and system peripherals to hardware components on the Nios development board. This section includes the following steps: 1.Create a new Block Design File (.bdf). 2.Create the Nios embedded processor. 3.Create & memory map system peripherals. 4.Configure system module settings. 5.Synthesize the design with LeonardoSpectrum software. 6.Enter input, output, bidirectional & primitive symbols. 7.Name the pins. 8.Connect the pins.
1. Create a New Block Design File
In this step you create a new BDF callednios_syset_momudelb.fd. This file is the top-level design entity of thenios_system_moduleproject. To create a new BDF, follow these steps: 1. ChooseNew(File menu). TheDesign Filestab of theNewdialog box appears automatically. 2. In theDesign Filestab, selectBlock Diagram/Schematic File. 3. ClickOK. A new Block Editor window appears. 4. ChooseSave As(File menu). 5. Select the folder where you want to save the BDF. TheSave Asdialog box should automatically display the project directory name, d:\Altera\Excalibur\nios_tutorial, as the directory for saving the file.
Altera Corporation
5
Nios Embedded Processor Hardware Tutorial
6
6. In theFile namebox, typenios_ _the name of system moduleas the BDF, if necessary. 7. Make sureAdd file to current projectis turned on. 8. ClickSave. The file is saved and added to the project.
2. Create the Nios Embedded Processor
TheMegaWizard Plug-In Managerallows you to create (or modify) design files that contain custom variations of megafunctions, such as the Nios system module. A complete Nios system module contains a Nios embedded processor and its associated system peripherals. The MegaWizard Plug-In Manager - Nios System Builderhelps you specify options for the system module easily. The wizard prompts you about the values you want to set for parameters and which optional ports and peripherals you want to use. Once the wizard generates the Nios system module, you can instantiate it in the design file. Follow these steps to create the Nios embedded processor in the ni _ y _e: os s stem module.bdffil 1. Click theSelection Toolbutton on the toolbar. The Block Editor toolbar has the following default toolbar buttons:
Selection Tool Symbol Tool Orthogonal Node Tool Zoom Tool Find Flip Horizontal Rotate Left 90 Rectangle Tool Line Tool
Text Tool Block Tool Orthogonal Bus Tool Full Screen
Flip Vertical
Oval Tool Arc Tool
2. Double-click an empty space in the Block Editor window. The Symboldialog box appears.
Altera Corporation
3.
4. 5. 6.
7. 8. 9.
Altera Corporation
Nios Embedded Processor Hardware Tutorial
ClickMegaWizard Plug-In Manager. The first page of the MegaWizard Plug-In Manageris displayed, as shown in the following illustration:
UnderWhich action do you want to perform?, selectCreate a new custom megafunction variationand clickNext.MegaWizard Plug-In Managerpage 2a appears. In theAvailable Megafunctionslist, make sureAltera Excalibur Nios(tm)is selected. Specify the following responses to the remaining wizard prompts in MegaWizard Plug-In Managerpage 2a:
Wizard Prompt: Response: Which type of output file doSelectVerilog HDL you want to create? What name do you want forType\uribalxc\Erad\:lAet the put file?_ outnios tutorial\nios32.v
ClickNext. System Builder NiosMegaWizard Plug-In Manager-page 3 appears. In theNamebox, leave the default name for the Nios embedded processor,nios32_cpu. To specify options for the Nios embedded processor, clickNext. MegaWizard Plug-In Manager - Niospage 1 appears.