FPGA 设计实例 基于 FPGA 的图形液晶显示面板应用. Graphic LCD panel. FPGAs make great video controllers and can easily control graphic LCD panels.

Similar documents
Design and Implementation of an AHB VGA Peripheral

EECS150 - Digital Design Lecture 13 - Project Description, Part 3 of? Project Overview

Lab # 9 VGA Controller

TSIU03: Lab 3 - VGA. Petter Källström, Mario Garrido. September 10, 2018

VGA Controller. Leif Andersen, Daniel Blakemore, Jon Parker University of Utah December 19, VGA Controller Components

Digital Blocks Semiconductor IP

Using the Renesas Graphics API to Create a User Interface

Video. Updated fir31.filtered on website Fall 2008 Lecture 12

Display Technology.! Images stolen from various locations on the web... Cathode Ray Tube

Display Technology. Cathode Ray Tube. Images stolen from various locations on the web...

IMS B007 A transputer based graphics board

USER MANUAL Nokia 5110 LCD

L14 - Video. L14: Spring 2005 Introductory Digital Systems Laboratory

Design of VGA Controller using VHDL for LCD Display using FPGA

Video Graphics Array (VGA)

An Efficient SOC approach to Design CRT controller on CPLD s

TV Character Generator

VGA Port. Chapter 5. Pin 5 Pin 10. Pin 1. Pin 6. Pin 11. Pin 15. DB15 VGA Connector (front view) DB15 Connector. Red (R12) Green (T12) Blue (R11)

Lecture 14: Computer Peripherals

Hitachi Europe Ltd. ISSUE : app084/1.0 APPLICATION NOTE DATE : 28/04/99

FPGA Laboratory Assignment 4. Due Date: 06/11/2012

Display Technology. Images stolen from various locations on the web... Cathode Ray Tube

Design and Implementation of Timer, GPIO, and 7-segment Peripherals

Spartan-II Development System

AD9884A Evaluation Kit Documentation

VGA 8-bit VGA Controller

Lab 3: VGA Bouncing Ball I

Configuring the Élan SC300 Device s Internal CGA Controller for a Specific LCD Panel

A * Rockwell. R6500 Microcomputer System DATA SHEET CRT CONTROLLER (CRTC) r- r- 31 O PART NUMBER R FEATURES DESCRIPTION O 30-4 O O

Video Display Unit (VDU)

VID_OVERLAY. Digital Video Overlay Module Rev Key Design Features. Block Diagram. Applications. Pin-out Description

HD66840/HD LVIC/LVIC-II (LCD Video Interface Controller) Description. Features

Configuring and using the DCU2 on the MPC5606S MCU

SPI Serial Communication and Nokia 5110 LCD Screen

Oscilloscopes, logic analyzers ScopeLogicDAQ

LAX_x Logic Analyzer

7inch Resistive Touch LCD User Manual

Lancelot. VGA video controller for the Altera Nios II processor. V4.0. December 16th, 2005

Week 5 Dr. David Ward Hybrid Embedded Systems

Part 1: Introduction to Computer Graphics

Digilent Nexys-3 Cellular RAM Controller Reference Design Overview

Display Technology. Images stolen from various locations on the web... Cathode Ray Tube

EDA385 Bomberman. Fredrik Ahlberg Adam Johansson Magnus Hultin

TOSHIBA CMOS DIGITAL INTEGRATED CIRCUIT SILICON MONOLITHIC T7779

Different Display Configurations on the i.mx31 WinCE PDK

Group 1. C.J. Silver Geoff Jean Will Petty Cody Baxley

A Fast Constant Coefficient Multiplier for the XC6200

LOCAL DECODING OF WALSH CODES TO REDUCE CDMA DESPREADING COMPUTATION. Matt Doherty Introductory Digital Systems Laboratory.

Design and Implementation of SOC VGA Controller Using Spartan-3E FPGA

Unit 3: Parallel I/O and Handshaking for LCD Control

Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science Introductory Digital Systems Laboratory

Video Output and Graphics Acceleration

C6845 CRT Controller Megafunction

