Development and Education Board
Development and Education Board
User Manual
CONTENTS
Chapter 1 DE2 Package.....................................................................................................................1
1.1 Package Contents .................................................................................................................1
1.2 The DE2 Board Assembly....................................................................................................2
1.3 Getting Help.........................................................................................................................3
ii
Altera DE2 Board
iii
DE2 User Manual
Chapter 1
DE2 Package
The DE2 package contains all components needed to use the DE2 board in conjunction with a
computer that runs the Microsoft Windows software.
1
DE2 User Manual
2
DE2 User Manual
• Altera Corporation
101 Innovation Drive
San Jose, California, 95134 USA
Email: [email protected]
• Terasic Technologies
No. 356, Sec. 1, Fusing E. Rd.
Jhubei City, HsinChu County, Taiwan, 302
Email: [email protected]
Web: DE2.terasic.com
• Arches Computing
Unit 708-222 Spadina Ave
Toronto, Ontario, Canada M5T3A2
Email: [email protected]
Web: DE2.archescomputing.com
A BBS (Bulletin Board System) Forum for the DE2 board has been created at the address shown
below. This Forum is meant to serve as a repository for information about the DE2 board, and to
provide a resource through which users can ask questions, and share design examples.
3
DE2 User Manual
Chapter 2
Altera DE2 Board
This chapter presents the features and design characteristics of the DE2 board.
The DE2 board has many features that allow the user to implement a wide range of designed
circuits, from simple circuits to various multimedia projects.
4
DE2 User Manual
In addition to these hardware features, the DE2 board has software support for standard I/O
interfaces and a control panel facility for accessing various components. Also, software is provided
for a number of demonstrations that illustrate the advanced capabilities of the DE2 board.
In order to use the DE2 board, the user has to be familiar with the Quartus II software. The
necessary knowledge can be acquired by reading the tutorials Getting Started with Altera’s DE2
Board and Quartus II Introduction (which exists in three versions based on the design entry method
used, namely Verilog, VHDL or schematic entry). These tutorials are provided in the directory
DE2_tutorials on the DE2 System CD-ROM that accompanies the DE2 board and can also be
found on Altera’s DE2 web pages.
5
DE2 User Manual
6
DE2 User Manual
SRAM
• 512-Kbyte Static RAM memory chip
• Organized as 256K x 16 bits
• Accessible as memory for the Nios II processor and by the DE2 Control Panel
SDRAM
• 8-Mbyte Single Data Rate Synchronous Dynamic RAM memory chip
• Organized as 1M x 16 bits x 4 banks
• Accessible as memory for the Nios II processor and by the DE2 Control Panel
Flash memory
• 4-Mbyte NAND Flash memory (1 Mbyte on some boards)
• 8-bit data bus
• Accessible as memory for the Nios II processor and by the DE2 Control Panel
SD card socket
• Provides SPI mode for SD Card access
• Accessible as memory for the Nios II processor with the DE2 SD Card Driver
Pushbutton switches
• 4 pushbutton switches
• Debounced by a Schmitt trigger circuit
• Normally high; generates one active-low pulse when the switch is pressed
Toggle switches
• 18 toggle switches for user inputs
• A switch causes logic 0 when in the DOWN (closest to the edge of the DE2 board) position
and logic 1 when in the UP position
Clock inputs
• 50-MHz oscillator
• 27-MHz oscillator
• SMA external clock input
7
DE2 User Manual
Audio CODEC
• Wolfson WM8731 24-bit sigma-delta audio CODEC
• Line-level input, line-level output, and microphone input jacks
• Sampling frequency: 8 to 96 KHz
• Applications for MP3 players and recorders, PDAs, smart phones, voice recorders, etc.
VGA output
• Uses the ADV7123 240-MHz triple 10-bit high-speed video DAC
• With 15-pin high-density D-sub connector
• Supports up to 1600 x 1200 at 100-Hz refresh rate
• Can be used with the Cyclone II FPGA to implement a high-performance TV Encoder
8
DE2 User Manual
• Provides a high-speed parallel interface to most available processors; supports Nios II with a
Terasic driver
• Supports Programmed I/O (PIO) and Direct Memory Access (DMA)
Serial ports
• One RS-232 port
• One PS/2 port
• DB-9 serial connector for the RS-232 port
• PS/2 connector for connecting a PS2 mouse or keyboard to the DE2 board
IrDA transceiver
• Contains a 115.2-kb/s infrared transceiver
• 32 mA LED drive current
• Integrated EMI shield
• IEC825-1 Class 1 eye safe
• Edge detection input
1. Connect the provided USB cable from the host computer to the USB Blaster connector on
the DE2 board. For communication between the host and the DE2 board, it is necessary to
install the Altera USB Blaster driver software. If this driver is not already installed on the
host computer, it can be installed as explained in the tutorial Getting Started with Altera's
DE2 Board. This tutorial is available on the DE2 System CD-ROM and from the Altera
DE2 web pages.
2. Connect the 9V adapter to the DE2 board
3. Connect a VGA monitor to the VGA port on the DE2 board
4. Connect your headset to the Line-out audio port on the DE2 board
9
DE2 User Manual
5. Turn the RUN/PROG switch on the left edge of the DE2 board to RUN position; the
PROG position is used only for the AS Mode programming
6. Turn the power on by pressing the ON/OFF switch on the DE2 board
10
DE2 User Manual
Chapter 3
DE2 Control Panel
The DE2 board comes with a Control Panel facility that allows a user to access various components
on the board through a USB connection from a host computer. This chapter first presents some
basic functions of the Control Panel, then describes its structure in block diagram form, and finally
describes its capabilities.
In addition to the DE2_USB_API.sof file, it is necessary to execute on the host computer the
program DE2_control_panel.exe. Both of these files are available on the DE2 System CD-ROM
that accompanies the DE2 board, in the directory DE2_control_panel. Of course, these files may
already have been installed to some other location on your computer system.
11
DE2 User Manual
7. The Control Panel is now ready for use; experiment by setting the value of some 7-segment
display and observing the result on the DE2 board.
The concept of the DE2 Control Panel is illustrated in Figure 3.3. The IP that performs the control
functions is implemented in the FPGA device. It communicates with the Control Panel window,
which is active on the host computer, via the USB Blaster link. The graphical interface is used to
issue commands to the control circuitry. The provided IP handles all requests and performs data
transfers between the computer and the DE2 board.
12
DE2 User Manual
The DE2 Control Panel can be used to change the values displayed on 7-segment displays, light up
LEDs, talk to the PS/2 keyboard, read/write the SRAM, Flash Memory and SDRAM, load an image
pattern to display as VGA output, load music to the memory and play music via the audio DAC.
The feature of reading/writing a byte or an entire file from/to the Flash Memory allows the user to
develop multimedia applications (Flash Audio Player, Flash Picture Viewer) without worrying about
how to build a Flash Memory Programmer.
In the window shown in Figure 3.2, the values to be displayed by the 7-segment displays (which are
named HEX7-0) can be entered into the corresponding boxes and displayed by pressing the Set
button. A keyboard connected to the PS/2 port can be used to type text that will be displayed on the
LCD display.
Choosing the LED & LCD tab leads to the window in Figure 3.4. Here, you can turn the individual
LEDs on by selecting them and pressing the Set button. Text can be written to the LCD display by
typing it in the LCD box and pressing the corresponding Set button.
The ability to set arbitrary values into simple display devices is not needed in typical design
activities. However, it gives the user a simple mechanism for verifying that these devices are
functioning correctly in case a malfunction is suspected. Thus, it can be used for troubleshooting
purposes.
13
DE2 User Manual
14
DE2 User Manual
A 16-bit word can be written into the SDRAM by entering the address of the desired location,
specifying the data to be written, and pressing the Write button. Contents of the location can be
read by pressing the Read button. Figure 3.5 depicts the result of writing the hexadecimal value
6CA into location 200, followed by reading the same location.
The Sequential Write function of the Control Panel is used to write the contents of a file into the
SDRAM as follows:
1. Specify the starting address in the Address box.
2. Specify the number of bytes to be written in the Length box. If the entire file is to be
loaded, then a checkmark may be placed in the File Length box instead of giving the
number of bytes.
3. To initiate the writing of data, click on the Write a File to SDRAM button.
4. When the Control Panel responds with the standard Windows dialog box asking for the
source file, specify the desired file in the usual manner.
The Control Panel also supports loading files with a .hex extension. Files with a .hex extension are
ASCII text files that specify memory values using ASCII characters to represent hexadecimal
values. For example, a file containing the line
0123456789ABCDEF
defines four 16-bit values: 0123, 4567, 89AB, CDEF. These values will be loaded consecutively
into the memory.
The Sequential Read function is used to read the contents of the SDRAM and place them into a file
as follows:
1. Specify the starting address in the Address box.
2. Specify the number of bytes to be copied into the file in the Length box. If the entire
contents of the SDRAM are to be copied (which involves all 8 Mbytes), then place a
checkmark in the Entire SDRAM box.
3. Press Load SDRAM Content to a File button.
4. When the Control Panel responds with the standard Windows dialog box asking for the
destination file, specify the desired file in the usual manner.
15
DE2 User Manual
To open the Flash memory control window, shown in Figure 3.6, select the FLASH tab in the
Control Panel.
A byte of data can be written into a random location on the Flash chip as follows:
1. Click on the Chip Erase button. The button and the window frame title will prompt you to
wait until the operation is finished, which takes about 20 seconds.
2. Enter the desired address into the Address box and the data byte into the wDATA box.
Then, click on the Write button.
16
DE2 User Manual
To read a byte of data from a random location, enter the address of the location and click on the
Read button. The rDATA box will display the data read back from the address specified.
The Sequential Write function is used to load a file into the Flash chip as follows:
1. Specify the starting address and the length of data (in bytes) to be written into the Flash
memory. You can click on the File Length checkbox to indicate that you want to load the
entire file.
2. Click on the Write a File to Flash button to activate the writing process.
3. When the Control Panel responds with the standard Windows dialog box asking for the
source file, specify the desired file in the usual manner.
The Sequential Read function is used to read the data stored in the Flash memory and write this data
into a file as follows:
1. Specify the starting address and the length of data (in bytes) to be read from the Flash
memory. You can click on the Entire Flash checkbox to indicate that you want to copy the
entire contents of the Flash memory into a specified file.
2. Click on the Load Flash Content to a File button to activate the reading process.
3. When the Control Panel responds with the standard Windows dialog box asking for the
destination file, specify the desired file in the usual manner.
To run the Control Panel, the user must first set it up as explained in Section 3.1. Figure 3.7 depicts
the structure of the Control Panel. Each input/output device is controlled by a controller instantiated
in the FPGA chip. The communication with the PC is done via the USB Blaster link. A Command
Controller circuit interprets the commands received from the PC and performs the appropriate
actions. The SDRAM, SRAM, and Flash Memory controllers have three user-selectable
asynchronous ports in addition to the Host port that provides a link with the Command Controller.
The connection between the VGA DAC Controller and the FPGA memory allows displaying of the
default image shown on the left side of the figure, which is stored in an M4K block in the Cyclone
II chip. The connection between the Audio DAC Controller and a lookup table in the FPGA is used
to produce a test audio signal of 1 kHz.
17
DE2 User Manual
To let users implement and test their IP cores (written in Verilog) without requiring them to
implement complex API/Host control software and memory (SRAM/SDRAM/Flash) controllers,
we provide an integrated control environment consisting of a software controller in C++, a USB
command controller, and a multi-port SRAM/SDRAM/Flash controller.
Users can connect circuits of their own design to one of the User Ports of the SRAM/SDRAM/Flash
controller. Then, they can download binary data into the SRAM/SDRAM/Flash. Once the data is
downloaded to the SDRAM/Flash, users can configure the memory controllers so that their circuits
can read/write the SDRAM/Flash via the User Ports connected.
3. Select the Asynchronous 1 port for the Flash Multiplexer and then click on the Configure
button to activate the port. You need to click the Configure button to enable the connection
from the Flash Memory to the Asynchronous Port 1 of the Flash Controller (indicated in
Figure 3.7).
4. Set toggle switches SW1 and SW0 to OFF (DOWN position) and ON (UP position),
respectively.
5. Plug your headset or a speaker into the audio output jack and you should hear the music
played from the Audio DAC circuit.
6. Note that the Asynchronous Port 1 is connected to the Audio DAC part, as shown in Figure
3.7. Once you selected Asynchronous Port 1 and clicked the Configure button, the Audio
DAC Controller will communicate with the Flash memory directly. In our example, the
AUDIO_DAC Verilog module defines a circuit that reads the contents of the Flash memory
19
DE2 User Manual
Figure 3.9. Displayed image and the cursor controlled by the scroll bars
• Make sure that the checkboxes Default Image and Cursor Enable are checked.
• Connect a VGA monitor to the DE2 board and you should see on the screen the default
image shown in Figure 3.9. The image includes a cursor which can be controlled by means
of the X/Y-axes scroll bars on the DE2 Control Panel.
The image in Figure 3.9 is stored in an M4K memory block in the Cyclone II FPGA. It is loaded
into the M4K block in the MIF/Hex(Intel) format during the default bit stream configuration stage.
We will next describe how you can display other images and use your own images to generate the
binary data patterns that can be displayed on the VGA monitor.
Another image is provided in the file picture.dat in the folder DE2_demonstrations\pictures on the
DE2 System CD-ROM. You can display this image as follows:
20
DE2 User Manual
• Select the SRAM page of the Control Panel and load the file picture.dat into the SRAM.
• Select the TOOLS page and choose Asynchronous 1 for the SRAM multiplexer port as
shown in Figure 3.10. Click on the Configure button to activate the multi-port setup.
Figure 3.10. Use the Asynchronous Port 1 to access the image data in the SRAM.
21
DE2 User Manual
Figure 3.11. Multi-Port Controller configured to display an image from the SRAM.
You can display any image file by loading it into the SRAM chip or into an M4K memory block in
the Cyclone II chip. This requires generating a bitmap file, which may be done as follows:
1. Load the desired image into an image processing tool, such as Corel PhotoPaint.
2. Resample the original image to have a 640 x 480 resolution. Save the modified image in
the Windows Bitmap format.
3. Execute DE2_control_panel\ImgConv.exe, an image conversion tool developed for the
DE2 board, to reach the window in Figure 3.13.
4. Click on the Open Bitmap button and select the 640 x 480 Grayscale photo for
conversion.
5. When the processing of the file is completed, click on the Save Raw Data button and a file
named Raw_Data_Gray.dat will be generated and stored in the same directory as the
original image file. You can change the file name prefix from Raw_Data to another name
by changing the File Name field in the displayed window.
6. Raw_Data_Gray.dat is the raw data that can be downloaded directly into the SRAM on the
DE2 board and displayed on the VGA monitor using the VGA controller IP described in
the DE2_USB_API project.
7. The ImgConv tool will also generate Raw_Data_BW.dat (and its corresponding TXT
format) for the black and white version of the image – the threshold for judging black or
22
DE2 User Manual
Note: Raw_Data_BW.txt is used to fill in the MIF/Intel Hex format for M4K SRAM
23
DE2 User Manual
Chapter 4
Using the DE2 Board
This chapter gives instructions for using the DE2 board and describes each of its I/O devices.
The DE2 board contains a serial EEPROM chip that stores configuration data for the Cyclone II
FPGA. This configuration data is automatically loaded from the EEPROM chip into the FPGA each
time power is applied to the board. Using the Quartus II software, it is possible to reprogram the
FPGA at any time, and it is also possible to change the non-volatile data that is stored in the serial
EEPROM chip. Both types of programming methods are described below.
1. JTAG programming: In this method of programming, named after the IEEE standards Joint
Test Action Group, the configuration bit stream is downloaded directly into the Cyclone II
FPGA. The FPGA will retain this configuration as long as power is applied to the board;
the configuration is lost when the power is turned off.
2. AS programming: In this method, called Active Serial programming, the configuration bit
stream is downloaded into the Altera EPCS16 serial EEPROM chip. It provides
non-volatile storage of the bit stream, so that the information is retained even when the
power supply to the DE2 board is turned off. When the board's power is turned on, the
configuration data in the EPCS16 device is automatically loaded into the Cyclone II
FPGA.
The sections below describe the steps used to perform both JTAG and AS programming. For both
methods the DE2 board is connected to a host computer via a USB cable. Using this connection, the
board will be identified by the host computer as an Altera USB Blaster device. The process for
installing on the host computer the necessary software device driver that communicates with the
24
DE2 User Manual
USB Blaster is described in the tutorial Getting Started with Altera's DE2 Board. This tutorial is
available on the DE2 System CD-ROM and from the Altera DE2 web pages.
position and then reset the board by turning the power switch off and back on; this action
causes the new configuration data in the EPCS16 device to be loaded into the FPGA chip.
In addition to its use for JTAG and AS programming, the USB Blaster port on the DE2 board can
also be used to control some of the board's features remotely from a host computer. Details that
describe this method of using the USB Blaster port are given in Chapter 3.
There are also 18 toggle switches (sliders) on the DE2 board. These switches are not debounced,
26
DE2 User Manual
and are intended for use as level-sensitive data inputs to a circuit. Each switch is connected directly
to a pin on the Cyclone II FPGA. When a switch is in the DOWN position (closest to the edge of
the board) it provides a low logic level (0 volts) to the FPGA, and when the switch is in the UP
position it provides a high logic level (3.3 volts).
There are 27 user-controllable LEDs on the DE2 board. Eighteen red LEDs are situated above the
18 toggle switches, and eight green LEDs are found above the pushbutton switches (the 9th green
LED is in the middle of the 7-segment displays). Each LED is driven directly by a pin on the
Cyclone II FPGA; driving its associated pin to a high logic level turns the LED on, and driving the
pin low turns it off. A schematic diagram that shows the pushbutton and toggle switches is given in
Figure 4.4. A schematic diagram that shows the LED circuitry appears in Figure 4.5.
A list of the pin names on the Cyclone II FPGA that are connected to the toggle switches is given in
Table 4.1. Similarly, the pins used to connect to the pushbutton switches and LEDs are displayed in
Tables 4.2 and 4.3, respectively.
27
DE2 User Manual
29
DE2 User Manual
Each segment in a display is identified by an index from 0 to 6, with the positions given in Figure
4.7. Note that the dot in each display is unconnected and cannot be used. Table 4.4 shows the
assignments of FPGA pins to the 7-segment displays.
30
DE2 User Manual
31
DE2 User Manual
Important: To use the 27 MHz clock, the TD_RESET pin (PIN_C4) must be asserted to a high logic
level.
32
DE2 User Manual
33
DE2 User Manual
34
DE2 User Manual
35
DE2 User Manual
36
DE2 User Manual
37
DE2 User Manual
The timing specification for VGA synchronization and RGB (red, green, blue) data can be found on
various educational web sites (for example, search for “VGA signal timing”). Figure 4.12 illustrates
the basic timing requirements for each row (horizontal) that is displayed on a VGA monitor. An
active-low pulse of specific duration (time a in the figure) is applied to the horizontal
synchronization (hsync) input of the monitor, which signifies the end of one row of data and the
start of the next. The data (RGB) inputs on the monitor must be off (driven to 0 V) for a time period
called the back porch (b) after the hsync pulse occurs, which is followed by the display interval (c).
During the data display interval the RGB data drives each pixel in turn across the row being
displayed. Finally, there is a time period called the front porch (d) where the RGB signals must
again be off before the next hsync pulse can occur. The timing of the vertical synchronization (vsync)
is the same as shown in Figure 4.12, except that a vsync pulse signifies the end of one frame and the
start of the next, and the data refers to the set of rows in the frame (horizontal timing). Figures 4.13
and 4.14 show, for different resolutions, the durations of time periods a, b, c, and d for both
horizontal and vertical timing.
Detailed information for using the ADV7123 video DAC is available in its datasheet, which can be
found on the manufacturer's web site, and from the Datasheet folder on the DE2 System CD-ROM.
The pin assignments between the Cyclone II FPGA and the ADV7123 are listed in Table 4.8. An
example of code that drives a VGA display is described in Sections 5.2 and 5.3.
38
DE2 User Manual
39
DE2 User Manual
41
DE2 User Manual
42
DE2 User Manual
43
DE2 User Manual
4.12 TV Decoder
The DE2 board is equipped with an Analog Devices ADV7181 TV decoder chip. The ADV7181 is
an integrated video decoder that automatically detects and converts a standard analog baseband
television signal (NTSC, PAL, and SECAM) into 4:2:2 component video data compatible with
16-bit/8-bit CCIR601/CCIR656. The ADV7181 is compatible with a broad range of video devices,
including DVD players, tape-based sources, broadcast sources, and security/surveillance cameras.
The registers in the TV decoder can be programmed by a serial I2C bus, which is connected to the
Cyclone II FPGA as indicated in Figure 4.19. The pin assignments are listed in Table 4.13. Detailed
information on the ADV7181 is available on the manufacturer’s web site, and from the Datasheet
folder on the DE2 System CD-ROM.
44
DE2 User Manual
45
DE2 User Manual
Figure 4.20. A TV Encoder that uses the Cyclone II FPGA and the ADV7123.
Detailed information for using the ISP1362 device is available in its datasheet and programming
guide; both documents can be found on the manufacturer’s web site, and from the Datasheet folder
on the DE2 System CD-ROM. The most challenging part of a USB application is in the design of
the software driver needed. Two complete examples of USB drivers, for both host and device
applications, can be found in Sections 5.3 and 5.4. These demonstrations provide examples of
software drivers for the Nios II processor.
46
DE2 User Manual
47
DE2 User Manual
48
DE2 User Manual
49
DE2 User Manual
50
DE2 User Manual
51
DE2 User Manual
52
DE2 User Manual
53
DE2 User Manual
Chapter 5
Examples of Advanced Demonstrations
This chapter provides a number of examples of advanced circuits implemented on the DE2 board.
These circuits provide demonstrations of the major features on the board, such as its audio and
video capabilities, and USB and Ethernet connectivity. For each demonstration the Cyclone II
FPGA (or EPCS16 serial EEPROM) configuration file is provided, as well as the full source code in
Verilog HDL code. All of the associated files can be found in the DE2_demonstrations folder from
the DE2 System CD-ROM. For each of demonstrations described in the following sections, we
give the name of the project directory for its files, which are subdirectories of the
DE2_demonstrations folder.
54
DE2 User Manual
• Power on the DE2 board, with the USB cable connected to the USB Blaster port. If
necessary (that is, if the default factory configuration of the DE2 board is not currently
stored in EPCS16 device), download the bit stream to the board by using either JTAG or AS
programming
• You should now be able to observe that the 7-segment displays are displaying a sequence of
characters, and the red and green LEDs are flashing. Also, Welcome to the Altera DE2
Board is shown on the LCD display
• Optionally connect a VGA display to the VGA D-SUB connector. When connected, the
VGA display should show a pattern of colors.
• Optionally connect a powered speaker to the stereo audio-out jack
• Place toggle switch SW17 in the UP position to hear a 1 kHz humming sound from the
audio-out port. Alternatively, if switch SW17 is DOWN, the microphone-in port can be
connected to a microphone to hear voice sounds, or the line-in port can be used to play audio
from an appropriate sound source.
The Verilog source code for this demonstration is provided in the DE2_Default folder, which also
includes the necessary files for the corresponding Quartus II project. The top-level Verilog file,
called DE2_Default.v, can be used as a template for other projects, because it defines ports that
correspond to all of the user-accessible pins on the Cyclone II FPGA.
As soon as the bit stream is downloaded into the FPGA, the register values of the TV Decoder chip
are used to configure the TV decoder via the I2C_AV_Config block, which uses the I2C protocol to
communicate with the TV Decoder chip. Following the power-on sequence, the TV Decoder chip
will be unstable for a time period; the Lock Detector is responsible for detecting this instability.
The itu_656_decoder block extracts YCrCb (4:4:4) video signals from the 4:2:2 data source sent
from the TV Decoder. It also generates a 13.5 MHz pixel clock (YPixel Clock) with blanking signals
indicating the valid period of data output. Because the video signal from the TV Decoder is
interlaced, we need to perform de-interlacing on the data source. We used the Dual Port Line Buffer
block and Hsyncx2 block to perform the de-interlacing operation where the pixel clock is changed
55
DE2 User Manual
to 27 MHz from 13.5 MHz and the Hsync is changed to 31.4 kHz from 15.7 kHz. Internally, the
Dual Port Line Buffer uses a 1 Kbyte long dual port SRAM to double the YCrCb data amount (Y x 2,
Cr x 2, Cb x 2 signals in the block diagram).
Finally, the YCrCb2RGB block converts the YCrCbx2 data into RGB output. The VGA Timing
Generator block generates standard VGA sync signals VGA_HS and VGA_VS to enable the display
on a VGA monitor.
56
DE2 User Manual
• Connect the audio output of the DVD player to the line-in port of the DE2 board and
connect a speaker to the line-out port. If the audio output jacks from the DVD player are of
RCA type, then an adaptor will be needed to convert to the mini-stereo plug supported on
the DE2 board; this is the same type of plug supported on most computers
• Load the bit stream into FPGA. Press KEY0 on the DE2 board to reset the circuit
This demonstration uses the device port of the Philips ISP1362 chip and the Nios II processor to
implement a USB mouse movement detector. We also implemented a video frame buffer with a
VGA controller to perform the real-time image storage and display. Figure 5.3 shows the block
diagram of the circuit, which allows the user to draw lines on the VGA display screen using the
USB mouse. The VGA Controller block is integrated into the Altera Avalon bus so that it can be
controlled by the Nios II processor.
Once the program running on the Nios II processor is started, it will detect the existence of the USB
mouse connected to DE2 board. Once the mouse is moved, the Nios II processor is able to keep
track of the movement and record it in a frame buffer memory. The VGA Controller will overlap the
57
DE2 User Manual
data stored in the frame buffer with a default image pattern and display the overlapped image on the
VGA display.
• Connect a USB Mouse to the USB Host Connector (type A) of the DE2 board
• Connect the VGA output of the DE2 board to a VGA monitor (both LCD and CRT type of
monitors should work)
• Load the bit stream into FPGA
• Run the Nios II and choose DE2_NIOS_HOST_MOUSE_VGA as the workspace. Click on
the Compile and Run button
• You should now be able to observe a blue background with an Altera logo on the VGA
display
• Move the USB mouse and observe the corresponding movements of the cursor on the screen
• Left-click mouse to draw white dots/lines and right-click the mouse to draw blue dots/lines
on the screen.
58
DE2 User Manual
After connecting the DE2 board to a USB port on the host computer, a software program has to be
executed on the Nios II processor to initialize the Philips ISP1362 chip. Once the software program
is successfully executed, the host computer will identify the new device in its USB device list and
ask for the associated driver; the device will be identified as a Philips PDIUSBD12 SMART
Evaluation Board. After completion of the driver installation on the host computer, the next step is
to run a software program on the host computer called ISP1362DcUsb.exe; this program
communicates with the DE2 board.
In the ISP1362DcUsb program, clicking on the Add button in the window panel of the software
causes the host computer to send a particular USB packet to the DE2 board; the packet will be
received by the Nios II processor and will increment the value of a hardware counter. The value of
the counter is displayed on one of the board’s 7-segment displays, and also on the green LEDs. If
the user clicks on the Clear button in the window panel of the software driver, the host computer
sends a different USB packet to the board, which causes the Nios II processor to clear the hardware
counter to zero.
59
DE2 User Manual
60
DE2 User Manual
For this demonstration the sample rate is set to 48 kHz. Pressing the pushbutton KEY0 reconfigures
the gain of the audio CODEC via the I2C bus, cycling through one of the ten predefined gains
(volume levels) provided by the device.
61
DE2 User Manual
On the transmitting side, the Nios II processor sends 64-byte packets every 0.5 seconds to the
DM9000A. After receiving the packet, the DM9000A appends a four-byte checksum to the packet
and sends it to the Ethernet port.
On the receiving side, the DM9000A checks every packet received to see if the destination MAC
address in the packet is identical to the MAC address of the DE2 board. If the packet received does
have the same MAC address or is a broadcast packet, the DM9000A will accept the packet and send
an interrupt to the Nios II processor. The processor will then display the packet contents in the Nios
II IDE console window.
Figure 5.9. Packet sending and receiving using the Nios II processor.
63
DE2 User Manual
In this demonstration we show how to implement an SD Card Music Player on the DE2 board, in
which the music files are stored in an SD card and the board can play the music files via its
CD-quality audio DAC circuits. We use the Nios II processor to read the music data stored in the
SD Card and use the Wolfson WM8731 audio CODEC to play the music.
The audio CODEC is configured in the slave mode, where external circuitry must provide the
ADC/DAC serial bit clock (BCK) and left/right channel clock (LRCK) to the audio CODEC. As
shown in Figure 5.11, we provide an Audio DAC Controller to achieve the clock generation and the
data flow control. The Audio DAC Controller is integrated into the Avalon bus architecture, so that
the Nios II processor can control the application.
64
DE2 User Manual
During operation the Nios II processor will check if the FIFO memory of the Audio DAC Controller
becomes full. If the FIFO is not full, the processor will read a 512-byte sector and send the data to
the FIFO of the Audio DAC Controller via the Avalon bus. The Audio DAC Controller uses a 48
kHz sample rate to send the data and clock signals to the audio CODEC. The design also mixes the
data from microphone-in with line-in for the Karaoke-style effects.
65
DE2 User Manual
Copyright © 2005 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.
This document is being provided on an “as-is” basis and as an accommodation and therefore all
warranties, representations or guarantees of any kind (whether express, implied or statutory)
including, without limitation, warranties of merchantability, non-infringement, or fitness for a
particular purpose, are specifically disclaimed.
66