An 371
An 371
Reference Design
Altera Corporation 1
AN-371-1.0 Preliminary
Automotive Graphics System Reference Design
Design
Hardware
Cyclone Device
Nios II
Processor
Rendering
Hardware
PIO
LEDs & Switches
Avalon Avalon Modules
VGA
Video Bus
Camera
Input Fabric LCD Lancelot
Controller VGA Video
Controller
Flash
SDRAM
Memory
One additional global clock input is used as the input clock from the
camera module.
2 Altera Corporation
Preliminary
Reference Design Hardware
Color Avalon
Bars Register
Slave
26-MHz
4:2:2
Video Video Input Color
RGB FIFO
& FIFO Clipping Space
Buffer
Buffer Converter
Line Avalon
FIFO
Buffers & X-Scaling DMA
Buffer
Y-Scaling Master To SDRAM
Frame Buffer
f For more details on the Avalon video input module see AN373: Avalon
Video Input Module.
LCD Controller
The Avalon LCD controller module provides a flexible video display
solution for driving LCDs with the following features:
Altera Corporation 3
Preliminary
Automotive Graphics System Reference Design
■ Three drawing layers—8 bit palette, RGB666 + 6 bit pixel alpha, layer
alpha
■ Picture-in picture
Nios II Avalon
Processor Register
Slave
Timing
Generator
Avalon
DMA
Master
To LCD
Avalon
DMA
Master
Avalon
DMA Palette
Master
Avalon
DMA Palette
Master
f For more details on the Avalon LCD controller, see AN372: Avalon LCD
Controller. For more information on the Avalon Bus, see the Avalon Bus
Specification Reference Manual. For more information on SOPC Builder,
see the SOPC Builder User Guide and AN 333: Developing Peripherals for
SOPC Builder.
Nios II Processor
The Nios II processor is generated using Altera’s SOPC Builder tool. A
variety of configurations are possible including data and instruction
caches of varying size.
4 Altera Corporation
Preliminary
Software Concepts
Flash Memory
Flash memory stores the FPGA image, reference design software, and
images to be displayed by the LCD controller.
Images for display are stored in the zip file system created in the Nios II
integrated design environment (IDE).
SDRAM
At power up, the reference design software is copied from flash memory
to SDRAM, where it is executed.
The SDRAM also holds the frame buffers for the video input and LCD
controller modules.
PIO Modules
Three PIO modules interface to LEDs, 7-segment LEDs, and switches on
the Nios development board, Cyclone edition.
Hardware-Accelerated 2D Rendering
The optional rendering hardware supports acceleration of 2D rendering
by providing hardware rendering for filled rectangles. If the hardware is
included, the software detects its presence through the system definition
generated by SOPC Builder. If the hardware is present, there is a
#define for the base address, which can be tested for. The software uses
hardware rendering for the following purposes:
Altera Corporation 5
Preliminary
Automotive Graphics System Reference Design
The frame buffer memory for these layers must be allocated with two
bytes per pixel, e.g., a 640 × 480 display requires a frame buffer of 614,400
bytes.
Frame buffer memory for these layers must be allocated with one byte per
pixel, e.g., a 640 × 480 display requires a frame buffer of 307,200 bytes.
Interrupts
One interrupt is available from the Avalon video input module at the end
of each captured video frame.
Another interrupt is available from the LCD controller at the end of each
displayed frame.
The two interrupts allow updating of video input and LCD controller
registers during frame blanking periods, to ensure flicker-free display of
video and drawn objects.
6 Altera Corporation
Preliminary
Software Concepts
Video Frame
Input Buffer 1 Invalid
Frame
Buffer 2
Frame LCD
Buffer 3 Controller
Example B
Valid
Frame
Buffer 1
Video Frame
Input Buffer 2
Frame LCD
Buffer 3 Controller
When the video input interrupts at the end of a frame, software must
determine if the next frame buffer is free for use or is still being used by
the LCD controller for display. If the next frame buffer is in use, the video
input must re-use the buffer it just wrote for the next video frame (i.e., a
video frame is lost). This situation occurs when the video frame rate is
greater than the LCD frame rate.
When the LCD controller interrupts at the end of a frame, software must
determine if the next frame buffer is available for display or is still being
written by the video input. If the next frame buffer is still being written,
Altera Corporation 7
Preliminary
Automotive Graphics System Reference Design
the LCD controller must re-use the buffer it just displayed for the next
frame (i.e., a video frame is displayed twice). This situation occurs when
the video frame rate is less than the LCD frame rate.
Control registers for the LCD controller may only be changed during the
LCD controller frame blanking period and with the associated LCD
controller layer disabled.
Input Frame
YCLIPS
Start Pixel
Clipped Region
YCLIPE
End Pixel
XCLIPS XCLIPE
Start Pixel End Pixel
1 Ensure that the LCD controller is set up to display the same size
image as that generated from the video input by clipping and
resizing.
Image Display
Images, other than video input, may be displayed by either loading them
into a frame buffer from a zip file system in the flash memory or by
having the processor render the image into a frame buffer.
8 Altera Corporation
Preliminary
Software Concepts
■ Line draw
■ Polygon draw
■ Polygon fill
■ Circle draw
■ Circle fill
■ Text
Picture in Picture
The picture-in-picture feature, available on display layers 1 to 4, allows an
image in a small frame buffer to be displayed anywhere on the screen.
The advantage over using a full screen sized frame buffer with
transparent borders is the use of less frame buffer memory bandwidth for
the associated layer. Figure 6 shows the picture-in-picture control
registers.
Display Frame
WIN_Lx_V_START
Start Pixel
480
Picture-In-Picture Region
WIN_Lx_V_STOP
End Pixel
640
Altera Corporation 9
Preliminary
Automotive Graphics System Reference Design
Cursor Display
A hardware cursor can be implemented by dedicating one display layer
to the cursor and using the picture-in-picture feature to display a small
image (e.g., 32 × 32 pixels) as a cursor. The cursor position should be
updated during the LCD controller frame blanking period by updating
the picture-in-picture control registers (see “Updating the Control
Registers” on page 8).
Reference The reference design software is compiled and downloaded to the Nios
development board, Cyclone edition, using the Nios II IDE. The compiled
Design Software software may also be programmed into the on-board flash memory with
the FPGA image and display images using the flash programmer within
the IDE.
f For more details on the Nios II IDE see the Nios II Software Developers
Handbook.
You can run a number of different software modules; you select them by
closing one of the push-button switches while resetting the Nios
development board, Cyclone edition.
Performance Tests
The 2D rendering performance tests run if switch SW0 is closed during
reset. The rendering performance tests cycle through the following
actions and report results in terms of the number of objects drawn:
10 Altera Corporation
Preliminary
Reference Design Software
This demonstration shows a live video image from the camera module.
The video is overlaid with a trapezoid clear region in the center of the
screen surrounded by a partially opaque border. This overlay uses one
8-bit layer filled with a 50% alpha-value black. The trapezoidal region is
then rendered with a 0 alpha value (transparent). Two lines are drawn as
an aid to represent the direction of travel of a reversing vehicle. Figure 7
shows the reverse-parking aid overlay.
Altera Corporation 11
Preliminary
Automotive Graphics System Reference Design
32 bit
Contains the Quartus II projects.
altera_avalon_graphics_2d
Contains the rendering hardware files.
altera_avalon_i2c
Contains the i2c core files.
doc
Contains the i2c core documentation.
altera_avalon_lcd_controller
Contains the Avalon LCD controller files.
altera_avalon_video_in
Contains the Avalon video input module files .
software
Contains the Nios II project.
auto32
Contains the Nios II project files.
auto32_syslib
Contains the Nios II IDE files.
doc
Contains the documentation files.
images
Contains the demonstration images.
12 Altera Corporation
Preliminary
Getting Started
Altera Corporation 13
Preliminary
Automotive Graphics System Reference Design
4. Turn off the graphics_2d_0 check box, if you do not want hardware
rendering.
5. Click the System Generation tab and click Generate (see Figure 10).
14 Altera Corporation
Preliminary
Performance
3. Use the Nios II IDE to download the Nios II project to the Nios
development board, Cyclone edition.
a. Open
f For information on the software modules that you can run, see
“Reference Design Software” on page 10.
Performance The reference design fMAX is limited by the Avalon bus matrix because of
the large number of masters connected to the SDRAM controller. In an
EP1C20F400I7 device the fMAX is 75 MHz. The fMAX is higher for designs
using fewer layers in the LCD controller. A large improvement in fMAX
could be gained by designing the LCD controller with a single DMA
master servicing all layers, rather than the current scheme of one DMA
master per layer.
Utilization The complete reference design based upon a Nios II(s) processor with 512
byte instruction cache uses approximately 10,700 logic cells and 33 M4K
memory blocks when implemented in the Cyclone family.
The complete reference design based upon a Nios II(f) with 4 Kbyte
instruction cache and 4 Kbyte data cache uses approximately 11,300 logic
cells and 54 M4K memory blocks when implemented in the Cyclone
family.
Altera Corporation 15
Preliminary
Automotive Graphics System Reference Design
Copyright © 2004 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 re-
spective holders. Altera products are protected under numerous U.S. and foreign patents and pending
101 Innovation Drive applications, maskwork rights, and copyrights. Altera warrants performance of its semiconductor products
San Jose, CA 95134 to current specifications in accordance with Altera's standard warranty, but reserves the right to make chang-
(408) 544-7000 es 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
www.altera.com herein except as expressly agreed to in writing by Altera Corporation. Altera customers
Applications Hotline: are advised to obtain the latest version of device specifications before relying on any pub-
(800) 800-EPLD lished information and before placing orders for products or services.
Literature Services:
lit_req@altera.com
16 Altera Corporation
Preliminary