Testing Results for a Video Poker System on a Chip

4.3inch 480x272 Touch LCD (B) User Manual

An FPGA Based Solution for Testing Legacy Video Displays

A CONTROL MECHANISM TO THE ANYWHERE PIXEL ROUTER

ECE 448 Lecture 10. VGA Display Part 1 VGA Synchronization

Lab Assignment 2 Simulation and Image Processing

IT T35 Digital system desigm y - ii /s - iii

ELEX 7660: Digital System Design Composite Video Encoder with SPI Interface. Matthew Knight, Cole Harkness

EECS150 - Digital Design Lecture 12 - Video Interfacing. Recap and Outline

Modeling Digital Systems with Verilog

Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science Introductory Digital Systems Laboratory

Read-only memory (ROM) Digital logic: ALUs Sequential logic circuits. Don't cares. Bus

ECE532 Digital System Design Title: Stereoscopic Depth Detection Using Two Cameras. Final Design Report

LED Array Tutorial. This guide explains how to set up and operate the LED arrays that can be used for your. Internal Structure of LED Array

Chapter 7 Memory and Programmable Logic

Laboratory Exercise 4

2.13inch e-paper HAT (D) User Manual

Using the Siemens S65 Display

Chapter 7 Counters and Registers

Checkpoint 2 Video Interface

6.111 Project Proposal IMPLEMENTATION. Lyne Petse Szu-Po Wang Wenting Zheng

VGA Configuration Algorithm using VHDL

Block Diagram. dw*3 pixin (RGB) pixin_vsync pixin_hsync pixin_val pixin_rdy. clk_a. clk_b. h_s, h_bp, h_fp, h_disp, h_line

DATASHEET HMP8154, HMP8156A. Features. Ordering Information. Applications. NTSC/PAL Encoders. FN4343 Rev.5.00 Page 1 of 34.

Risk Risk Title Severity (1-10) Probability (0-100%) I FPGA Area II Timing III Input Distortion IV Synchronization 9 60

Sapera LT 8.0 Acquisition Parameters Reference Manual

Part 1: Introduction to computer graphics 1. Describe Each of the following: a. Computer Graphics. b. Computer Graphics API. c. CG s can be used in

VARIABLE FREQUENCY CLOCKING HARDWARE

VectorVGA Tempest User Manual

The BAT WAVE ANALYZER project

Revision: August 11, E Main Suite D Pullman, WA (509) Voice and Fax. 8 LEDs. Doc: page 1 of 9

DT3162. Ideal Applications Machine Vision Medical Imaging/Diagnostics Scientific Imaging

User's Manual of LED LIGHTING CONTROL SYSTEM (VC-500A/B) VISS LIGHTING (SHENZHEN) CO.,LTD.

CAPTURE CAPTURE. VERSiON 1.2. Specialists in Medical. Digital Imaging Solutions

980 Protocol Analyzer General Presentation. Quantum Data Inc Big Timber Road Elgin, IL USA Phone: (847)

TV Synchronism Generation with PIC Microcontroller

XC-77 (EIA), XC-77CE (CCIR)

3/5/2017. A Register Stores a Set of Bits. ECE 120: Introduction to Computing. Add an Input to Control Changing a Register s Bits

EE251: Thursday October 11

GUIX Synergy Port Framework Module Guide

21.1. Unit 21. Hardware Acceleration

fbas_enc: FBAS(CVBS) encoder for PAL and/or NTSC

Chapter 3 Unit Combinational

Final Project [Tic-Tac-Toe]

Tearing Effect with Solomon SSD1963 Display Controller

Sandia Project Document.doc

Real-Time Digital Oscilloscope Implementation in 90nm CMOS Technology FPGA

Transcription:

FPGA 设计实例 基于 FPGA 的图形液晶显示面板应用 Graphic LCD panel FPGAs make great video controllers and can easily control graphic LCD panels. This project is split in 4 parts: 1. Introduction 2. Video generator 3. Graphics 4. Text Here's a view of one LCD panel used for this project:

