Supporting Custom Boards with DSP Builder

Similar documents
DSP Builder. DSP Builder v6.1 Issues. Error When Directory Pathname is a Network UNC Path

Estimating Nios Resource Usage & Performance

DSP Builder Release Notes

Design Verification Using the SignalTap II Embedded

DSP Development Kit, Stratix II Edition

FPGAs Provide Reconfigurable DSP Solutions

Error Correction Code (ALTECC_ENCODER and ALTECC_DECODER) Megafunctions User Guide

DDR and DDR2 SDRAM Controller Compiler User Guide

Active Serial Memory Interface

altshift_taps Megafunction User Guide

CORDIC Reference Design. Introduction. Background

Introduction. Design Hierarchy. FPGA Compiler II BLIS & the Quartus II LogicLock Design Flow

DSP Development Kit, Stratix & Stratix Professional Edition Getting Started User Guide

Using Verplex Conformal LEC for Formal Verification of Design Functionality

DDR & DDR2 SDRAM Controller Compiler

Debugging Nios II Systems with the SignalTap II Logic Analyzer

DSP Builder User Guide

Simple Excalibur System

ByteBlaster II Parallel Port Download Cable

ByteBlaster II Download Cable User Guide

Table 1 shows the issues that affect the FIR Compiler v7.1.

Nios II Embedded Design Suite 7.1 Release Notes

Simulating Nios II Embedded Processor Designs

Nios II Embedded Design Suite 6.1 Release Notes

Excalibur Solutions DPRAM Reference Design

Practical Hardware Debugging: Quick Notes On How to Simulate Altera s Nios II Multiprocessor Systems Using Mentor Graphics ModelSim

DDR & DDR2 SDRAM Controller Compiler

FFT MegaCore Function User Guide

Simultaneous Multi-Mastering with the Avalon Bus

System Debugging Tools Overview

DDR & DDR2 SDRAM Controller Compiler

DSP Development Kit, Stratix II Edition Getting Started User Guide

High Bandwidth Memory (HBM2) Interface Intel FPGA IP Design Example User Guide

UTOPIA Level 2 Slave MegaCore Function

ZBT SRAM Controller Reference Design

Using the Nios Development Board Configuration Controller Reference Designs

Table 1 shows the issues that affect the FIR Compiler, v6.1. Table 1. FIR Compiler, v6.1 Issues.

DDR & DDR2 SDRAM Controller

Simulating the PCI MegaCore Function Behavioral Models

DDR & DDR2 SDRAM Controller

2.5G Reed-Solomon II MegaCore Function Reference Design

System-on-a-Programmable-Chip (SOPC) Development Board

Using MAX 3000A Devices as a Microcontroller I/O Expander

lpm_compare Megafunction User Guide

Exercise 1 In this exercise you will review the DSSS modem design using the Quartus II software.

Figure 1. Device Package Ordering Information for Stratix, Stratix GX, Cyclone, APEX 20KC, APEX II, Mercury & Excalibur Devices EP1S 25 F 780 C 5 N

Quartus II Introduction Using Verilog Designs. 1 Introduction. For Quartus II 12.0

Nios Embedded Processor UART Peripheral

MasterBlaster Serial/USB Communications Cable User Guide

Using the Serial FlashLoader With the Quartus II Software

Using MAX II & MAX 3000A Devices as a Microcontroller I/O Expander

POS-PHY Level 4 MegaCore Function

Nios Soft Core Embedded Processor

Cyclone II FPGA Family

University Program 3 Kit

Matrices in MAX II & MAX 3000A Devices

Edge Detection Using SOPC Builder & DSP Builder Tool Flow

SignalTap II with Verilog Designs. 1 Introduction. For Quartus II 13.1

FFT/IFFT Block Floating Point Scaling

PCI Express Compiler. System Requirements. New Features & Enhancements

White Paper. Floating-Point FFT Processor (IEEE 754 Single Precision) Radix 2 Core. Introduction. Parameters & Ports

USB BitJetLite Download Cable

Simulating the Reed-Solomon Model

