Академический Документы
Профессиональный Документы
Культура Документы
Version 1.00
CONTENTS
Chapter 1 DE0 Package.....................................................................................................................1 1.1 1.2 Package Contents .................................................................................................................1 The DE0 Board Assembly....................................................................................................2 Getting Help.........................................................................................................................2
Chapter 2 Altera DE0 Board.............................................................................................................4 2.1 2.2 2.3 Layout and Components ......................................................................................................4 Block Diagram of the DE0 Board........................................................................................5 Power-up the DE0 Board .....................................................................................................8
Chapter 3 DE0 Control Panel .........................................................................................................10 3.1 3.2 3.3 3.4 3.5 3.6 3.7 Control Panel Setup ...........................................................................................................10 Controlling the LEDs and 7-Segment Displays.................................................................12 Switches and Buttons .........................................................................................................14 SDRAM and Flash Controller and Programmer................................................................15 PS2 Device.........................................................................................................................16 SD CARD ..........................................................................................................................17 VGA ...................................................................................................................................18
Chapter 4 Using the DE0 Board .....................................................................................................20 4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8 4.9 4.10 4.11 Configuring the Cyclone III FPGA....................................................................................20 Using the LEDs and Switches............................................................................................23 Using the 7-segment Displays............................................................................................26 Clock Circuitry...................................................................................................................28 Using the LCD Module......................................................................................................29 Using the Expansion Header..............................................................................................31 Using VGA ........................................................................................................................34 RS-232 Serial Port .............................................................................................................37 PS/2 Serial Port ..................................................................................................................38 SD Card Socket..................................................................................................................39 Using SDRAM and Flash ..................................................................................................39
Chapter 5 Examples of Advanced Demonstrations ......................................................................44 5.1 5.2 5.3 DE0 Factory Configuration................................................................................................44 SD Card..............................................................................................................................45 VGA Color Pattern Demonstration....................................................................................49
iii
Chapter 1
DE0 Package
The DE0 package contains all the components needed to use the DE0 board in conjunction with a computer that runs the Microsoft Windows software.
The DE0 package includes: The DE0 board USB Cable for FPGA programming and control DE0 System CD containing : o Alteras Quartus II Web Edition and the Nios II Embedded Design Suit Evaluation Edition software o the DE0 documentation and supporting materials, including the User Manual, the Control Panel utility, reference designs and demonstrations, device datasheets, tutorials, and a set of laboratory exercises Clear plastic cover for the board 7.5 DC wall-mount power supply
Getting Help Here are the addresses where you can get help if you encounter problems: Altera Corporation 101 Innovation Drive
2
San Jose, California, 95134 USA Email: university@altera.com Terasic Technologies No. 356, Sec. 1, Fusing E. Rd. Jhubei City, HsinChu County, Taiwan, 302 Email: support@terasic.com Web: DE0.terasic.com
Chapter 2
SDRAM (8 Mbytes)
FLASH (4 Mbytes)
Figure 2-1 The DE0 board. The DE0 board has many features that allow the user to implement a wide range of designed circuits, from simple circuits to various multimedia projects. The following hardware is provided on the DE0 board:
4
Altera Cyclone III 3C16 FPGA device Altera Serial Configuration device EPCS4 USB Blaster (on board) for programming and user API control; both JTAG and Active Serial (AS) programming modes are supported 8-Mbyte SDRAM 4-Mbyte Flash memory SD Card socket 3 pushbutton switches 10 toggle switches 10 green user LEDs 50-MHz oscillator for clock sources VGA DAC (4-bit resistor network) with VGA-out connector RS-232 transceiver PS/2 mouse/keyboard connector Two 40-pin Expansion Headers
SD Card Socket
RS-232 Transceiver
USB Blaster
Figure 2-2 Block diagram of the DE0 board. Following is more detailed information about the blocks in Figure 2-2: Cyclone IIII 3C16 FPGA 15,408 LEs 56 M9K Embedded Memory Blocks 504K total RAM bits 56 embedded multipliers 4 PLLs 346 user I/O pins FineLine BGA 484-pin package Built-in USB Blaster circuit On-board USB Blaster for programming and user API (Application programming interface) control Using the Altera EPM240 CPLD SDRAM One 8-Mbyte Single Data Rate Synchronous Dynamic RAM memory chip Supports 16-bits data bus
6
Flash memory 4-Mbyte NOR Flash memory Support Byte (8-bits)/Word (16-bits) mode SD card socket Provides both SPI and SD 1-bit mod SD Card access Pushbutton switches 3 pushbutton switches Normally high; generates one active-low pulse when the switch is pressed Slide switches 10 Slide switches A switch causes logic 0 when in the DOWN position and logic 1 when in the UP position General User Interfaces 10 Green color LEDs (Active high) 4 seven-segment displays (Active low) 16x2 LCD Interface (Not include LCD module) Clock inputs 50-MHz oscillator VGA output Uses a 4-bit resistor-network DAC With 15-pin high-density D-sub connector Supports up to 1280x1024 at 60-Hz refresh rate Serial ports One RS-232 port (Without DB-9 serial connector) One PS/2 port (Can be used through a PS/2 Y Cable to allow you to connect a keyboard and mouse to one port) Two 40-pin expansion headers 72 Cyclone III I/O pins, as well as 8 power and ground lines, are brought out to two 40-pin expansion connectors 40-pin header is designed to accept a standard 40-pin ribbon cable used for IDE hard drives
7
2. 3. 4. 5.
At this point you should observe the following: All user LEDs are flashing All 7-segment displays are cycling through the numbers 0 to F The VGA monitor displays the image shown in Figure 2-3.
Chapter 3
10
Figure 3-2. The error message of the DE0 Control Panel. The concept of the DE0 Control Panel is illustrated in Figure 3-3. The Control Codes that perform the control functions is implemented in the FPGA board. 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 codes. It handles all requests and performs data transfers between the computer and the DE0 board.
11
FPGA/ SOPC
System Interconnect Fabric
SEG7 Controller SDRAM Controller PS2 Controller VGA Controller PIO Controller
7-SEG Display SDRAM PS2 Keyboard VGA LED/Button/ Switch/ Seg7/ SD- Card
NIOS II
JTAG
Flash Controller
Flash
Figure 3-3. The DE0 Control Panel concept. The DE0 Control Panel can be used to light up the LEDs, change the values displayed on 7-segment, monitor buttons/switches status, read/write the SDRAM and Flash Memory, read data from a PS/2 keyboard, output color pattern to LCD monitor via VGA connector, and read SD-CARD specification information. The feature of reading/writing a word or an entire file from/to the Flash Memory allows the user to develop multimedia application (Flash Picture Viewer) without worrying about how to build a Memory Programmer.
12
Figure 3-4. Controlling LEDs Choosing the 7-SEG tab leads to the window in Figure 3-5. In the tab sheet, directly use the Up-Down control and Dot Check box to specified desired patterns, the 7-SEG patterns on the board will be updated immediately.
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.
Figure 3-6. Monitoring switches and buttons. The ability to check the status of button and switch is not needed in typical design activities. However, it provides users a simple mechanism for verifying if the buttons and switches are functioning correctly. Thus, it can be used for troubleshooting purposes.
14
Figure 3-7. Accessing the SDRAM 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-7 depicts the result of writing the hexadecimal value 7eff into location 000000, 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 Memory 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.
15
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 8-bit values: 01, 23, 45, 67, 89, AB, CD, EF. 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 Memory box. 3. Press Load Memory 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. Users can use the similar way to access the Flash. Please note that users need to erase the flash before writing data to it.
16
3.6 SD CARD
The function is designed to read the identification and specification of the SD card. The 1-bit SD MODE is used to access the SD card. This function can be used to verify the functionality of SD-CARD Interface. Follow the steps below to exercise the SD card: 1. Choosing the SD-CARD tab leads to the window in Figure 3-9. 2. Insert a SD card to the DE0 board, then press the Read button to read the SD card. The SD cards identification and specification will be displayed in the control window.
17
3.7 VGA
DE0 control panel provides VGA pattern function that allows users to output color pattern to LCD/CRT monitor using the DE0 FPGA board. Please follow the steps below to generate the VGA pattern function: 1. 2. 3. 4. Choosing the VGA tab leads to the window in Figure 3-10. Plug a D-sub cable to the VGA connector of the DE0 board and LCD/CRT monitor. The LCD/CRT monitor will display the same color pattern on the control panel window. Click the drop down menu shown in Figure 3-10 where you can output the selected color individually.
18
19
Chapter 4
20
USB Blaster Circuit Quartus II Programmer MAX II EPM240 PROG/RUN JTAG UART JTAG Config Signals RUN
Connect the supplied USB cable to the USB Blaster port on the DE0 board (see Figure 2-1) Configure the JTAG programming circuit by setting the RUN/PROG switch (see Figure 4-4) to the PROG position. The EPCS4 chip can now be programmed by using the Quartus II Programmer module to select a configuration bit stream file with the .pof filename extension Once the programming operation is finished, set the RUN/PROG switch back to the RUN position and then reset the board by turning the power switch off and back on; this action causes the new configuration data in the EPCS4 device to be loaded into the FPGA chip.
USB Blaster Circuit PROG/RUN MAX II EPM240 PROG AS Mode Config Auto Power-on Config
In addition to its use for JTAG and AS programming, the USB Blaster port on the DE0 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.
23
Figure 4-5. Connections between the pushbutton and Cyclone III FPGA
Pushbutton depressed Before Debouncing Pushbutton released
D2
E4
E3
H7
J7
G5
G4
H6
H5
J6
Logic ``1``
SW9
SW8 SW7
Logic``0``
Figure 4-7 Connections between the toggle switches and Cyclone III FPGA
24
J1 J2 J3 H1 F2 E1 C1 C2 B2 B1
LEDG0 LEDG1 LEDG2 LEDG3 LEDG4 LEDG5 LEDG6 LEDG7 LEDG8 LEDG9
LEDG0
LEDG1
LEDG2
LEDG3
LEDG4
LEDG5
LEDG6
LEDG7
LEDG8
LEDG9
Figure 4-8 Connections between the LEDs and Cyclone III FPGA Table 4.1. Pin assignments for the slide switches
Signal Name SW[0] SW[1] SW[2] SW[3] SW[4] SW[5] SW[6] SW[7] SW[8] SW[9] FPGA Pin No. PIN_J6 PIN_H5 PIN_H6 PIN_G4 PIN_G5 PIN_J7 PIN_H7 PIN_E3 PIN_E4 PIN_D2 Description Slide Switch[0] Slide Switch[1] Slide Switch[2] Slide Switch[3] Slide Switch[4] Slide Switch[5] Slide Switch[6] Slide Switch[7] Slide Switch[8] Slide Switch[9]
25
HEX0
HEX0_D0 HEX0_D0 HEX0_D1 HEX0_D2 HEX0_D3 E11 F11 H12 H13
HEX0_D5 HEX0_D6
HEX0_D1
HEX0_D4
HEX0_D2
HEX0_D3
HEX0_DP
Figure 4-9 Connections between the 7-segment displays and Cyclone III FPGA
26
0 5 6 4 3 1
2 DP
27
Seven Segment Digit 3[0] Seven Segment Digit 3[1] Seven Segment Digit 3[2] Seven Segment Digit 3[3] Seven Segment Digit 3[4] Seven Segment Digit 3[5] Seven Segment Digit 3[6] Seven Segment Decimal Point 3
28
The LCD module has built-in fonts and can be used to display text by sending appropriate commands to the display controller, which is called HD44780. Detailed information for using the display is available in its datasheet, which can be found on the manufacturer's web site, and from the Datasheet/LCD folder on the DE0 System CD-ROM. A schematic diagram of the LCD module showing connections to the Cyclone III FPGA is given in Figure 4-13. The associated pin assignments appear in Table 4.7.
29
F21 D22 D21 C22 C21 B22 B21 D20 C20 E21 F22 E22 LCD_RW LCD_BLON LCD_DATA0 LCD_DATA1 LCD_DATA2 LCD_DATA3 LCD_DATA4 LCD_DATA6 LCD_DATA7 LCD_DATA5 LCD_RS LCD_EN
2 X 16 LCD Module
Figure 4-13 Connections between the LCD module and Cyclone III FPGA
30
Note that some LCD modules do not have backlight. Therefore the LCD_BLON signal should not be used in users design projects.
31
(GPIO 0) J4
[AB12] GPIO0_CLKIN0 [AA12] GPIO0_CLKIN1 [AA15] GPIO0_D2 [AA14] GPIO0_D4 [AB13] GPIO0_D6 5V [AB10] GPIO0_D8 [AB8] GPIO0_D10 [AB5] GPIO0_D12 [AB3] GPIO0_CLKOUT0 [AA3] GPIO0_CLKOUT1 [V14] GPIO0_D16 [Y13] GPIO0_D18 [U13] GPIO0_D20 3.3V [R10] GPIO0_D22 [Y10] GPIO0_D24 [T8] GPIO0_D26 [W7] GPIO0_D28 [V5] GPIO0_D30 1 3 5 7 9 2 4 6 8 10 GPIO0_D0 [AB16] GPIO0_D1 [AA16] GPIO0_D3 [AB15] GPIO0_D5 [AB14] GPIO0_D7 [AA13] GND GPIO0_D9 [AA10] GPIO0_D11 [AA8] GPIO0_D13 [AA5] GPIO0_D14 [AB4] GPIO0_D15 [AA4] GPIO0_D17 [U14] GPIO0_D19 [W13] GPIO0_D21 [V12] GND GPIO0_D23 [V11] GPIO0_D25 [W10] GPIO0_D27 [V8] GPIO0_D29 [W6] GPIO0_D31 [U7] [AB11] GPIO1_CLKIN0 [AA11] GPIO1_CLKIN1 [AA19] GPIO1_D2 [AB18] GPIO1_D4 [AA17] GPIO1_D6 5V [Y17] GPIO1_D8 [U15] GPIO1_D10 [W15] GPIO1_D12 [R16] GPIO1_CLKOUT0 [T16] GPIO1_CLKOUT1 [AA7] GPIO1_D16 [T14] GPIO1_D18 [U12] GPIO1_D20 3.3V [R11] GPIO1_D22 [U10] GPIO1_D24 [U9] GPIO1_D26 [Y7] GPIO1_D28 [V6] GPIO1_D30
(GPIO 1) J5
1 3 5 7 9 2 4 6 8 10 GPIO1_D0 [AA20] GPIO1_D1 [AB20] GPIO1_D3 [AB19] GPIO1_D5 [AA18] GPIO1_D7 [AB17] GND GPIO1_D9 [W17] GPIO1_D11 [T15] GPIO1_D13 [V15] GPIO1_D14 [AB9] GPIO1_D15 [AA9] GPIO1_D17 [AB7] GPIO1_D19 [R14] GPIO1_D21 [T12] GND GPIO1_D23 [R12] GPIO1_D25 [T10] GPIO1_D27 [T9] GPIO1_D29 [U8] GPIO1_D31 [V7]
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
Figure 4-14 I/O distribution of the expansion headers Table 4.8. Pin assignments for the expansion headers.
Signal Name GPIO0_D[0] GPIO0_D[1] GPIO0_D[2] GPIO0_D[3] GPIO0_D[4] GPIO0_D[5] GPIO0_D[6] GPIO0_D[7] GPIO0_D[8] GPIO0_D[9] GPIO0_D[10] GPIO0_D[11] GPIO0_D[12] GPIO0_D[13] GPIO0_D[14] GPIO0_D[15] FPGA Pin No. PIN_AB16 PIN_AA16 PIN_AA15 PIN_AB15 PIN_AA14 PIN_AB14 PIN_AB13 PIN_AA13 PIN_AB10 PIN_AA10 PIN_AB8 PIN_AA8 PIN_AB5 PIN_AA5 PIN_AB4 PIN_AA4 Description GPIO Connection 0 IO[0] GPIO Connection 0 IO[1] GPIO Connection 0 IO[2] GPIO Connection 0 IO[3] GPIO Connection 0 IO[4] GPIO Connection 0 IO[5] GPIO Connection 0 IO[6] GPIO Connection 0 IO[7] GPIO Connection 0 IO[8] GPIO Connection 0 IO[9] GPIO Connection 0 IO[10] GPIO Connection 0 IO[11] GPIO Connection 0 IO[12] GPIO Connection 0 IO[13] GPIO Connection 0 IO[14] GPIO Connection 0 IO[15]
32
GPIO0_D[16] GPIO0_D[17] GPIO0_D[18] GPIO0_D[19] GPIO0_D[20] GPIO0_D[21] GPIO0_D[22] GPIO0_D[23] GPIO0_D[24] GPIO0_D[25] GPIO0_D[26] GPIO0_D[27] GPIO0_D[28] GPIO0_D[29] GPIO0_D[30] GPIO0_D[31] GPIO0_CLKIN[0] GPIO0_CLKIN[1] GPIO0_CLKOUT[0] GPIO0_CLKOUT[1] GPIO1_D[0] GPIO1_D[1] GPIO1_D[2] GPIO1_D[3] GPIO1_D[4] GPIO1_D[5] GPIO1_D[6] GPIO1_D[7] GPIO1_D[8] GPIO1_D[9] GPIO1_D[10] GPIO1_D[11] GPIO1_D[12] GPIO1_D[13] GPIO1_D[14] GPIO1_D[15] GPIO1_D[16]
PIN_V14 PIN_U14 PIN_Y13 PIN_W13 PIN_U13 PIN_V12 PIN_R10 PIN_V11 PIN_Y10 PIN_W10 PIN_T8 PIN_V8 PIN_W7 PIN_W6 PIN_V5 PIN_U7 PIN_AB12 PIN_AA12 PIN_AB3 PIN_AA3 PIN_AA20 PIN_AB20 PIN_AA19 PIN_AB19 PIN_AB18 PIN_AA18 PIN_AA17 PIN_AB17 PIN_Y17 PIN_W17 PIN_U15 PIN_T15 PIN_W15 PIN_V15 PIN_AB9 PIN_AA9 PIN_AA7
GPIO Connection 0 IO[16] GPIO Connection 0 IO[17] GPIO Connection 0 IO[18] GPIO Connection 0 IO[19] GPIO Connection 0 IO[20] GPIO Connection 0 IO[21] GPIO Connection 0 IO[22] GPIO Connection 0 IO[23] GPIO Connection 0 IO[24] GPIO Connection 0 IO[25] GPIO Connection 0 IO[26] GPIO Connection 0 IO[27] GPIO Connection 0 IO[28] GPIO Connection 0 IO[29] GPIO Connection 0 IO[30] GPIO Connection 0 IO[31] GPIO Connection 0 PLL In GPIO Connection 0 PLL In GPIO Connection 0 PLL Out GPIO Connection 0 PLL Out GPIO Connection 1 IO[0] GPIO Connection 1 IO[1] GPIO Connection 1 IO[2] GPIO Connection 1 IO[3] GPIO Connection 1 IO[4] GPIO Connection 1 IO[5] GPIO Connection 1 IO[6] GPIO Connection 1 IO[7] GPIO Connection 1 IO[8] GPIO Connection 1 IO[9] GPIO Connection 1 IO[10] GPIO Connection 1 IO[11] GPIO Connection 1 IO[12] GPIO Connection 1 IO[13] GPIO Connection 1 IO[14] GPIO Connection 1 IO[15] GPIO Connection 1 IO[16]
33
GPIO1_D[17] GPIO1_D[18] GPIO1_D[19] GPIO1_D[20] GPIO1_D[21] GPIO1_D[22] GPIO1_D[23] GPIO1_D[24] GPIO1_D[25] GPIO1_D[26] GPIO1_D[27] GPIO1_D[28] GPIO1_D[29] GPIO1_D[30] GPIO1_D[31] GPIO1_CLKIN[0] GPIO1_CLKIN[1] GPIO1_CLKOUT[0] GPIO1_CLKOUT[1]
PIN_AB7 PIN_T14 PIN_R14 PIN_U12 PIN_T12 PIN_R11 PIN_R12 PIN_U10 PIN_T10 PIN_U9 PIN_T9 PIN_Y7 PIN_U8 PIN_V6 PIN_V7 PIN_AB11 PIN_AA11 PIN_R16 PIN_T16
GPIO Connection 1 IO[17] GPIO Connection 1 IO[18] GPIO Connection 1 IO[19] GPIO Connection 1 IO[20] GPIO Connection 1 IO[21] GPIO Connection 1 IO[22] GPIO Connection 1 IO[23] GPIO Connection 1 IO[24] GPIO Connection 1 IO[25] GPIO Connection 1 IO[26] GPIO Connection 1 IO[27] GPIO Connection 1 IO[28] GPIO Connection 1 IO[29] GPIO Connection 1 IO[30] GPIO Connection 1 IO[31] GPIO Connection 1 PLL In GPIO Connection 1 PLL In GPIO Connection 1 PLL Out GPIO Connection 1 PLL Out
34
VGA_R
VGA_G VGA_B
10 5 15
L22 L21
VGA_VS VGA_HS
Figure 4-15 Connections between VGA circuit and Cyclone III FPGA 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-16 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-16, 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). Table 4.9 and Table 4.10 show different resolutions of 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, or in the Datasheet/VGA DAC folder on the DE0 System CD-ROM. The pin assignments between the Cyclone III FPGA and the VGA connector are listed in Table 4.11. An example of code that drives a VGA display is described in Sections 5.3.
35
Figure 4-16 VGA horizontal timing specification Table 4.9. VGA horizontal timing specification
VGA mode Configuration VGA(60Hz) Resolution(HxV) 640x480 a(us) 3.8 Horizontal Timing Spec b(us) 1.9 c(us) 25.4 d(us) 0.6 Pixel clock(Mhz) 25 (640/c)
640x480
36
U3
U22 V22 U21 V21 UART_RXD UART_RTS UART_TXD UART_CTS 12 9 11 T1IN 10 T2IN
ADM3202
R1IN R2IN T1OUT T2OUT 13 8 14 7 RXD RTS TXD CTS GND1
R1OUT R2OUT
Figure 4-18 Connections between the ADM232 (RS-232) chip and Cyclone III FPGA
37
J3
8 5 2 1
6 3
R22 P21
PS2_MSDAT PS2_KBDAT
Figure 4-19 Connections between PS/2 and Cyclone III FPGA Table 4.13. PS/2 pin assignments
Signal Name PS2_KBCLK PS2_KBDAT PS2_MSCLK PS2_MSDAT FPGA Pin No. PIN_P22 PIN_P21 PIN_R21 PIN_R22 Description PS/2 Clock PS/2 Data PS/2 Clock (reserved for second PS/2 device) PS/2 Data(reserved for second PS/2 device)
38
4 5 6 7 8
Y21
SD_CLK
AA22
SD_DATA0
W20
SD_WPn
11
Figure 4-20 Connections between SD Card and Cyclone III FPGA Table 4.14. SD Card pin assignments
Signal Name SD_CLK SD_CMD SD_DAT0 SD_DAT3 SD_WP_N FPGA Pin No. PIN_Y21 PIN_Y22 PIN_AA22 PIN_W21 PIN_W20 Description SD Clock SD Command bidirectional signal SD Data bidirectional signal SD Data bidirectional signal SD Card write protect signal (active low)
39
SDRAM
See Table 4.15 See Table 4.15 B5 A4 E7 B8 D6 G8 F7 G7 E5 E6 DRAM_ADDR[12:0] DRAM_DQ[15:0] DRAM_BA_0 DRAM_BA_1 DRAM_LDQM DRAM_UDQM DRAM_WE_N DRAM_CAS_N DRAM_RAS_N DRAM_CS_N DRAM_CLK DRAM_CKE A[12:0] D[15:0] BA0 BA1 LDQM UDQM nWE nCAS nRAS nCS CLK CKE
U1
FLASH
See Table 4.16 See Table 4.16 Y2 P4 R1 T3 M7 G8 R6 AA1 FL_ADDR[12:0] FL_DQ[15:0] FL_DQ15_AM1 FL_WE_N FL_RST_N FL_WP_N FL_RY FL_CE_N FL_OE_N FL_BYTE_N A[21:0] DQ[14:0] DQ15/A-1 WE# RESET# WP#ACC RY/BY# CE# OE# BYTE#
U2
40
41
SDRAM Clock Enable SDRAM Clock SDRAM Write Enable SDRAM Chip Select
42
FL_DQ[7] FL_DQ[8] FL_DQ[9] FL_DQ[10] FL_DQ[11] FL_DQ[12] FL_DQ[13] FL_DQ[14] FL_DQ15_AM1 FL_BYTE_N FL_CE_N FL_OE_N FL_RST_N FL_RY FL_WE_N FL_WP_N
PIN_Y1 PIN_T5 PIN_T7 PIN_T4 PIN_U2 PIN_V1 PIN_V4 PIN_W2 PIN_Y2 PIN_AA1 PIN_N8 PIN_R6 PIN_R1 PIN_M7 PIN_P4 PIN_T3
FLASH Data[7] FLASH Data[8] FLASH Data[9] FLASH Data[10] FLASH Data[11] FLASH Data[12] FLASH Data[13] FLASH Data[14] FLASH Data[15] FLASH Byte/Word Mode Configuration FLASH Chip Enable FLASH Output Enable FLASH Reset LASH Ready/Busy output FLASH Write Enable FLASH Write Protect /Programming Acceleration
43
Chapter 5
The Verilog source code for this demonstration is provided in the DE0_Default folder, which also includes the necessary files for the corresponding Quartus II project. The top-level Verilog file, called DE0_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 III FPGA.
5.2 SD Card
Many applications use a large external storage device, such as a SD card or CF card, to store data. The DE0 board provides the hardware and software needed for SD card access. In this demonstration we will show how to browse files stored in the root directory of a SD card and how to read the file contents of a specific file. The size of the SD card should be less or equal to 2GB. Also, it is required to be formatted as FAT (FAT16 or FAT 32) File System in advance. Long file name is supported in this demonstration. Figure 5-1 shows the hardware system block diagram of this demonstration. The system requires a 50 MHz clock provided from the board. Four PIO pins are connected to the SD card socket. They are SD_CLK, SD_CMD, SD_DAT and SD_WP_N. The three pins SD_CLK, SD_CMD and SD_DAT are used to implement SD 1-bit Mode protocol for accessing the SD card content. The SD 1-bit protocol and FAT File System function are all implemented by NIOS II software. The software is stored in the on-board SDRAM memory.
Figure 5-1 Block Diagram of the SD Card Demonstration Figure 5-2 shows the software stack of this demonstration. The NIOS PIO block provides basic IO functions to access hardware directly. The functions are provided from NIOS II system and the
45
function prototype is defined in the header file <io.h>. The SD-CARD block implements SD 1-bit mode protocol for communication with the SD card. The FAT File System block implements reading function for FAT16 and FAT 32 file system. Long filename is supported. By calling the exported FAT functions, users can browse files under the root directory of the SD card. Furthermore, users can open a specified file and read the contents of the file. The main block implements main control of this demonstration. When the program is executed, it detects whether a SD card is inserted. If a SD card is found, it will check whether the SD card is formatted as FAT file system. If a FAT file system is found, it searches all files in the root directory of the FAT file system and displays their names in the nios2-terminal. If a text file named test.txt is found, it will dump the file contents. If it successfully recognizes the FAT file system, it will turn on the all of green LED. On the other hand, it will turn off all of the green LED if it fails to parse the FAT file system. Half number of the green LED will be turn on if there is no SD card found in the SD Card socket. If users press BUTTON2 of the DE0 board, the program will perform above process again.
46
Demonstration Setup
Make sure Quartus II and NIOS II are installed on your PC. Change Switch to PROG Mode to RUN mode in DE0 board. Power on the DE0 board. Connect USB Blaster to the DE0 board and install USB Blaster driver if necessary. Execute the demo batch file test.bat under the batch file folder, DE0_NIOS_SDCARD\demo_batch. After NIOS II program is downloaded and executed successfully, a prompt message will be displayed in nios2-terminal Copy test files to the root directory of the SD Card. Insert the SD card into the SD Card socket of DE0, as shown in Figure 5-3. Press Button2 of the DE0 board to start reading SD Card. The program will display SD Card information, as shown in Figure 5-4.
47
48
SW0
50
Figure 5-6. The setup for the VGA color pattern demonstration
51
Pattern 1
Pattern 2
SW0
SW0
Figure 5-7. The output color pattern type for the demonstration
52
Chapter 6
Appendix
6.1 Revision History
Version V1.0 V1.1 V1.2 V1.3 V1.4 V1.5 V1.6 Change Log Initial Version (Preliminary) GPIO Pin Assignments Corrected SDRAM pin description Corrected Figure 4.10 Clock Circuitry pin assignment Corrected SD card demonstration setup corrected Add debounced circuit description Modify section 4.2 PROG. SW description
53