Graphic LCD panel - Introduction Graphic LCD panels use a digital interface and are easy to interface to FPGAs. The different interfaces Graphic LCD panels come in 2 flavors: 1. With a Video-like interface 2. With a CPU-peripheral-like interface Advantages 1. Video-like interface Low cost & widely available (used in notebook computers for example) Easy to control from an FPGA Freedom on what is displayed 2. CPU-peripheral-like interface Easy to attach to microcontrollers A frame-buffer memory is integrated

(frame-buffer/on-the-fly video/sprites/hardware mouse cursor... or any combination of these) to the panel Disadvantages Requires a video controller (FPGA or dedicated chip) Requires some external memory (for the frame-buffer, character generator,...) Higher cost & lower availability For frame-buffer applications only How it works Uses a video signal - with HSync (horizontal sync) and VSync (vertical sync) pulses Similar to a VGA signal, but with digital RGB video signals The panel appears like a memory (SRAM) to the microcontroller The CPU writes to the SRAM and the data appears on the screen This project uses "type-1" panels - since we use FPGAs here, that's the most appropriate. Graphic LCD panel - video generator Prior to be able to display anything on the panel, we need to generate video-sync signals (H-sync and V-sync). The LCD used for this project has the following characteristics: Monochrome, with a 480x320 resolution (about 150000 pixels). Synchronous interface, 4-bits data interface (4 pixels are entered for each clock). No off-screen period. With a 4-bits data input, we need 480/4=120 clocks horizontally. With 320 lines, a complete video frame takes 120x320=38400 clocks. The code looks like that: parameter ScreenWidth = 480; parameter ScreenHeight = 320;

reg [6:0] CounterX; // counts from 0 to 119 reg [8:0] CounterY; // counts from 0 to 319 wire CounterXmaxed = (CounterX==ScreenWidth/4-1); wire CounterYmaxed = (CounterY==ScreenHeight-1); always @(posedge clk) begin if(counterxmaxed) CounterX <= 0; else CounterX <= CounterX + 1; end always @(posedge clk) if(counterxmaxed) begin if(counterymaxed) CounterY <= 0; else CounterY <= CounterY + 1; end reg HSync, VSync; always @(posedge clk) begin HSync <= CounterXmaxed; VSync <= CounterYmaxed; end Now, let's provide data to be displayed - first some graphics, then some text. Graphic LCD panel - Graphics Let's investigate 3 ways to generate graphical video data.

Rasterized bitmaps The classical (and easy) way to display graphics on an LCD is to hold rasterized bitmap data into a RAM. We are going to use a blockram here (see here to learn what are blockrams). We display a small 128x32 pixels bitmap here (fits nicey into a 4Kbits blockram): // Use a blockram to hold the graphical data wire [7:0] BitmapData; blockram_8x512 RAM_bitmap(.clk(clk),.rd_adr({CounterY[4:0],CounterX[4:1]}),.data_out(Bit mapdata)); // Let's say we need 4 bits at a time wire [3:0] LCD_Bitmap4 = CounterX[0]? BitmapData[3:0] : BitmapData[7:4]; // Display the data into a chessboard pattern wire [3:0] LCD_BitmapChessboard = (CounterY[5] ^ CounterX[5])? 4'b000 : LCD_Bitmap4 ^ {4{CounterY[5]}}; Not shown above is how the RAM is written. The easiest is to treat it as a ROM (the RAM content is part of the FPGA configuration, and doesn't change while the FPGA is running). Here's a macro shot:

The drawback of rasterized bitmaps is that you require a large enough RAM to hold the state of each pixel of the bitmap. That's expensive using internal FPGA RAM, so external RAM is often used instead. Now, let's explore more original ways to create graphics. Curve y=f(x) Let's say we want to display an y=f(x) waveform, like a sine. That's surprisingly easy to do. We hold the "Y" values into a blockram and generate the picture line by line by reading the RAM and comparing the values against "CounterY" (the current line number). // We assume CounterX and CounterY are available: // CounterX is the pixel number of the current line // CounterY is the line number // We use a RAM to hold the "Y" values // Y=F(CounterX) wire [7:0] RAM_Y_value;