Simulating the PCI MegaCore Function Behavioral Models

Disassemble the machine code present in any memory region. Single step through each assembly language instruction in the Nios II application.

Legacy SDRAM Controller with Avalon Interface

Using MicroC/OS-II RTOS with the Nios II Processor Tutorial Preliminary Information

RLDRAM II Controller MegaCore Function

Stratix II FPGA Family

Implementing LED Drivers in MAX Devices

December 2002, ver. 1.3 Application Note 191. Six individual interrupts Six-bit priority scheme Five-bit priority scheme plus one individual interrupt

FFT MegaCore Function User Guide

AN 547: Putting the MAX II CPLD in Hibernation Mode to Achieve Zero Standby Current

AN 549: Managing Designs with Multiple FPGAs

16. Design Debugging Using In-System Sources and Probes

Design Tools for 100,000 Gate Programmable Logic Devices

24K FFT for 3GPP LTE RACH Detection

Interlaken IP Core (2nd Generation) Design Example User Guide

altmult_accum Megafunction User Guide

Simulating the ASMI Block in Your Design

Stratix FPGA Family. Table 1 shows these issues and which Stratix devices each issue affects. Table 1. Stratix Family Issues (Part 1 of 2)

lpm_mult Megafunction User Guide

Video and Image Processing Suite

lpm_rom Megafunction User Guide

Using VCS with the Quartus II Software

Intel Stratix 10 External Memory Interfaces IP Design Example User Guide

White Paper Configuring the MicroBlaster Passive Serial Software Driver

Simulating Visual IP Models with the NC-Verilog, Verilog-XL, VCS, or ModelSim (UNIX) Simulators

White Paper Using the MAX II altufm Megafunction I 2 C Interface

Video Input Daughter Card Reference Manual

Floating Point Inverse (ALTFP_INV) Megafunction User Guide

SERDES Transmitter/Receiver (ALTLVDS) Megafunction User Guide

Toolflow for ARM-Based Embedded Processor PLDs

Intel Stratix 10 Low Latency 40G Ethernet Design Example User Guide

Intel Cyclone 10 External Memory Interfaces IP Design Example User Guide

April 2002, Version 1.1. Component. PTF File. Component. Component GUI Wizards. Generation. System PTF file Files and Libraries.

DSP Builder. Quartus II & MATLAB/Simulink Interface. User Guide September 2001, v0.02 Pre-Release

Edge Detection Reference Design

Nios Soft Core. Development Board User s Guide. Altera Corporation 101 Innovation Drive San Jose, CA (408)

Color Space Converter

Transcription:

Supporting Custom Boards with DSP Builder April 2003, ver. 1.0 Application Note 221 Introduction As designs become more complex, verification becomes a critical, time consuming process. To address the need for more efficient verification techniques, the Altera DSP Builder tool provides a seamless flow for performing implementation in The MathWorks Simulink software and verification in actual hardware. DSP Builder provides bit-true and cycle-accurate simulation models and supports board-level, in-system verification using the SignalTap II embedded logic analyzer. By importing the data into the MATLAB/Simulink workspace to facilitate visual analysis, this analyzer lets you monitor internal nodes within a design in hardware at system speed. Before analyzing a design in hardware, you must integrate board elements into your Simulink design file using DSP development board blocks. To facilitate this process, DSP Builder includes a library of blocks for the APEX EP20K200E, APEX EP20K1500E, Stratix EP1S25, and Stratix EP1S80 DSP development boards. Additionally, DSP Builder allows you to perform rapid prototyping using any hardware development board and custom blocks you build yourself. Using DSP Builder and your own board provides the following benefits: Speeds up the prototyping flow for DSP applications Enhances debugging capabilities of DSP applications using the SignalTap II logic analyzer Creates powerful, effective demonstrations for early prototypes of DSP applications Supports the same board for multiple projects during the prototyping stage This application note describes how to create a custom board library in DSP Builder to support your own board with different devices and/or pin-outs. This document also includes a walkthrough that explains the step-by-step procedure for creating a board library, using the Nios development board, Stratix edition as an example. Using this example and the templates provided, you can easily create your own custom board library. Altera Corporation 1 AN-221-1.0

