Altera Nios Ethernet User Manual

Nios Ethernet
Development Kit User Guide
101 Innovation Drive San Jose, CA 95134 (408) 544-7000
http://www.altera.com Document Date: August 2002
Document Version: 3.0
Copyright Nios Ethernet Development Kit User Guide
Copyright © 2002 Altera Corporation. All rights reserved. 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, mask work 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.
UG-NIOSETHERKIT-3.0
About this User Guide
This user guide provides the information necessary to get you started
®
using the Nios
Ethernet Development Kit (EDK). This manual provides:
An overview of the Nios EDK, its contents, and its intended use
A Getting Started section with a step-by-step guide to installing the
development tools, installing hardware, and accessing the software application examples.
A Daughter Card reference section providing a description of the
daughter card including a functional overview, pinout information, and descriptions of the PC-board design files included with the kit
A software overview introducing you to the C language library,
providing a description of the supported protocols and the general structure of the provided functions and data structures
A plugs library reference describing the software routines
1 For the most current version of this user guide, see
http://www.altera.com/literature/lit-nio.html
Table 1 shows the user guide revision history.
Table 1. User Guide Revision History
Date Description
August 2002 Updated PDF for Ethernet 10/100 kit
April 2002 Updated PDF - new cover for version 2.1
January 2002 PDF only. Added new (adapter_irq) and modified one
(adapter_base_address) parameter for the nr_plugs_initialize routine. Updated description for nr_plugs_idle routine.
July 2001 initial printed document and PDF - version 1.0
Refer to the readme file for new features, system requirements and
installation information.
Altera Corporation iii
About this User Guide Nios Ethernet Development Kit User Guide
How to Contact
For the most up-to-date information about Altera® products, go to the Altera world-wide web site at http://www.altera.com.
Altera
For technical support on this product, go to
http://www.altera.com/mysupport. For additional information about
Altera products, consult the sources shown in Table 2.
Table 2. How to Contact Altera
Information Type USA & Canada All Other Locations
Technical support http://www.altera.com/mysupport/ http://www.altera.com/mysupport/
(800) 800-EPLD (3753) (7:00 a.m. to 5:00 p.m. Pacific Time)
Product literature http://www.altera.com http://www.altera.com
Altera literature services lit_req@altera.com (1) lit_req@altera.com (1)
Non-technical customer service
FTP site ftp.altera.com ftp.altera.com
(800) 767-3753 (408) 544-7000
(408) 544-7000 (1) (7:00 a.m. to 5:00 p.m. Pacific Time)
(7:30 a.m. to 5:30 p.m. Pacific Time)
Note:
(1) You can also contact your local Altera sales office or sales representative.
Documentation
Altera values your feedback. If you would like to provide feedback on this documente.g., clarification requests, inaccuracies, or inconsistencies
Feedback
send e-mail to nios_docs@altera.com.
Nios Ethernet Development Kit User Guide About this User Guide
Typographic
The Nios Ethernet Development Kit User Guide uses the typographic conventions shown in Table 3.
Conventions
Table 3. Conventions
Visual Cue Meaning
Bold Type with Initial Capital Letters
bold type External timing parameters, directory names, project names, disk drive names,
Italic Type with Initial Capital Letters
Italic type Internal timing parameters and variables are shown in italic type. Examples: t
Initial Capital Letters Keyboard keys and menu names are shown with initial capital letters. Examples:
“Subheading Title” References to sections within a document and titles of on-line help topics are shown
Courier type Signal and port names are shown in lowercase Courier type. Examples: data1, tdi,
Command names, dialog box titles, checkbox options, and dialog box options are shown in bold, initial capital letters. Example: Save As dialog box.
filenames, filename extensions, and software utility names are shown in bold type. Examples: f
Document titles are shown in italic type with initial capital letters. Example: AN 75:
High-Speed Board Design.
Variable names are enclosed in angle brackets (< >) and shown in italic type. Example: <file name>, <project name>.pof file.
Delete key, the Options menu.
in quotation marks. Example: “Typographic Conventions.”
input. Active-low signals are denoted by suffix n, e.g., resetn.
, \qdesigns directory, d: drive, chiptrip.gdf file.
MAX
PIA
, n + 1.
Anything that must be typed exactly as it appears is shown in Courier type. For example: c:\qdesigns\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 Courier.
1., 2., 3., and a., b., c.,... Numbered steps are used in a list of items when the sequence of the items is important, such as the steps listed in a procedure.
v The checkmark indicates a procedure that consists of one step only. 1 The hand points to information that requires special attention.
r The angled arrow indicates you should press the Enter key.
f The feet direct you to more information on a particular topic.
Bullets are used in a list of items when the sequence of the items is not important.
Altera Corporation v
Contents
About this User Guide ...............................................................................................................................iii
How to Contact Altera .................................................................................................................. iv
Documentation Feedback ............................................................................................................. iv
Typographic Conventions ..............................................................................................................v
Overview .......................................................................................................................................................... 9
Nios Ethernet Development Kit Description ...............................................................................9
Installed Components ...................................................................................................................10
MAC Addresses .............................................................................................................................11
Getting Started ............................................................................................................................................13
Verify Kit Contents ........................................................................................................................ 13
Set Up the Daughter Card ............................................................................................................13
Install the Hardware and Software Files ....................................................................................16
Load the Reference Design ........................................................................................................... 17
Run Example Applications ...........................................................................................................20
The Hello Plugs Application Example ................................................................................20
Configure Your Network Settings ...............................................................................23
The Networked-Based GERMS Monitor Application Example ......................................24
The Simple Web Server Application Example ..................................................................27
Daughter Card ..............................................................................................................................................29
Daughter Card Components ........................................................................................................29
Functional Overview .....................................................................................................................30
Stack Daughter Cards ....................................................................................................................30
SOPC Builder Library Component .............................................................................................. 31
Connector Pinouts ..........................................................................................................................32
Nios System to Daughter Card Pin Map ....................................................................................34
Software Overview .....................................................................................................................................39
Software Description .....................................................................................................................39
System Requirements ............................................................................................................39
Protocols Supported ..............................................................................................................39
Library Features .....................................................................................................................39
Protocols Architecture ...................................................................................................................40
Standards .........................................................................................................................................40
ARP (RFC 826) ........................................................................................................................41
IP (RFC 791) ............................................................................................................................41
Altera Corporation vii
Contents Nios Ethernet Development Kit User Guide
ICMP (RFC 792) ......................................................................................................................41
UDP (RFC 768) .......................................................................................................................41
DNS (RFC 1034 & 1035) ........................................................................................................41
TCP (RFC 793) ........................................................................................................................41
Build Options ..................................................................................................................................42
PLUGS_DEBUG (Default Value = 1) .................................................................................. 42
PLUGS_PLUG_COUNT (Default Value = 6) .....................................................................42
PLUGS_ADAPTER_COUNT (Default Value = 2) ............................................................ 42
PLUGS_DNS (Default Value = 1) ........................................................................................42
PLUGS_PING (Default Value = 1) ......................................................................................42
PLUGS_TCP (Default Value = 1) .........................................................................................43
Byte Order .......................................................................................................................................43
Data Structures ...............................................................................................................................44
Payload Descriptions .....................................................................................................................47
Plugs Library Routines ............................................................................................................................. 49
nr_plugs_initialize .........................................................................................................................50
nr_plugs_terminate ........................................................................................................................51
nr_plugs_set_mac_led ...................................................................................................................52
nr_plugs_create ..............................................................................................................................53
typedef int (*nr_plugs_receive_callback_proc) .........................................................................55
nr_plugs_destroy ........................................................................................................................... 57
nr_plugs_connect ...........................................................................................................................58
nr_plugs_send ................................................................................................................................60
nr_plugs_send_to ...........................................................................................................................61
int nr_plugs_listen .........................................................................................................................62
typedef int (*nr_plugs_listen_callback_proc) ............................................................................63
nr_plugs_ip_to_ethernet ...............................................................................................................64
nr_plugs_name_to _ip ...................................................................................................................65
nr_plugs_idle .................................................................................................................................. 66
void nr_plugs_print_ethernet_packet .........................................................................................67
nr_n2h16 ..........................................................................................................................................68
nr_h2n16 ..........................................................................................................................................68
nr_n2h32 ..........................................................................................................................................68
nr_h2n32 ..........................................................................................................................................68
viii Altera Corporation
Overview
1
Overview
Nios Ethernet Development Kit Description
The Nios Ethernet Development Kit (EDK) includes hardware and software components that provide network connectivity for your Nios­based embedded systems. The components included in this kit are:
A network-interface daughter card that can plug directly into the
Nios development board.
An SOPC Builder library component that defines the logic and
interface signals necessary to use the daughter card in a Nios system.
A C language library that provides a network-protocol stack. This
library includes support for raw Ethernet, address resolution protocol (ARP), Internet protocol (IP), Internet control message protocol (ICMP), user datagram protocol (UDP), and transmission control protocol (TCP) protocols and utility routines for controlling the daughter card hardware.
The kit includes APEXTM device hardware reference designs and example software application programs. These reference designs and application examples are intended as starting points to be modified by you for your specific network-enabled application.
The Nios EDK library components and tools can be installed on Solaris, HP-UX or PC-Windows (NT/2000/XP).
1 The Nios Development Kit, featuring the Nios embedded
processor must be installed before you can use the Nios Ethernet Development Kit.
The following items are included in the Nios EDK:
Nios EDK daughter card based on the SMSC
PHY/MAC chip
Male-to-male RJ-45 network cable
Female-to-male crossover adapter, used for direct-PC connection
Nios EDK CD-ROM
The Nios EDK CD-ROM contains the following files:
SOPC library components
PC-board schematic and layout files for the Nios EDK daughter card
Altera Corporation 9
TM
LAN91C111
Overview Nios Ethernet Development Kit User Guide
Example hardware reference design configurations:
Nios 32-bit CPU for a single daughter card Nios 16-bit CPU for a single daughter card Nios 32-bit for dual-stacked daughter cards
Example software applications:
Library general demonstration and configuration programs Example web server Nios 32-bit CPU network-based GERMS monitor application
example
Documentation:
Nios Ethernet Development Kit User Guide
Installed
The Nios EDK CD-ROM includes an InstallShield
®
installation wizard for
Windows workstations, and install scripts for Unix workstations. See
Components
Install the Hardware and Software Files on page 16 for step-by-step
installation instructions.
The Nios EDK adds files to your SOPC Builder home <SOPC-HOME> directory. By default, the install program adds the files to the SOPC Builder home directory C:\Altera\Excalibur\sopc_builder_2_5. During installation you have the option to add the SOPC Builder tool to another directory. In this document, the SOPC Builder home directory is referred to as <SOPC-HOME>. Below are the directories and files found in the C:\Altera\Excalibur\sopc_builder_2_5 default directory.
The SOPC Builder library component directories are:
–<SOPC-HOME>/components/altera_avalon_cs8900/
–<SOPC-HOME>/components/altera_avalon_lan91c111/
The APEX hardware (FPGA) reference designs are:
<SOPC-HOME>/examples/verilog/nios_dev_board/ethernet/
standard_cs8900_16/
<SOPC-HOME>/examples/verilog/nios_dev_board/ethernet/
standard_cs8900_32/
<SOPC-HOME>/examples/verilog/nios_dev_board/ethernet/
standard_cs8900_stacked_32/
<SOPC-HOME>/examples/verilog/nios_dev_board/ethernet/
standard_lan91c111_16/
<SOPC-HOME>/examples/verilog/nios_dev_board/ethernet/
standard_lan91c111_32/
<SOPC-HOME>/examples/verilog/nios_dev_board/ethernet/
standard_lan91c111_stacked_32/
1 To access the .vhdl default directory files, change /verilog/ to
/vhdl/in the default directory files shown for verilog.
Nios Ethernet Development Kit User Guide Overview
The PDF documentation files are in:
<SOPC-HOME>/documents/nedk/
1 For the most current version of this user guide, see
http://www.altera.com/literature/lit-nio.html.
A complete set of PC-board manufacturing documents for the
daughter card. This includes all design-files necessary to build and assemble the daughter card board and components. These documents are found in following directories:
<SOPC-HOME>/documents/nedk_daughtercard_cs8900/
<SOPC-HOME>/documents/nedk_daughtercard_lan91c111/
1
Overview
f
MAC Addresses
For detailed specifications for the SMSC LAN 91C111 chip, see
http://www.smsc.com/main/catalog/lan91c111.html
For detailed specification for the Cirrus® Logic CS8900A chip, see
http://www.cirrus.com/design/products/overview/detail.cfm?d= 46
The Nios EDK daughter card manufacturing and design documents give you all the necessary information to build copies of the daughter card yourself. You may also use these design files to copy and paste sections of the daughter card design into your own custom PC-board schematic, layout, or bill of materials (BOM).
All Ethernet devices require a unique 48-bit Ethernet media access control (MAC) address. All Nios EDK kits ship with the same default MAC address. This MAC address serves as a placeholder during development. To obtain your own block of unique Ethernet MAC addresses for your products, refer to the IEEE web site at
http://www.standards.ieee.org/regauth/oui/index.shtml.
A single Nios EDK system can use the default MAC address on a LAN without a conflict. However, two Nios EDK systems with the same MAC address will cause conflicts. If you are using two or more Nios EDK systems on the same LAN, you must assign a unique Ethernet MAC address to each system.
The Nios Development Kit and the Nios EDK form a prototyping platform for creating your custom embedded, networked system. These development boards, reference designs, and applications allow you to rapidly prototype your application.
Altera Corporation 11
Verify Kit Contents
Getting Started
This section explains how to set up the Nios EDK daughter card, install the Nios EDK files, load the hardware reference design into the board and run the Ethernet application examples.
Verify the following items are included in your Nios Ethernet Development Kit:
Nios EDK daughter card based on the SMSC LAN 91C111
PHY/MAC chip
Male-to-male RJ-45 network cable
Female-to-male crossover adapter, used for direct-PC connection
Nios EDK CD-ROM
OReilly Internet Core Protocols Manual
Nios Ethernet Development Kit User Guide
2
Getting Started
Set Up the Daughter Card
f
The hardware reference designs included with the Nios EDK assume the daughter card is connected to the prototype connectors JP8, JP9, and JP10 on the Nios development board and that your board is already set up.
If you are setting up your Nios development board for the first time, see the Nios Embedded Processor Getting Started User Guide.
1. Verify that your Nios board is set up correctly and the power is off.
Altera Corporation 13
Getting Started Nios Ethernet Development Kit User Guide
1 When connecting the daughter card, make sure you place the
card on the prototype connectors correctly as shown in Figure 1. If you do not, the board may be permanently damaged.
Figure 1. Correct & Incorrect Daughter Card Connection
2. Place the daughter card on the JP8, JP9, and JP10 prototype connectors.
Figure 2. Daughter Card Placement for Use with the APEX Reference Design
Nios Ethernet Development Kit User Guide Getting Started
1 The daughter card can also be placed on the JP11, JP12, and JP13
prototype connectors. However, the APEX hardware reference designs shipped with the kit do not target these prototype connectors and will need to be changed.
Figure 3. Alternative Placement of the Daughter Card
2
Getting Started
3. Connect the network cable to the daughter card.
If you are connected to a LAN or HUB:
Connect the male-to-male networking cable to the RJ-45 connector on the daughter card as shown in Figure 4.
Figure 4. Using the Nios EDK with a LAN or HUB
Altera Corporation 15
Getting Started Nios Ethernet Development Kit User Guide
If you are not using a LAN or HUB connection and are connected directly to a workstation or PC Ethernet jack, insert the female-to­male RJ-45 crossover adapter to the networking cable and then connect the adapter to the RJ-45 on the daughter card as shown in
Figure 5.
Figure 5. Using the Nios EDK with a Workstation or PC Ethernet Jack
Install the Hardware and Software Files
f
4. Connect the other end of the networking cable to your Ethernet LAN or workstation.
The instructions below are for a Windows PC. These instructions assume you have already installed or upgraded your Nios Development Kit to version 2.1 or higher.
1. Insert the Nios EDK CD-ROM into your CD-ROM drive. The InstallShield installer begins automatically.
Unix users: See the readme text file for installation instructions.
Nios Ethernet Development Kit User Guide Getting Started
2. Follow the installation instructions. The screen in Figure 6 appears when you have completed the installation. Click Finish.
Figure 6. Install Completed
2
Getting Started
Load the Reference Design
This section explains how you will use the Quartus Nios ethernet reference design into the Nios development board. All instructions assume you are using the Quartus II software.
1. Click the Start Menu > Programs > Altera > Nios Ethernet
Development Kit 2.0 > Nios Ethernet Development Kit Reference Design.
2. In the Quartus II software, click the Open Programmer icon.
Figure 7. Quartus II Software Icons
Open Programmer Icon
®
II software to load the
Altera Corporation 17
Getting Started Nios Ethernet Development Kit User Guide
The Chain 1 dialog box appears as shown in Figure 8.
Figure 8. Chain 1 Dialog Box
3. Click Add File. The Select File dialog box appears as shown in
Figure 9.
Figure 9. The Select File Dialog Box
Nios Ethernet Development Kit User Guide Getting Started
4. Double-click the standard_lan91c111_32.sof file and the file appears in the Chain 1 dialog box as shown in Figure 10.
Figure 10. Chain 1 Dialog Box
2
Getting Started
5. Click the check box in the Program/Configure column as shown in
Figure 10.
6. Check the Programming Hardware section of the screen as shown in
Figure 10. ByteBlasterMV should appear in the Type field
selection. To change the type, click Setup and select ByteBlasterMV from the Hardware Type drop-down list box.
Altera Corporation 19
Getting Started Nios Ethernet Development Kit User Guide
Figure 11. ByteBlasterMV Selection
1 If ByteBlasterMV is not an available selection, you will need to
install the ByteBlasterMV driver.
f
f
Run Example Applications
For information about installing the ByteBlasterMV driver, see the
Quartus II Installation & Licensing for PCs Manual at the Altera web site.
7. In the Chain 1 dailog box, click Start . See Figure 10 on page 19. The two-digit seven-segment display on the Nios development board turns off. When the download is completed, the Progress bar reads 100% and the dual seven-segment LED display lights turn on.
If you encounter a JTAG error, see the Nios Embedded Processor
Development Board Data Sheet for information on setting the switches
correctly.
Using the Nios SDK Shell, you will now run the example applications. Nios software is developed in the Bash environment. If you are unfamiliar with the Bash environment, refer to the Nios Embedded Processor Software
Development Reference Manual for more information.
The Hello Plugs Application Example
To run Hello Plugs, follow these steps:
1. Click the Start Menu > Programs > Altera > Excalibur Nios 2.1> Nios SDK Shell. The SDK Shell window appears and displays the SDK Shell prompt as shown in Figure 12 on page 21.
Nios Ethernet Development Kit User Guide Getting Started
Figure 12. The Nios SDK Shell
2
Getting Started
f
2. At the prompt, type;
cd verilog/nios_dev_board/ethernet/ standard_lan91c111_32/cpu_sdk/src r
1 If you installed the Nios EDK program in another directory,
make the appropriate change in step 2.
3. Type nios-build hello_plugs.c r
The default setting for the nios-run utility is <COM1>. For more information about specifying another serial port when executing nios- run,see the Nios Embedded Processor Software Development Reference
Manual.
4. Press SW3 to clear the Nios development board.
5. Type nios-run hello_plugs.srec r
The hello_plugs.srec file begins downloading to the board as shown in Figure 13.
Altera Corporation 21
Loading...
+ 47 hidden pages