blockram_8x512 RAM_FXY(.clk(clk),.rd_adr(CounterX),.data_out(RAM_Y_value)); // check for equality between the "Y" values and "CounterY" reg grcpeq1; always @(posedge clk) grcpeq1 <= (RAM_Y_value==CounterY); reg grcpeq2; always @(posedge clk) grcpeq2 <= grcpeq1; // check for "greater-than" between the "Y" values and "CounterY" reg grcp1; always @(posedge clk) grcp1 <= (RAM_Y_value>CounterY); reg grcp2; always @(posedge clk) grcp2 <= grcp1; // display a pixel if equality, or if "CounterY" is between 2 successive "Y" values wire FXpix= grcpeq2 (grcp1 ^ grcp2); Here's the result using F(x)=cos(x*2*pi/480)*sin(x*2*pi/480*4):

Rotozoom A Rotozoom is an efficient method to display a bitmap with linear geometric distortions. In particular, that allows easy rotating and zooming of a picture. In the following implementation, we display a rotated chessboard pattern on the screen. reg [15:0] X0, Y0, X1, Y1; always @(posedge clk) if(vsync) begin X0 <= 0; Y0 <= 0; X1 <= 0; Y1 <= 0; end else if(hsync) begin X0 <= X1-100; Y0 <= Y1 + 400; X1 <= X1-100; Y1 <= Y1 + 400; end else begin X0 <= X0 + 400; Y0 <= Y0 + 100; end // Display a chessboard pattern by XOR'ing the MSB of X and Y counters // You could also display a rotozoomed bitmap by feeding X and Y to a bitmap in a RAM wire rotozoom_pix = X0[15] ^ Y0[15];

This is simplified because the increment values are fixed (400 and 100 above). You'd want to vary them in a real implementation. By varying the coefficients, you rotate and zoom the chessboard. Here's the result, mixed with the previous waveform: You can then mix that with some text... Graphic LCD panel - Text Let's try to display characters on our panel. This way, the panel can be used as a text terminal. Our 480x320 sample panel can be used as a 80 columns x 40 lines console (using 6x8 characters font) or 60 columns x 40 lines console (using 8x8 character font). We are going to use a "character generator" technique. Character generator

Let's assume the word "Hello" is somewhere on the screen. In ASCII, that uses 5 bytes (0x48, 0x65, 0x6C, 0x6C, 0x6F). Our simple character generator uses one RAM to hold the characters to display, and one ROM to hold the font. "Font ROM" contains the representation of each possible characters. Here're sample sets: Changing the content of the "Character RAM" makes characters appear on the panel. 8x8 font implementation On the panel, a 6x8 font looks somewhat nicer than a 8x8 font, but 8x8 is easier to implement, so that's what we try first. By using a 2Kbytes RAM for the "Character RAM", we can have 32 lines of 64 characters... so 5 bits to count the lines and 6 bits to count the columns. By keeping all the numbers a power of two, the implementation stays as simple as possible. Here's what we got:

We use 6 bits from CounterX, and 8 bits from CounterY (5 bits for the "Character RAM", plus 3 bits for the "Font ROM"). "Font ROM" uses a total of 11 bits. The design goes as follow: wire [7:0] CharacterRAM_dout; ram8x2048 CharacterRAM(.clk(clk),.rd_adr({CounterY[7:3],CounterX[6:1]}),.data_out(CharacterRAM_dout) ); wire [7:0] raster8; rom8x2048 FontROM(.clk(clk),.rd_adr({CharacterRAM_dout, CounterY[2:0]}),.data_out(raster8) ); wire [3:0] LCDdata = CounterX[0]? raster8[7:4] : raster8[3:0]; A few details: Because my LCD panel takes 4-pixels per clock, we need 2 clocks for 1 character width (1 character width=8 pixels). That's why "Character RAM" uses "CounterX[6:1]" instead of "CounterX[5:0]" above. In an FPGA, it makes sense that the "Font ROM" is actually a RAM. This way, the font can be loaded or changed at runtime. The mechanism to write the RAMs is not shown above.

