Altera DE2: DM9000A Ethernet Controller Application Notes: By: Brent Erickson Mavis Chan Sydney Bitner
Altera DE2: DM9000A Ethernet Controller Application Notes: By: Brent Erickson Mavis Chan Sydney Bitner
Altera DE2: DM9000A Ethernet Controller Application Notes: By: Brent Erickson Mavis Chan Sydney Bitner
Hardware Configuration
In order to simplify the hardware configuration process, Terasic has provided the HDL and TCL files
necessary to add the component to a system through SOPC builder. These files can be downloaded
from
https://www.ualberta.ca/~delliott/local/ece492/appnotes/2013w/Ethernet_DM9000A/DM9000A.tar
QSys System
The Ethernet controller will need to be supplied with a 25 MHz clock. This can be accomplished by
creating a new clock, or dividing the system clock by 2. The system clock is assumed to run at 50
MHz. The second approach will be taken here by using an ALTPLL.
Note: The following steps only show what needs to be added to get the DM9000A working. They
assume that a NIOSII processor and other components (such as RAM) have already been added to
the system.
1. In the downloaded file, there is a folder named hardware. Copy the contents of this folder to
the root of your Quartus project.
2. In Quartus, go to Tools → QSys.
3. Add an Avalon ALTPLL if one doesn't already exist.
4. Create a clock of 25MHz and export the signal.
5. In the component list in QSys, there should be a new category: “Terasic Technologies Inc.”.
Under this category is the DM9000A component. Add this component to the system.
6. Export the conduit signal under the DM9000A component.
7. Connect the Component as shown in Figure 1 below
8. Generate the Qsys system.
Figure 1 Qsys System
2. Add the necessary signals into your system component (assuming the DM9000A was called
DM9000A_0 in SOPC Builder).
dm9000a_if_0_s1_export_DATA : inout std_logic_vector(15 downto 0) := (others => 'X'); -- DATA
dm9000a_if_0_s1_export_CMD : out std_logic; -- CMD
dm9000a_if_0_s1_export_RD_N : out std_logic; -- RD_N
dm9000a_if_0_s1_export_WR_N : out std_logic; -- WR_N
dm9000a_if_0_s1_export_CS_N : out std_logic; -- CS_N
dm9000a_if_0_s1_export_RST_N : out std_logic; -- RST_N
dm9000a_if_0_s1_export_INT : in std_logic := 'X'; -- INT
dm9000a_if_0_s1_export_CLK : out std_logic;
The DM9000A component should now be connected. The final step is to program the board with the
new configuration.
Software Configuration
After adding the component to the system, the software drivers are not added automatically in the
NIOS II IDE. The following additions and initializations need to be done in software.
1. Add the files from the “software” folder of the downloaded tar file to the root of your software
project.
2. Open the dm9000a.h file and add these lines:
#define DM9000A_0_BASE DM9000A_IF_0_BASE
#define DM9000A_0_IRQ DM9000A_IF_0_IRQ
#define DM9000A_0_NAME DM9000A_IF_0_NAME
3. In web_server.c, define the green leds base and lcd display name if they are different than the
default ones in the file.
#define LED_PIO_BASE GREEN_LEDS_BASE3
#define LCD_DISPLAY_NAME LCD_0_NAME
4. Define the flash name and base in network_utilities.c. Add the following lines:
#define EXT_FLASH_NAME CFI_FLASH_0_NAME
#define EXT_FLASH_BASE CFI_FLASH_0_BASE
5. Initialize the controller by adding the following lines in the main() function in web_server.c: (Add
dm9000a.h as the first include-file at the top of web_server.c)
DM9000A_INSTANCE( DM9000A_0, dm9000a_0 );
DM9000A_INIT( DM9000A_0, dm9000a_0 );
Now that the board is connected and the IP is known, the board's web site can be accessed by
accessing the IP through a browser. A simpler test can be performed by simply pinging the IP of the
board from a computer.
Further Reading
The web server and simple socket server provided by Altera are extremely good examples on how to
use the Ethernet controller as well as how to set up a whole web server. The Altera directory
provided on the lab computers has a DE2 demonstration named SE2_NIOS_HOST_MOUSE_VGA
that utilizes the Ethernet.
Note: The demonstration projects provided on the University labs are quite old, and will likely lead
to hardware or other compilation errors. Newer versions of the demonstrations updated to support
Quartus II 10.0 are the DE2_70 demonstrations. These demonstrations are not for the Cylone II, but
they contain excellent examples of updated code and drivers for the newer Quartus. These
demonstrations can be downloaded from here: http://www.terasic.com/downloads/cd-
rom/de2_70/DE2_70_demonstrations_V10.rar
The above rar file contains three projects that utilize the Ethernet: DE2_70_NET,
DE2_70_NIOS_HOST_MOUSE_VGA and DE2_70_SD_Card_Audio_Player.
References
Previous application notes from winter2012 for running a web server:
http://www.ece.ualberta.ca/~elliott/ece492/appnotes/2012w/Webserver/
Author Information
Based on application notes from 2013 Ethernet App Notes by Tarek Kaddoura and
Jigar Nahar. Compiled by Group 9: Brent Erickson, Mavis Chan & Sydney Bitner.