1 This document assumes that you have basic familiarity with the MATLAB/Simulink software. Refer to MATLAB and Simulink Help for specific details on how to use the software. Refer to the DSP Builder User Guide for information on how to use DSP Builder. Targeting Boards with DSP Builder Altera offers several DSP development boards as prototyping platforms that provide you with an economical solution for hardware and software verification. These rapid prototyping boards let you debug and verify functionality and design timing. With a library of peripherals including analog input and output channels and the ability to combine boards easily with right angle connectors, you can use these boards to construct a powerful processing system. Combined with DSP IP from Altera and Altera Megafunction Partners Program (AMPP ) partners, you can solve design problems that formerly required custom hardware and software solutions. 1 For more information on Altera DSP development kits, refer to www.altera.com/products/devkits/kit-dev_platforms.html. To target a specific development board in DSP Builder, you include device and connector blocks, which are unique to each development board, in your Simulink Model File (.mdl). The SignalCompiler block, which is the heart of DSP Builder, converts the Simulink design into synthesizable RTL VHDL and generates Tcl scripts with the device and pin-out information for the input and output ports in the design based on these blocks. You then use the Tcl scripts to perform synthesis, Quartus II compilation, and/or simulation in the ModelSim software. The SignalCompiler block also lets you perform synthesis and place-androute and download a device configuration file directly to your development board from within Simulink, providing a seamless interface between implementation and verification. This process can significantly reduce the time needed to go from system design to evaluation and verification in actual hardware for rapid prototyping. In addition to the Altera DSP development board libraries provided with DSP Builder, you can create custom board libraries for any development board. Board information is not hard-coded in the SignalCompiler block; instead, it is specified in a dedicated board configuration block that you include in your top-level Model File. This feature allows DSP Builder to support any hardware development board using a customized library. The user-created library must contain all information necessary to pass device, port, and pin-out constraints to the Quartus II Tcl script for compilation. 2 Altera Corporation

Board Library Blocks When creating a library for your own board, you use two types of blocks: Board configuration block Board connector blocks The board configuration block contains information about the specific development board you are using; the board connector block describes the I/O components within the development board. Each board library you create should have one board configuration block and one or more board connector blocks. Figure 1 shows an example of a board library created for the Nios development board (APEX version). Figure 1. Custom Board Library Example Board Configuration Block Board Connector Blocks Board Configuration Block The board configuration block indicates which board is targeted and is unique for each board that is supported in DSP Builder. When targeting a DSP development board (i.e., selecting DSP Board as the target in Signal Compiler), the Simulink design must contain the board configuration block at the top hierarchical level. Altera Corporation 3

This block has information on the target device and has pin-outs for control signals, including clock input, clock output from the PLL block (if any), and the global reset signal. Optionally, it can configure the clock output feeding an on-board digital-to-analog converter (DAC). For more details, refer to Parameters on page 6. Board Connector Blocks Board connector blocks link to I/O components such as analog-to-digital converters (ADC), DACs, RS-232 serial ports, LEDs, switches, and pushbuttons. Each block must include information on the ports represented including the direction (i.e., input or output), bit width, and pin location. For more details, refer to Parameters on page 6. About the Simulink Mask Editor Masking blocks is a Simulink feature that allows you to make a customized parameter dialog box for each component in your board library. This section describes the Mask Editor options you use when creating a new library and customizing it for the connectors available on your development board. The Mask Editor has the following tabs: Icon Parameters Initialization Documentation 1 For a complete description of the Simulink features described in this section such as the Mask Editor and model construction commands like get_param, gcb, and set_param see Using Simulink in The MathWorks documentation. Each block has its own parameters specified in the Parameters tab in the Mask Editor. These parameters are initialized using MATLAB commands or a MATLAB script specified in the Initialization tab. Figure 2 shows the development flow using the Mask Editor. 4 Altera Corporation

