1 |
2 |
dimamali |
|
2 |
|
|
This leon3 design is tailored to the Altera NiosII Cyclone III
|
3 |
|
|
Embedded Evaluation Kit, with 16-bit DDR SDRAM and 1 Mbyte of SSRAM.
|
4 |
|
|
The kit consists of a Cyclone III FPGA starter board and the LCD
|
5 |
|
|
Multimedia Daughter Card.
|
6 |
|
|
|
7 |
|
|
0. Introduction
|
8 |
|
|
---------------
|
9 |
|
|
|
10 |
|
|
The leon3 design can be synthesized with quartus or synplify,
|
11 |
|
|
and can reach 60 - 70 MHz depending on configuration and synthesis
|
12 |
|
|
options. Use 'make quartus' or 'make quartus-synp' to run the
|
13 |
|
|
complete flow. To program the FPGA in batch mode, use
|
14 |
|
|
'make quartus-prog-fpga' or
|
15 |
|
|
'make quartus-prog-fpga-ref (reference config).
|
16 |
|
|
|
17 |
|
|
This template design does not require modification of the logic in the
|
18 |
|
|
daughter card CPLD. The CPLD is assumed to have its default configuration.
|
19 |
|
|
|
20 |
|
|
The daughter card documentation has the following notice to avoid
|
21 |
|
|
bus contention:
|
22 |
|
|
|
23 |
|
|
"There are two LVDS termination resistors on the Cyclone III FPGA
|
24 |
|
|
Starter Board, R3 and R4. R3 connects HC_RX_CLK and HC_TD_27MHZ;
|
25 |
|
|
R4 connects HC_ADC_PENIRQ_n and HC_TX_CLK."
|
26 |
|
|
|
27 |
|
|
When using Disable Setting
|
28 |
|
|
Video decoder Ethernet PHY HC_ETH_RESET_N to 0
|
29 |
|
|
Touch panel Ethernet PHY HC_ETH_RESET_N to 0
|
30 |
|
|
Ethernet PHY Video decoder HC_TD_RESET to 0 and do not
|
31 |
|
|
use the touch panel function
|
32 |
|
|
when the ethernet PHY is
|
33 |
|
|
enabled.
|
34 |
|
|
|
35 |
|
|
In the template design, HC_TD_RESET is always driven to '0'.
|
36 |
|
|
The user is responsible for not using the touch panel at
|
37 |
|
|
the same time as the Ethernet PHY is in use.
|
38 |
|
|
|
39 |
|
|
1. Unsupported peripherals / Further development
|
40 |
|
|
------------------------------------------------
|
41 |
|
|
|
42 |
|
|
The video decoder and audio decoder are not used.
|
43 |
|
|
|
44 |
|
|
2. System
|
45 |
|
|
---------
|
46 |
|
|
|
47 |
|
|
The output from grmon should look something like this:
|
48 |
|
|
|
49 |
|
|
grmon -altjtag -jtagdevice 1 -ramrws 1 -normw
|
50 |
|
|
|
51 |
|
|
GRMON LEON debug monitor v1.1.30
|
52 |
|
|
|
53 |
|
|
Copyright (C) 2004-2008 Gaisler Research - all rights reserved.
|
54 |
|
|
For latest updates, go to http://www.gaisler.com/
|
55 |
|
|
Comments or bug-reports to support@gaisler.com
|
56 |
|
|
|
57 |
|
|
using Altera JTAG cable
|
58 |
|
|
Selected cable 1 - USB-Blaster [USB 1-1.1]
|
59 |
|
|
JTAG chain:
|
60 |
|
|
@1: EP3C25 (0x020F30DD)
|
61 |
|
|
|
62 |
|
|
GRLIB build version: 3050
|
63 |
|
|
|
64 |
|
|
initialising ................
|
65 |
|
|
detected frequency: 50 MHz
|
66 |
|
|
|
67 |
|
|
Component Vendor
|
68 |
|
|
LEON3 SPARC V8 Processor Gaisler Research
|
69 |
|
|
AHB Debug JTAG TAP Gaisler Research
|
70 |
|
|
SVGA frame buffer Gaisler Research
|
71 |
|
|
GR Ethernet MAC Gaisler Research
|
72 |
|
|
LEON2 Memory Controller European Space Agency
|
73 |
|
|
AHB/APB Bridge Gaisler Research
|
74 |
|
|
LEON3 Debug Support Unit Gaisler Research
|
75 |
|
|
DDR266 Controller Gaisler Research
|
76 |
|
|
Generic APB UART Gaisler Research
|
77 |
|
|
Multi-processor Interrupt Ctrl Gaisler Research
|
78 |
|
|
Modular Timer Unit Gaisler Research
|
79 |
|
|
General purpose I/O port Gaisler Research
|
80 |
|
|
Keyboard PS/2 interface Gaisler Research
|
81 |
|
|
AMBA Wrapper for OC I2C-master Gaisler Research
|
82 |
|
|
SPI Controller Gaisler Research
|
83 |
|
|
SPI Controller Gaisler Research
|
84 |
|
|
|
85 |
|
|
Use command 'info sys' to print a detailed report of attached cores
|
86 |
|
|
|
87 |
|
|
grlib> inf sys
|
88 |
|
|
00.01:003 Gaisler Research LEON3 SPARC V8 Processor (ver 0x0)
|
89 |
|
|
ahb master 0
|
90 |
|
|
01.01:01c Gaisler Research AHB Debug JTAG TAP (ver 0x0)
|
91 |
|
|
ahb master 1
|
92 |
|
|
02.01:063 Gaisler Research SVGA frame buffer (ver 0x0)
|
93 |
|
|
ahb master 2
|
94 |
|
|
apb: 80000b00 - 80000c00
|
95 |
|
|
clk0: 33.20 MHz
|
96 |
|
|
03.01:01d Gaisler Research GR Ethernet MAC (ver 0x0)
|
97 |
|
|
ahb master 3, irq 10
|
98 |
|
|
apb: 80000a00 - 80000b00
|
99 |
|
|
edcl ip 192.168.0.57, buffer 2 kbyte
|
100 |
|
|
00.04:00f European Space Agency LEON2 Memory Controller (ver 0x1)
|
101 |
|
|
ahb: 00000000 - 20000000
|
102 |
|
|
ahb: 20000000 - 40000000
|
103 |
|
|
ahb: a0000000 - b0000000
|
104 |
|
|
apb: 80000000 - 80000100
|
105 |
|
|
16-bit prom @ 0x00000000
|
106 |
|
|
32-bit static ram: 1 * 1024 kbyte @ 0xa0000000
|
107 |
|
|
01.01:006 Gaisler Research AHB/APB Bridge (ver 0x0)
|
108 |
|
|
ahb: 80000000 - 80100000
|
109 |
|
|
02.01:004 Gaisler Research LEON3 Debug Support Unit (ver 0x1)
|
110 |
|
|
ahb: 90000000 - a0000000
|
111 |
|
|
AHB trace 128 lines, stack pointer 0xa00ffff0
|
112 |
|
|
CPU#0 win 8, hwbp 2, itrace 128, V8 mul/div, lddel 1
|
113 |
|
|
icache 2 * 8 kbyte, 32 byte/line lru
|
114 |
|
|
dcache 2 * 4 kbyte, 16 byte/line lru
|
115 |
|
|
03.01:025 Gaisler Research DDR266 Controller (ver 0x0)
|
116 |
|
|
ahb: 40000000 - 50000000
|
117 |
|
|
ahb: fff00100 - fff00200
|
118 |
|
|
16-bit DDR : 1 * 32 Mbyte @ 0x40000000
|
119 |
|
|
100 MHz, col 9, ref 7.8 us
|
120 |
|
|
01.01:00c Gaisler Research Generic APB UART (ver 0x1)
|
121 |
|
|
irq 2
|
122 |
|
|
apb: 80000100 - 80000200
|
123 |
|
|
baud rate 38343
|
124 |
|
|
02.01:00d Gaisler Research Multi-processor Interrupt Ctrl (ver 0x3)
|
125 |
|
|
apb: 80000200 - 80000300
|
126 |
|
|
03.01:011 Gaisler Research Modular Timer Unit (ver 0x0)
|
127 |
|
|
irq 8
|
128 |
|
|
apb: 80000300 - 80000400
|
129 |
|
|
8-bit scaler, 2 * 32-bit timers, divisor 50
|
130 |
|
|
05.01:01a Gaisler Research General purpose I/O port (ver 0x0)
|
131 |
|
|
apb: 80000500 - 80000600
|
132 |
|
|
06.01:060 Gaisler Research Keyboard PS/2 interface (ver 0x1)
|
133 |
|
|
irq 6
|
134 |
|
|
apb: 80000600 - 80000700
|
135 |
|
|
08.01:028 Gaisler Research AMBA Wrapper for OC I2C-master (ver 0x0)
|
136 |
|
|
irq 11
|
137 |
|
|
apb: 80000800 - 80000900
|
138 |
|
|
09.01:02d Gaisler Research SPI Controller (ver 0x1)
|
139 |
|
|
irq 9
|
140 |
|
|
apb: 80000900 - 80000a00
|
141 |
|
|
FIFO depth: 4, 1 slave select signals
|
142 |
|
|
Controller index for use in GRMON: 1
|
143 |
|
|
0c.01:02d Gaisler Research SPI Controller (ver 0x1)
|
144 |
|
|
irq 12
|
145 |
|
|
apb: 80000c00 - 80000d00
|
146 |
|
|
FIFO depth: 4, 2 slave select signals
|
147 |
|
|
Controller index for use in GRMON: 2
|
148 |
|
|
grlib>
|
149 |
|
|
|
150 |
|
|
3. DDR interface
|
151 |
|
|
----------------
|
152 |
|
|
|
153 |
|
|
The DDR interface is supported and runs at 100 MHz.
|
154 |
|
|
The read data clock phase shift should be set to 90' (rskew = 2500).
|
155 |
|
|
|
156 |
|
|
4. SSRAM interface
|
157 |
|
|
------------------
|
158 |
|
|
|
159 |
|
|
The SSRAM can be accessed using the standard LEON2 MCTRL core.
|
160 |
|
|
One read waitstate is needed, start grmon with :
|
161 |
|
|
|
162 |
|
|
grmon -altjtag -jtagdevice 1 -ramrws 1 -normw
|
163 |
|
|
|
164 |
|
|
5. Flash memory
|
165 |
|
|
---------------
|
166 |
|
|
|
167 |
|
|
The 16-bit flash memory can be accessed and programmed by grmon,
|
168 |
|
|
if the SSRAM is working. The output from the 'flash' command is
|
169 |
|
|
listed below:
|
170 |
|
|
|
171 |
|
|
grlib> fla
|
172 |
|
|
|
173 |
|
|
Intel-style 16-bit flash on D[31:16]
|
174 |
|
|
|
175 |
|
|
Manuf. Intel
|
176 |
|
|
Device 0x881B
|
177 |
|
|
|
178 |
|
|
Device ID 70a6ffff00684403
|
179 |
|
|
User ID ffffffffffffffff
|
180 |
|
|
|
181 |
|
|
|
182 |
|
|
1 x 16 Mbyte = 16 Mbyte total @ 0x00000000
|
183 |
|
|
|
184 |
|
|
|
185 |
|
|
CFI info
|
186 |
|
|
flash family : 1
|
187 |
|
|
flash size : 128 Mbit
|
188 |
|
|
erase regions : 2
|
189 |
|
|
erase blocks : 131
|
190 |
|
|
write buffer : 64 bytes
|
191 |
|
|
region 0 : 4 blocks of 32 Kbytes
|
192 |
|
|
region 1 : 127 blocks of 128 Kbytes
|
193 |
|
|
|
194 |
|
|
|
195 |
|
|
5.1 How to program the flash prom with a FPGA programming file
|
196 |
|
|
--------------------------------------------------------------
|
197 |
|
|
|
198 |
|
|
There are two ways of programming the Flash memory. One using
|
199 |
|
|
Altera's Parallel Flash Loader and one using GRMON.
|
200 |
|
|
|
201 |
|
|
Programming the Flash using Altera's Parallel Flash Loader:
|
202 |
|
|
|
203 |
|
|
1. Start Quartus II and select File -> Convert Programming Files
|
204 |
|
|
|
205 |
|
|
2. Make the following settings:
|
206 |
|
|
|
207 |
|
|
Programming File Type: Programmer Object file (.pof)
|
208 |
|
|
Mode: Active Parallel
|
209 |
|
|
Configuration device: CFI_128MB
|
210 |
|
|
|
211 |
|
|
3. Select "Configuration Master" under "Input files to convert" and click
|
212 |
|
|
"Add file"
|
213 |
|
|
|
214 |
|
|
4. Select the leon3mp.sof file and click OK
|
215 |
|
|
|
216 |
|
|
5. Select "SOF data" and click "Properties"
|
217 |
|
|
|
218 |
|
|
6. Change the following properties:
|
219 |
|
|
|
220 |
|
|
Address mode for selected pages: Start
|
221 |
|
|
Start address: 0x020000
|
222 |
|
|
|
223 |
|
|
7. Generate the programmer object file by clicking "Generate"
|
224 |
|
|
|
225 |
|
|
8. Start the Quartus II programmer
|
226 |
|
|
|
227 |
|
|
9. Click "Auto Detect"
|
228 |
|
|
|
229 |
|
|
10. Right-click on the detected EP3C25 device and select "Attach Flash Device"
|
230 |
|
|
|
231 |
|
|
11. Select Flash Memory, CFI_128MB and click "OK"
|
232 |
|
|
|
233 |
|
|
12. Right click on the added CFI_128MB Flash device and select "Change File"
|
234 |
|
|
|
235 |
|
|
13. Select the .pof file that was generated in step 7 and click "OK".
|
236 |
|
|
|
237 |
|
|
14. Check the "Program/Configure" box for the added file under the Flash
|
238 |
|
|
device. Checking this box will change the Device File to "Factory
|
239 |
|
|
default PFL image"
|
240 |
|
|
|
241 |
|
|
15. Click "Start"
|
242 |
|
|
|
243 |
|
|
16. When programming has successfully finished press "Reconfigure" on the
|
244 |
|
|
board to load the leon3mp design.
|
245 |
|
|
|
246 |
|
|
Programming the Flash with GRMON:
|
247 |
|
|
|
248 |
|
|
1. Create a hex file of the programming file with Quartus. Choose
|
249 |
|
|
"Active Parallel" as the Mode. This mode is available in Quartus II 7.2
|
250 |
|
|
|
251 |
|
|
2. Convert the Intel Hex file to srecord format. The hexfile needs to be byte
|
252 |
|
|
swapped. This can be done with a tool from the SRecord package which can be
|
253 |
|
|
downloaded from http://srecord.sourceforge.net/. Issue the command:
|
254 |
|
|
|
255 |
|
|
srec_cat output_file.hexout -Intel -byteswap > fpga.srec
|
256 |
|
|
|
257 |
|
|
If the resulting fpga.srec file does not have the correct offset, the
|
258 |
|
|
offset may have to be given as an argument to srec_cat:
|
259 |
|
|
|
260 |
|
|
srec_cat output_file.hexout -Intel -byteswap -offset 0x20000 > fpga.srec
|
261 |
|
|
|
262 |
|
|
To see that the data has the correct offset, issue the command:
|
263 |
|
|
|
264 |
|
|
srec_info fpga.srec
|
265 |
|
|
|
266 |
|
|
The "Data:" area should start at 020000.
|
267 |
|
|
|
268 |
|
|
3. Program the flash memory using grmon:
|
269 |
|
|
|
270 |
|
|
flash unlock all
|
271 |
|
|
flash erase 0x20000 0x100000
|
272 |
|
|
flash load fpga.srec
|
273 |
|
|
|
274 |
|
|
The programming is slow, and will take at approximately 30 minutes with a JTAG
|
275 |
|
|
connection. The ethernet debug link is significantly faster.
|
276 |
|
|
|
277 |
|
|
6. SPI SD Card interface
|
278 |
|
|
----------------
|
279 |
|
|
|
280 |
|
|
The design instantiates a SPICTRL core which is connected to the SD card slot.
|
281 |
|
|
The user may deselect the SPI controller (SPICTRL) and enable the SPI memory
|
282 |
|
|
controller instead. SPIMCTRL allows reading SD cards without additonal software
|
283 |
|
|
support. The design will not synthesize if both cores are enabled.
|
284 |
|
|
|
285 |
|
|
Suitable configuration values for SPIMCTRL are; SD Card = 1, Clock divisor = 2,
|
286 |
|
|
Alt. clock divisor = 7. Note that the SPIMCTRL core will insert a large amount
|
287 |
|
|
of wait states on the system bus if AMBA SPLIT support is not enabled.
|
288 |
|
|
|
289 |
|
|
7. Ethernet interface
|
290 |
|
|
---------------------
|
291 |
|
|
|
292 |
|
|
The design can be configured to instantiate a GRETH. Note that if the
|
293 |
|
|
LCD touch panel interface is enabled the GRETH is not instantiated
|
294 |
|
|
even if it is selected in xconfig. See the note about bus contention
|
295 |
|
|
in section 0. Introduction of this file.
|
296 |
|
|
|
297 |
|
|
|
298 |
|
|
8. I2C interface
|
299 |
|
|
----------------
|
300 |
|
|
|
301 |
|
|
The design instantiates an I2C-master that is connected to the daughter
|
302 |
|
|
card EEPROM. The daughter card uses uni-directional I2C clock lines
|
303 |
|
|
and this prevents slaves from stretching the master clock.
|
304 |
|
|
|
305 |
|
|
grlib> i2c read 0x50 0 16
|
306 |
|
|
|
307 |
|
|
00: 10 10 00 07
|
308 |
|
|
04: ed 08 07 6d
|
309 |
|
|
08: 0f 6a 0f 09
|
310 |
|
|
0c: 00 84 00 94
|
311 |
|
|
|
312 |
|
|
9. LCD support
|
313 |
|
|
---------------
|
314 |
|
|
|
315 |
|
|
Two cores must be instantiated to fully support all the functionality
|
316 |
|
|
of the LCD touch panel. For video display an SVGACTRL core is
|
317 |
|
|
instantiated. The 3-wire interface and panel ADC is interfaced with
|
318 |
|
|
an instantiation of a SPICTRL core. The designer can configure the
|
319 |
|
|
design to exclude any of these cores.
|
320 |
|
|
|
321 |
|
|
The 3-wire serial interface and the touch panel ADC are wired to
|
322 |
|
|
share the same clock. The touch panel slave select signal is wired
|
323 |
|
|
to the first slave select signal of the SPICTRL core. The three wire
|
324 |
|
|
enable signal is wired to the second slave select signal.
|
325 |
|
|
|
326 |
|
|
The ADC busy and interrupt signals are connected to GPIO 3 and 4,
|
327 |
|
|
respectively, and can be accessed via the GRGPIO core.
|
328 |
|
|
|
329 |
|
|
10. VGA support
|
330 |
|
|
---------------
|
331 |
|
|
|
332 |
|
|
The designer can enable a SVGACTRL core to drive the VGA DAC.
|
333 |
|
|
|
334 |
|
|
|
335 |
|
|
11. Loading and starting an OS from GRMON
|
336 |
|
|
-----------------------------------------
|
337 |
|
|
|
338 |
|
|
Before loading an OS with GRMON it may be necessary to adjust
|
339 |
|
|
the stack pointer. This can be done by supplying the flag
|
340 |
|
|
|
341 |
|
|
-stack 0x41ffff00
|
342 |
|
|
|
343 |
|
|
or by using the GRMON command
|
344 |
|
|
|
345 |
|
|
stack 0x41ffff00
|
346 |
|
|
|
347 |
|
|
after a connection has been made to the board.
|
348 |
|
|
|