Page 1
Nios Ethernet Development Kit User Guide 101 Innovation Drive San Jose, CA 95134 (408) 544-7000 Document Version: 3.0 http://www.altera.com Document Date: August 2002...
Page 2
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.
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...
Note: 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 document—e.g., clarification requests, inaccuracies, or inconsistencies— Feedback send e-mail to nios_docs@altera.com. Altera Corporation...
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 Conventions Table 3. 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.
..........................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...
Page 8
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...
The Nios EDK library components and tools can be installed on Solaris, HP-UX or PC-Windows (NT/2000/XP). 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:...
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: –...
Nios Ethernet Development Kit User Guide Overview The PDF documentation files are in: – <SOPC-HOME>/documents/nedk/ 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.
Nios EDK files, load the hardware reference design into the board and run the Ethernet application examples. Verify Kit Verify the following items are included in your Nios Ethernet Development Kit: Contents Nios EDK daughter card based on the SMSC LAN 91C111...
Page 14
Getting Started Nios Ethernet Development Kit User Guide When connecting the daughter card, make sure you place the card on the prototype connectors correctly as shown in Figure If you do not, the board may be permanently damaged. Figure 1. Correct & Incorrect Daughter Card Connection Place the daughter card on the JP8, JP9, and JP10 prototype connectors.
Page 15
Nios Ethernet Development Kit User Guide Getting Started 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.
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...
Reference instructions assume you are using the Quartus II software. Design Click the Start Menu > Programs > Altera > Nios Ethernet Development Kit 2.0 > Nios Ethernet Development Kit Reference Design. In the Quartus II software, click the Open Programmer icon.
Page 18
Getting Started Nios Ethernet Development Kit User Guide The Chain 1 dialog box appears as shown in Figure Figure 8. Chain 1 Dialog Box Click Add File. The Select File dialog box appears as shown in Figure Figure 9. The Select File Dialog Box...
Page 19
Nios Ethernet Development Kit User Guide Getting Started Double-click the standard_lan91c111_32.sof file and the file appears in the Chain 1 dialog box as shown in Figure Figure 10. Chain 1 Dialog Box Click the check box in the Program/Configure column as shown in...
The Hello Plugs Application Example To run Hello Plugs, follow these steps: 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...
Page 21
Nios Ethernet Development Kit User Guide Getting Started Figure 12. The Nios SDK Shell At the prompt, type; cd verilog/nios_dev_board/ethernet/ standard_lan91c111_32/cpu_sdk/src r If you installed the Nios EDK program in another directory, make the appropriate change in step 2. Type nios-build hello_plugs.c r The default setting for the nios-run utility is <COM1>.
Page 22
Peripheral Test Menu could appear. If this menu appears, press Ctrl+C and then repeat Step 5. Once the download is completed, the Hello Plugs Main Menu appears as shown in Figure Figure 14. The Nios Ethernet Hello Plugs Main Menu Altera Corporation...
Nios Ethernet Development Kit User Guide Getting Started Before you can use Hello Plugs, the network-based GERMS monitor, or the simple web server application examples, you must first configure your network settings. Configure Your Network Settings The instructions for configuring your network settings will only work if your PC is connected directly to your Nios development board with a Nios EDK daughter card using an Ethernet cable and crossover adapter.
Getting Started Nios Ethernet Development Kit User Guide Type your PC’s IP address for the IP address. Change the last number in the IP address up or down one digit (the allowable range is 2 to 254). For example, if your PC is using IP address 64.3.99.73, set your Nios EDK to 64.3.99.72 or 64.3.99.74.
Page 25
Nios Ethernet Development Kit User Guide Getting Started For more information about using the GERMS monitor, refer to the Nios Embedded Processor Software Development Reference Manual http://www.altera.com. To run the networked-based GERMS monitor application example, follow these steps: Run the Hello Plugs application to setup your network parameters if you have not done so already.
Page 26
Getting Started Nios Ethernet Development Kit User Guide Figure 16. Connecting to the GERMS Server Press the ? key + Enter to display the GERMS menu as shown in Figure Figure 17. The Nios GERMS Menu To change the dual 7-segment display, type m420:3636 r This command confirms your networked GERMS monitor-based application example is working.
Nios Ethernet Development Kit User Guide Getting Started For more information, see the readme_nedk_germs.txt file included in your kit. The Simple Web Server Application Example To use this application example, you must first run the Hello Plugs application to setup your network parameters. See “The Hello Plugs...
A 25 MHz crystal oscillator that is used by the SMSC LAN 91C111 chip All necessary resistors and capacitors A complete manufacturing bill of materials for the daughter card is provided in the installed nedk_daughter_card_documents directory. Figure 18. The Nios EDK Daughter Card RJ-45 connector LAN91C111 Ethernet controller Altera Corporation...
Daughter Card Nios Ethernet Development Kit User Guide Functional The main functional component on the Nios EDK daughter card is a LAN91C111 integrated PHY/MAC chip. See http://www.smsc.com/ Overview main/catalog/lan91c111.html for detailed specifications. The LAN91C111 presents an ISA-bus interface to the Nios CPU. The necessary electrical-interface signals are provided on the set of female connectors.
Nios Ethernet Development Kit User Guide Daughter Card SOPC Builder The Nios EDK includes an SOPC Builder library component that provides all logic and I/O signals necessary for using the daughter card. A library Library component is an add-on to the SOPC Builder that makes a new peripheral available.
Daughter Card Nios Ethernet Development Kit User Guide Each Ethernet interface (lan91c111) component in your system will have an associated group of I/O pins on your system module. A detailed description of how to connect these system-module I/O pins to the Nios EDK daughter card can be found at “Nios System to Daughter Card Pin...
Page 33
Nios Ethernet Development Kit User Guide Daughter Card Figure 21. F2 Connector Pinouts Figure 22. F1 Connector Pinouts Altera Corporation...
Daughter Card Nios Ethernet Development Kit User Guide Figure 23. F3 Connector Pinouts Nios System to Each Ethernet interface (lan91c111) peripheral in your Nios system has an associated set of I/O pins on your system module. This section describes Daughter Card how to connect these system-module I/O pins to the daughter card.
Page 35
Nios Ethernet Development Kit User Guide Daughter Card Table 4. Nios 32-bit CPU System Module I/O Port Name and Daughter Card Pin Name Daughter Card Pin Name 32-bit CPU System Module I/O Port Name GND (logic 0) INT (lower) irq_to_the <your_name> of lower card INT (upper) irq_to_the <your_name>...
Page 36
Daughter Card Nios Ethernet Development Kit User Guide Table 4. Nios 32-bit CPU System Module I/O Port Name and Daughter Card Pin Name Daughter Card Pin Name 32-bit CPU System Module I/O Port Name SD12 <your_bus_name>_data [12] SD13 <your_bus_name>_data [13] SD14 <your_bus_name>_data [14]...
Page 37
Nios Ethernet Development Kit User Guide Daughter Card Table 5. Nios 16-bit CPU System Module I/O Port Name and Daughter Card Pin Name Daughter Card Pin Name 16-bit CPU System Module I/O Port Name SD[15..0] <your_bus_name>_data SA[3] <your_bus_name>_address [3] SA[2] <your_bus_name>_address [2]...
The Plugs Library requires your system to have a Timer peripheral named timer 1. The customized software development kit for the LAN91C111 Ethernet- adapter peripherals contains the Plugs Library and example applications. This library contains single-threaded routines that rely on polling. Altera Corporation...
Software Overview Nios Ethernet Development Kit User Guide Protocols Figure 24 shows the relationships between the library-supported Nios EDK protocols. Architecture Figure 24. Nios EDK Protocol Structure hello_plugs.c PING ARP Scanner TELNET World Wide Web ICMP Raw Ethernet PLUGS LIBRARY...
Nios Ethernet Development Kit User Guide Software Overview ARP (RFC 826) Library routines are provided to query the LAN for the Ethernet address of a particular remote IP address, and to respond to queries for the local IP address. Other protocols like IP use ARP transparently.
Software Overview Nios Ethernet Development Kit User Guide Build Options The following build options are provided for modulating the features and the footprint of the Plugs Library. PLUGS_DEBUG (Default Value = 1) This build option may be set to zero, to disable all debug-printing...
Nios Ethernet Development Kit User Guide Software Overview PLUGS_TCP (Default Value = 1) If your application does not use TCP for any of its plugs, you can disable it and save a small amount of code space by setting this build option to zero.
Software Overview Nios Ethernet Development Kit User Guide Data Structures ns_plugs_network_setting Structure: typedef struct net_48 ethernet_address; short pad; net_32 ip_address; net_32 nameserver_ip_address; ns_plugs_network_settings; Description: This structure is used to configure an adapter with all the necessary network information. It is passed to the Plugs Library routine nr_plugs_initialize() for each adapter.
Page 45
Nios Ethernet Development Kit User Guide Software Overview ns_plugs_network_setting subnet_mask This is a 32-bit value in network-byte order. This mask val- ue is used to determine if a particular remote network de- vice is on the same LAN as the Nios-based device. If any bits of the Nios-based device’s IP address differ from any...
Page 46
Software Overview Nios Ethernet Development Kit User Guide ns_plugs_persistent_network_settings Structure: typedef struct long settings_index; // 0..3 ns_plugs_network_settings settings[4]; ns_plugs_persistent_network_settings; Description: The example programs that use the Plugs Library make use of nonvolatile network settings stored in the Flash memory. The program hello_plugs.c lets you enter up to four sets of network settings, and use these setting interchangeably.
Nios Ethernet Development Kit User Guide Software Overview Payload Each protocol treats a different part of the raw Ethernet packet as the payload. The payload is the part of the packet passed to the receive Descriptions callback procedure. The callback procedure can access the payload and all encapsulating header information.
Prints an Ethernet packet report nr_n2h16 Translates a network-short integer to a short integer nr_h2n16 Translates a short integer to a network-short integer nr_n2h32 Translates a network-long integer to a long integer nr_h2n32 Translates a long integer to a network-long integer Altera Corporation...
Plugs Library Routines Nios Ethernet Development Kit User Guide nr_plugs_initialize Syntax: int nr_plugs_initialize long flags, ns_plugs_network_settings *network_settings, void *adapter_base_address, int adapter_irq, ns_plugs_adapter_description *adapter_description Description: This routine can either initialize the plugs library or add an additional adapter to the plugs library. Each adapter is completely distinct from each other.
Nios Ethernet Development Kit User Guide Plugs Library Routines nr_plugs_terminate Syntax: nr_plug_terminate(void) void Description: Call this routine when you are done using the plugs library. If you need to reinitialize the plugs library with different network settings, call this routine first before reinitializing.
Plugs Library Routines Nios Ethernet Development Kit User Guide nr_plugs_set_mac_led Syntax: int nr_plug_set_mac_led int adapter_index, int led_onoff Description: This routine controls the LED present on most Ethernet jacks. If a particular adapter does not have a LED on the Ethernet jack, this routine does nothing. The LAN91C111 LED’s default behavior is to be on if it is connected to a...
Nios Ethernet Development Kit User Guide Plugs Library Routines nr_plugs_create Syntax: int nr_plugs_create int *plugs_handle_out, int protocol, host_16 port, nr_plugs_receive_callback_proc callback, void *callback_context, long flags Description: This routine creates a plug. A plug is a logical endpoint for network communications. A plug is in some ways similar to a traditional UNIX socket.
Page 54
Plugs Library Routines Nios Ethernet Development Kit User Guide callback When data arrives for this plug, your callback routine is called with the data. The parameters of the callback rou- tine are documented under nr_plugs_receive_callback_proc. callback _context This parameter is passed unmodified to your callback rou- tine.
Nios Ethernet Development Kit User Guide Plugs Library Routines typedef int (*nr_plugs_receive_callback_proc) Syntax: typedef int (*nr_plug_receive_callback_proc) int plug_handle void *context, ns_plugs_packet *p, void *payload, int payload_length Description: This is a routine you provide when you create a plug. The plugs library will call this routine whenever a packet ar- rives for the plug.
Page 56
Plugs Library Routines Nios Ethernet Development Kit User Guide p For example, suppose you created a plug that was using the TCP protocol. When your callback routine is called, you could examine the enclosing Ethernet packet header by reading at location p[ne_plugs_ethernet].head- er.
Nios Ethernet Development Kit User Guide Plugs Library Routines nr_plugs_destroy Syntax: int nr_plugs_destroy int plug_handle, Description: Deallocates a plug. When you no longer need a plug, call this routine to deallocate any resources associated with the discarded plug. Parameters: plug_handle A reference to the plug you are eliminating.
A reference to the plug you are connecting remote_name A pointer to a string containing the name of a remote-network de- vice (for example, http://www.altera.com). The routine will at- tempt to resolve the name to an IP address by using the DNS server associated with the first adapter installed.
Page 59
Nios Ethernet Development Kit User Guide Plugs Library Routines Include: plugs.h Transmission to another plug on the same Nios system will not succeed and loopback is not supported. Altera Corporation...
Plugs Library Routines Nios Ethernet Development Kit User Guide nr_plugs_send Syntax: int nr_plugs_send int plug_handle, void *data, int data_length, long flags Description: This routine transmits a packet of data using a particular plug. Before you call this routine, you must call nr_plugs_connect() to associate the plug with a par- ticular remote-network device.
Nios Ethernet Development Kit User Guide Plugs Library Routines nr_plugs_send_to Syntax: int nr_plugs_send_to int plug_handle, void *data, int data_length, long flags, net_32 ip_address, // net order net_16 port net order Description: This routine is identical to nr_plugs_send(), with the addition of a destination IP address and port. When a plug uses UDP, you can easily send a packet to any destina- tion using this routine.
Plugs Library Routines Nios Ethernet Development Kit User Guide int nr_plugs_listen Syntax: int nr_plugs_listen int plug_handle, nr_plugs_listen_callback_proc callback, void *callback_context Description: Only call this routine if the plug uses TCP. This routine tells the plug to wait for an incoming TCP connection re- quest.
Nios Ethernet Development Kit User Guide Plugs Library Routines typedef int (*nr_plugs_listen_callback_proc) Syntax: typedef int (*nr_plugs_listen_callback_proc) int plug_handle, void *context, host_32 remote_ip_address, host_16 remote_port Description: This is a routine you provide when you allow a TCP plug to accept connections using the nr_plugs_listen()rou- tine.
Plugs Library Routines Nios Ethernet Development Kit User Guide nr_plugs_ip_to_ethernet Syntax: int nr_plugs_ip_to_ethernet int adapter_index, net_32 ip_address, net_48 *ethernet_address_out, long flags Description: When this routine is given an IP address, it discovers which is the correct Ethernet address for the packets be- ing sent.
Nios Ethernet Development Kit User Guide Plugs Library Routines nr_plugs_name_to _ip Syntax: int nr_plugs_name_to_ip char *host_name, net_32 *host_ip_address_out Description: When this routine is given the name of a remote-network device it queries the name server to find out the IP ad- dress.
Plugs Library Routines Nios Ethernet Development Kit User Guide nr_plugs_idle Syntax: int nr_plugs_idle(void) void Description: If interrupts are not enabled, then this routine must be called frequently in your program’s inner loop, or from a timer interrupt routine. It polls the hardware device for in- coming packets, and dispatches them via each plug’s call-...
Nios Ethernet Development Kit User Guide Plugs Library Routines void nr_plugs_print_ethernet_packet Syntax: void nr_plugs_print_ethernet_packet(void) ns_plugs_ethernet_packet *p, int length, char *title Description: This routine prints an Ethernet packet in a friendly, hu- man-readable format. Parameters: p A pointer to an Ethernet packet.
Plugs Library Routines Nios Ethernet Development Kit User Guide The following routines and macros are for your general use, and are required when you are translating between host-byte ordering and network-byte ordering for Nios EDK-network programming. Network-byte ordering is always big-endian and Nios host-byte ordering is little-endian.