Figure 2. Development Flow Using the Mask Editor Mask Editor Icon Tab Parameters Tab Initialization Tab Documentation Tab MATLAB Initialization Script Icon When you create a block, you can give it an icon that contains descriptive text, state equations, images, or graphics. You make this setting in the Mask Editor s Icon tab. For example, you can photograph the elements on your board (e.g., D/A converters), save them as bitmaps (<filename>.bmp), and display them in your board library. The blocks in Figure 1 on page 3 are photographed bitmap icons. The imread and image commands read the graphics file and display the image, respectively. Figure 3 shows the Icon tab. Figure 3. Icon Tab Altera Corporation 5

Parameters You use the Parameters tab to define each block s variables and their parameter prompts. These prompts display in the block s parameter dialog box that appears when you double-click the block. To support your board, you must set up parameters for the board configuration block as well as any connector blocks. Figure 4 shows the Parameters tab. Figure 4. Parameters Tab You can use the board configuration block for the Stratix EP1S25 DSP development board, provided with DSP Builder, as a template when creating your own board configuration block. Modify the template as needed for your own development board. The board configuration block has the parameters and variables shown in Table 1. 6 Altera Corporation

Table 1. Parameters for Board Configuration Block Prompt Variable Description Value DSP Board DspBoard Indicate the name of board library. String Library Device Family Family Indicate the device family. Stratix, Cyclone, APEX, Mercury, ACEX, or FLEX Clock Pin In ClockPinIn Indicate the clock source pin to drive the device. Pin_<number> Clock Pin Out (D2A_2_CLK) Clock Pin Out (D2A_1_CLK) Clock1PinOut Clock2PinOut Indicate the clock out pin to drive D/A 2 (D2A_2). Indicate the clock out pin to drive D/A 1 (D2A_1). Clock Pin Out ClockPinOut Indicate the clock out pin to drive other components on board. Pin_<number> Pin_<number> Pin_<number> Global Reset Pin GlobalResetPin Indicate selection of reset pins. Pin_<number> Device Device Indicate the device part number. You can find the device part number format information at www.altera.com/products/devices/ dev-format.html JTAGDevice JTAGDevice Indicate the JTAG IDCODE of the device you are targeting. You can find the JTAG IDCODE by looking in the JTAG section of the appropriate device family data sheet The rest of the connectors in your custom board library have the parameters and variables shown in Table 2. Altera Corporation 7

Table 2. Parameters for Board Connector Block Prompt Variable Description Value Bus Type sgn Choose the bus number format. Signed Integer, Unsigned Integer, Single Bit, Signed Binary Fractional Node Type nodetype Indicate the type of node. Input Port, Output Port [number of bits].[] bwl Indicate the number of bits to the left of the binary 1-51 point, including the sign bit. This parameter does not apply to single-bit buses. [].[number of bits] bwr Indicate the number of bits to the right of the binary 0-51 point. This parameter only applies to signed binary fractional buses. Saturate sat When this option is turned on, if the output is greater On or Off than the maximum positive or negative value to be represented, the output is forced (or saturated) to the maximum positive or negative value, respectively. When this option is turned off, the most significant bit (MSB) is truncated. This option is not valid for the input port or constant node types. Round rnd When this option is turned on, the output is rounded On or Off away from zero. When this option is turned off, the least significant bit (LSB) is truncated: <int>(input +0.5). This option is not valid for the input port or constant node types. Constant Value cst Indicate the constant value that will be formatted with Double the bus parameter specified. DSP Board DspBoard Indicate name of board library String Library Pin Location LocPin Indicate pin location (MSB -> LSB). Pin_<number> componentid componentid Indicate unique component ID for each connector block. String 8 Altera Corporation