Here's a shot of the LCD with an 8x8 font: 6x8 font implementation The 6x8 font allows for more characters to be displayed (and looks better on the panel too!). My particular panel width is 480 pixels, which translates conveniently into 80 columns. The 6x8 font is more complicated to handle than 8x8 because the font width (6) is not a power of 2. That means we don't display the same part of a character at each clock cycle anymore. With CounterX=0, we display the first 4 pixels of CHAR[0] With CounterX=1, we display the last 2 pixels of CHAR[0] and the first 2 pixels of CHAR[1] With CounterX=2, we display the last 4 pixels of CHAR[1] With CounterX=3, we display the first 4 pixels of CHAR[2] With CounterX=4, we display the last 2 pixels of CHAR[2] and the first 2 pixels of CHAR[3]... That is done using a simple case statement wire [3:0] charfont0, charfont1; always @(posedge clk) begin case(cnt_mod3) 2'b00: LCDdata <= charfont0;

2'b01: LCDdata <= {charfont0[3:2], charfont1[3:2]}; 2'b10: LCDdata <= {charfont1[3:2], charfont0[1:0]}; endcase end with a modulus-3 counter (it counts 0, 1, 2, 0, 1, 2, 0, 1,...) reg [1:0] cnt_mod3; always @(posedge clk) if(cnt_mod3==2) cnt_mod3 <= 0; else cnt_mod3 <= cnt_mod3 + 1; but we also need a character-counter for the "Character RAM" // character-counter (increments only twice every 3 clocks) reg [6:0] cnt_charbuf; always @(posedge clk) if(cnt_mod3!=1) cnt_charbuf <= cnt_charbuf + 1; wire [11:0] CharacterRAM_rdaddr = CounterY[8:3]*80 + cnt_charbuf; wire [7:0] CharacterRAM_dout; ram8x2048 CharacterRAM(.clk(clk),.rd_adr(CharacterRAM_rdaddr),.data_out(CharacterRAM_dout) ); and two "Font ROMs". // remember the previous character displayed reg [7:0] RAM_charbuf_dout_last; always @(posedge clk) CharacterRAM_dout_last <= CharacterRAM_dout; // because we need it when we display 2 half characters at once wire [10:0] readaddr0 = {CharacterRAM_dout, CounterY[2:0]}; wire [10:0] readaddr1 = {CharacterRAM_dout_last, CounterY[2:0]}; // The font ROMs are split in two blockrams, holding 4 pixels each // (half of the second ROM is not used, since we need only 6 pixels) rom4x2048 FontROM0(.clk(clk),.rd_adr(readaddr0),.data_out(charfont0));

rom4x2048 FontROM1(.clk(clk),.rd_adr(readaddr1),.data_out(charfont1)); Here's a shot of the LCD with an 6x8 font: Hardware cursor Let's implement a blinking cursor that can be placed on any character on the panel. First we use a video-frame counter to "time" the blinking. Using 6 bits, the cursor blinks every 64 frames. reg [5:0] cnt_cursorblink; always @(posedge clk) if(vsync & hsync) cnt_cursorblink <= cnt_cursorblink + 1; wire cursorblinkstate = cnt_cursorblink[5]; // cursor on for 32 frames, off for 32 frames Now let's assume the cursor address position is available in a "CursorAddress" register. // Do we have a cursor-character match? wire cursorblink_adrmatch = cursorblinkstate & (CharacterRAM_rdaddr==CursorAddress); // When we have a match, "invert" the character // First for charfont0 wire [3:0] charfont0_cursor = charfont0 ^ {4{cursorblink_adrmatch}};

// Next for charfont1 reg cursorblink_adrmatch_last; always @(posedge clk) cursorblink_adrmatch_last <= cursorblink_adrmatch; wire [3:0] charfont1_cursor = charfont1 ^ {4{cursorblink_adrmatch_last}}; Whoa, we can display graphics and text! All this is applicable to monochrome and color LCDs. Here's what happens when we get carried away on a color LCD... Your turn to experiment!