Initialization You specify initialization commands in the Initialization tab. These commands define the variables that are associated with the parameters. For board library blocks, the initialization process executes from a MATLAB script when you open Simulink. Create a Custom Board Library on page 11 provides templates for these scripts (myboardprog.m for board configuration blocks and myboard_init.m for board connector block(s)). The Simulink get_param and set_param commands let you inspect and set dialog box parameters and change the dialog box s appearance while the dialog box is open. The gcb command gets the path of the current block. For a masked block to change the contents of its underlying system block and set parameters based on user input, you initialize it as a selfmodifying masked block using the following command: set_param(gcb, MaskSelfModifiable, on ); You can control the visibility of the user-defined parameter controls in the dialog box using the following command: set_param(gcb,'maskvisibilities',{'off','on', off'}); The parameter association is done by position (i.e., the first cell defines the value of the first parameter, the second cell defines the value of the second parameter and so on so forth). Figure 5 shows the Initialization tab. Figure 5. Initialization Tab Altera Corporation 9

Documentation You define the mask type, specify the block description, and point to the block s help file in the Documentation tab. The mask type field shows up in the block parameters dialog box for the corresponding block. For the board configuration block, the mask type should be DspBoard AlteraBlockSet. For the board connector blocks, the mask type should be AltBus AlteraBlockSet. 1 The commands, variables, and names in Simulink are casesensitive. The mask description field allows you to provide the user with helpful information about the block usage or parameters. You can also link to an HTML help file for the block (e.g., all of the DSP Builder blocks have help files). If you use the default specified in the template, which uses the GETDOCPATH script, you must place the HTML file in the <path to DSP Builder>\Altlib directory. Alternatively, you can place the HTML file in the same folder as the library model file and reference it using the following command: web([ file:/// which( foo.html )]); Figure 6 shows the Documentation tab. Figure 6. Documentation Tab 10 Altera Corporation

Create a Custom Board Library This section describes how to create your own board library, update blocks in the Mask Editor, edit the Altera-provided MATLAB scripts, and include your new library in the Simulink Library Browser. The instructions use the Nios development board, Stratix edition as an example. Hardware & Software Requirements To follow the steps in this section, you must have the following software installed on your system: MATLAB/Simulink Release 12 or 13 DSP Builder version 2.1.2 or later 1 The screenshots shown in this document are from Simulink version 5.0 (MATLAB/Simulink Release 13). If you are using another version of the software, some windows will be different, but the same concepts apply. If you want to use the library with a board after creating it, you will need the following additional hardware and software: The Quartus II software version 2.2 or later Nios development board, Stratix edition Walkthrough Design Files The design files for this walkthrough are installed automatically when you install DSP Builder. Figure 7 shows the walkthrough directory structure. You can begin creating the library using the files in the c:\dspbuilder\designexamples\modular_board\walkthrough directory. Alternatively, you can view the completed library in the c:\dspbuilder\designexamples\modular_board\complete directory. Figure 7. Walkthrough Directory Structure c:\dspbuilder\designexamples\modular_board complete Contains the completed files for the Nios development boards.. complete_nios_stratix Contains a library for the components on the Nios develpment board, Stratix edition. complete_nios_apex Contains a library for the components on the Nios develpment board (APEX). walkthrough Contains the files you should use to perform the design walkthrough. Altera Corporation 11

Design Walkthrough This section walks you through the steps involved in building a library of blocks targeting the Nios development board, Stratix edition using the files in the c:\dspbuilder esignexamples\modular_board \walkthrough directory. The steps include: 1. Create a New Library Model File 2. Create the Board Configuration Block 3. Create Board Connector Blocks 4. Add the Library to the Simulink Library Browser Instead of creating the library, you can view the Altera-provided libraries in the c:\dspbuilder\designexamples\modular_board\complete directory. Create a New Library Model File The first step when creating a custom library is to create a Model File (.mdl) to hold the board configuration and board connector blocks. Create a model file by performing the following steps: 1. Run the MATLAB software. 2. Change the current working directory to c:\dspbuilder\ designexamples\modular_board\walkthrough directory (e.g., by clicking the browse button next to the Current Directory list box in the MATLAB GUI). 3. Click the + icon next to Simulink in the Launch Pad. 4. Double-click Library Browser. 5. Choose New > Library (File menu) from the Simulink Library Browser. Simulink opens a new library model window. 6. Choose Save (File menu). 7. Save the library as myboard.mdl in the c:\dspbuilder\ designexamples\modular_board\walkthrough directory. 12 Altera Corporation

Create the Board Configuration Block In this walkthrough, you use the board configuration block from the Stratix DSP Board EP1S25F780C5 library as a template. Because you are using a template block, you have to break the link between the template block and its library to make it stand alone. To create a board configuration block for your development board, perform the following steps: 1. Click the + icon next to the Stratix DSP Board EP1S25F780C5 library in the Simulink Library Browser to expand it. 2. Drag and drop the Stratix DSP Board 1S25 Configuration block from the Stratix DSP Board EP1S25F780C5 library to your myboard.mdl file. 3. Right-click the Stratix DSP Board 1S25 Configuration block and choose Link Options > Disable Link from the pop-up menu. 4. Right-click the Stratix DSP Board 1S25 Configuration block and choose Link Options > Break Link from the pop-up menu. 5. Double-click the text label on the Stratix DSP Board 1S25 Configuration block. 6. Delete the text label. 7. Type Nios Stratix Board 1S10 Configuration as the new label. 8. Right-click the Nios Stratix Board 1S10 Configuration block and choose Edit Mask from the pop-up menu to open the Mask Editor. It opens to the Icon tab. 9. Change the name of the specified bitmap to stratix_nios_board.bmp in the Drawing commands box as shown in Figure 8. Altera Corporation 13

Figure 8. Change Bitmap in Icon Tab 10. Click the Parameters tab. 11. Change the options for the parameters in the Popups box as shown in Figure 9. Use the values provided in Table 3. For details, refer to Parameters on page 6. Table 3. Parameters for Board Nios Stratix 1S10 Configuration Block Prompt DSP Board Library Device Family Clock Pin In Clock Pin Out (D2A_2_CLK) Clock Pin Out (D2A_1_CLK) Clock Pin Out Global Reset Pin Device JTAG Device Pop-Up niosboard1s10 Stratix Pin_K17, Pin_AC17, Any Not applicable Not applicable Pin_AD15, Pin_E15, Any Pin_W5, Pin_W6, Pin_AB2, Pin_AB1, Any EP1S10F780C6ES @1: EP1S10F1020/780 (0x020010DD) 14 Altera Corporation

Figure 9. Change Parameters in Parameter Tab 12. Click the Initialization tab. 13. Change the visibility option for the parameters in the Initialization Commands window as shown below: set_param(gcb, MaskVisibilities,{ off, off, on, off, off, on, on, off, off }); This setting enables the Clock Pin In, Clock Pin Out, and Global Reset Pin options in the block parameters window for the Nios Stratix Configuration block. The rest of the parameters are hidden. 14. Change the MATLAB script, dspboard1s25prog, to niosboard1s10prog as shown in Figure 10. Altera Corporation 15

Figure 10. Change Initialization Commands in Initialization Tab 15. Create the niosboard1s10prog.m MATLAB script by updating the Altera-provided template c:\dspbuilder\designexamples \modular_board\walkthrough\myboardprog.m. a. Choose Open (File menu) in the MATLAB window. b. Browse to c:\dspbuilder\designexamples\modular_board \walkthrough. c. Select myboardprog.m and click Open. d. Change the script parameters after the instructions provided in the comment section of the template with the values in Table 4. Table 4. Parameters for niosboard1s10prog.m MATLAB Script Parameter Function Name Library Model Name Device Part Name Value niosboard1s10prog myboard EP1S10F780 e. Choose Save (File menu). f. Save the file as niosboard1s10prog.m. g. Choose Close (File menu). 16 Altera Corporation

16. Click the Documentation tab. 17. Change the Mask description to reflect the configuration settings of the Nios development board, Stratix edition by making configuration settings for the following signals: Input Clock (Crystal Oscillator): Pin_K17, Pin_AC17 Output Clock: Pin_AD15, Pin_E15 18. Change the Mask help to reflect the corresponding HTML help page for the board, nios_board_stratix.html, using the following command (see Figure 11): web([ file:/// which( nios_board_stratix.html )]); You can edit the file, which is located at c:\dspbuilder\ designexamples\modular_board\walkthrough\nios_board_strati x.html, to include any help information that you want. Figure 11. Change Mask Description & Mask Help in Documentation Tab 19. Click Apply. 20. Click OK to close the Mask Editor. Altera Corporation 17

Create Board Connector Blocks In this walkthrough, you use the board connector blocks from the Stratix DSP Board EP1S25F780C5 library as a template. Because you are using a template block, you have to break the link between the template block and its library to make it stand alone. LED0 Connector Block To create a LED0 board connector block for the Nios development board, Stratix edition, you need to follow these steps: 1. Drag and drop the LED0 block from the Stratix DSP Board EP1S25F780C5 library to the myboard.mdl file. 2. Right-click the LED0 connector block. 3. Choose Link Options > Disable Link from the pop-up menu. 4. Right-click the LED0 connector block. 5. Choose Link Options > Break Link. 6. Right-click the LED0 block. 7. Choose Edit Mask to open the Mask Editor. 8. Click the Parameters tab. 9. Click DSP Board Library under Prompt. 10. In the Popups box, change the setting to niosboard1s10 as shown in Figure 12. 18 Altera Corporation

Figure 12. Change Parameters for LED0 Connector Block 11. Click the Initialization tab. 12. Change the MATLAB initialization script to niosboard1s10_init and 5 to 1 (this number is the IOComponent variable number). The command should appear as shown in Figure 13. Figure 13. Change Initialization Script for LED0 Connector Block Altera Corporation 19

13. Create the niosboard1s10_init.m MATLAB script by updating the Altera-provided template c:\dspbuilder\designexamples \modular_board\walkthrough\myboard_init.m. a. Choose Open (File menu). b. Choose myboard_init.m (File menu) and click Open. c. Change the script parameters after the instructions provided in the comment section of the template with the values in Table 5. Table 5. Parameters for niosboard1s10_init MATLAB Script (LED0 Block) IOComponent number 1 sgn nodetype bwl 1 bwr 0 rnd sat cst 0 LocPin image componentid vis d. Change the function name to niosboard1s10_init. e. Choose Save (File menu). f. Save the file as niosboard1s10_init.m. g. Close the file. Single Bit Output Port off off Pin_H27 led.bmp LED0 1 For details on the parameters, refer to Parameters on page 6. 14. Click the Documentation tab. { off, off, off, off, off, off, off, on, off, off } 20 Altera Corporation

15. Change the Mask description to reflect the connector block of the Nios development board, Stratix edition: LED0 Connects to LED0 on the Stratix Nios development board. LOCATION = Pin_H27; 16. Change the Mask help to reflect the corresponding HTML help page for the board, nios_board_stratix.html, using the following command (see Figure 11): web([ file:/// which( nios_board_stratix.html )]); You can edit the file, which is located at c:\dspbuilder\ designexamples\modular_board\walkthrough\nios_board_strati x.html, to include any help information that you want. Figure 14. Change Mask Description & Help for LED0 Connector Block 17. Click Apply. 18. Click OK to close the Mask Editor. Altera Corporation 21

Other Board Connector Blocks To create the rest of the connector blocks for the Nios development board, Stratix edition, perform the same steps described in LED0 Connector Block on page 18 for each block. All board connector blocks share the same MATLAB script in the Initialization tab, but each connector block has a unique IOComponent number. Modify the parameters for each connector block in the MATLAB script based on the information in Tables 6 through 8. Additionally, change the mask description in the Documentation tab of each connector block to reflect the corresponding pin-out and board. The completed Stratix Nios Development Board Library is shown in Figure 15. Table 6. Parameters for LED1 through LED7 Blocks Parameter LED1 LED2 LED3 LED4 LED5 LED6 LED7 IOComponent number 2 3 4 5 6 7 8 sgn Single Bit nodetype Output Port bwl 1 bwr 0 sat off rnd off cst 0 LocPin Pin_H28 Pin_L23 Pin_L24 Pin_J25 Pin_J26 Pin_L20 Pin_L19 image led.bmp componentid LED1 LED2 LED3 LED4 LED5 LED6 LED7 vis { off, off, off, off, off, off, off, on, off, off } 22 Altera Corporation

Table 7. Parameters for SW0 through SW3 Blocks Parameter SW0 SW1 SW2 SW3 IOComponent number 9 10 11 12 sgn Single Bit nodetype Input Port bwl 1 bwr 0 sat Off rnd Off cst 0 LocPin Pin_W5 Pin_W6 Pin_AB2 Pin_AB1 image switch.bmp componentid SWITCH0 SWITCH1 SWITCH2 SWITCH3 vis { off, off, off, off, off, off, off, on, off, off } Table 8. Parameters for BCD0 & BCD1 Blocks Parameter BCD0 BCD1 IOComponent number sgn nodetype bwl 8 bwr 0 sat rnd cst 0 LocPin Signed Integer Output Port off off Pin_A18,Pin_C18,Pin_D18,Pin_A19,Pin_ B19,Pin_C19,Pin_E19,Pin_D19, 7SegmentDisplay.bmp image componentid 7SegmentDisplay0 7SegmentDisplay1 vis { off, off, off, off, off, off, off, on, off, off } Pin_B18,Pin_B20,Pin_A20,Pin_C20,Pin _A21,Pin_B21,Pin_C21,Pin_D21, Altera Corporation 23

Figure 15. Completed Stratix Nios Board EP1S10F780C6ES Library Add the Library to the Simulink Library Browser This section describes how to add your newly created library to the Simulink Library Browser. The c:\dspbuilder\designexamples \modular_board\walkthrough directory contains a template slblock.m MATLAB script. This script defines the block library for the blockset you have just created. You change the parameters in this script to reflect your own board library. 1 The slblock.m script must be located in the same directory as the rest of the files for your custom board library. For this walkthrough, update the slblock.m script by changing the parameters after the description and instructions using values from Table 9. Table 9. Parameters for slblock MATLAB Script Parameter blkstruct.name blkstruct.openfcn Browser(1).Library Browser(1).Name Value [ Stratix Nios Development Board sprintf( \n ) Extras ] myboard myboard Stratix Nios Development Board 24 Altera Corporation

1 The slblock.m script must be in the MATLAB system path for the library to appear in the Simulink Library Browser. Refer to the MATLAB path command for more information. The Stratix Nios Board EP1S10F780C6ES Library appears in the Simulink Library Browser as shown in Figure 16. Figure 16. Stratix Nios Board EP1S10F780C6ES Library in Simulink Library Browser You can now include blocks from the new library in a Simulink design as shown in Figure 17. Altera Corporation 25

Figure 17. Example Design using Stratix Nios Board EP1S10F780C6ES Library Conclusion References DSP Builder is a powerful tool for verifying systems in hardware. Using this tool, you can target any development board using custom libraries you create using Altera-provided templates. Simulink Dynamic System Simulation for MATLAB. The Mathworks. DSP Builder User Guide. Altera Corporation. San Jose, CA. April 2003. 101 Innovation Drive San Jose, CA 95134 (408) 544-7000 http://www.altera.com Applications Hotline: (800) 800-EPLD Literature Services: lit_req@altera.com Copyright 2003 Altera Corporation. Altera, The Programmable Solutions Company, the stylized Altera logo, specific device designations, and all other words and logos that are identified as trademarks and/or service marks are, unless noted otherwise, the trademarks and service marks of Altera Corporation in the U.S. and other countries. All other product or service names are the property of their respective holders. Altera products are protected under numerous U.S. and foreign patents and pending applications, maskwork rights, and copyrights. Altera warrants performance of its semiconductor products to current specifications in accordance with Altera s standard warranty, but reserves the right to make changes to any products and services at any time without notice. Altera assumes no responsibility or liability arising out of the application or use of any information, product, or service described herein except as expressly agreed to in writing by Altera Corporation. Altera customers are advised to obtain the latest version of device specifications before relying on any published information and before placing orders for products or services. All rights reserved. 26 Altera Corporation