A Video Controller for an FPGA. Dual-Ported RAM

Similar documents
MAYD Ain t Yet Doom. Final Report

The On-Chip Peripheral Bus

Scorched Earf XESS. W4840 Embedded Systems Design Spring A Term Project Submitted In Partial Fulfillment Of

OPB General Purpose Input/Output (GPIO) (v3.01b)

Discontinued IP. OPB General Purpose Input/Output (GPIO) (v3.01b) Introduction. Features. LogiCORE Facts

Hardware Design with VHDL Design Example: BRAM ECE 443

Smasher Video Game Design

COLOR VIDEO IN SOFTWARE VHDL AND C FILES

OPB to PLBV46 Bridge (v1.01a)

CSEE Embedded Systems Design ObTrak Project Final Report

Discontinued IP. OPB Interrupt Controller (v1.00c) Introduction. Features. LogiCORE Facts

CDA 4253 FGPA System Design Xilinx FPGA Memories. Hao Zheng Comp Sci & Eng USF

Discontinued IP. OPB Arbiter (v1.02e) Introduction. Features. LogiCORE Facts

Programmable Logic. Simple Programmable Logic Devices

Discontinued IP. OPB IIC Bus Interface (v1.01d) Introduction. Features. LogiCORE Facts

American Pool Video Game

Run Pac-man Game Based on 8086/8088 FPGA IP Core. Authors: Kevin Xie, Michael Ye, Winston Zhu Last update: 1 st, August, 2007

IP cores. V. Angelov

The Virtex FPGA and Introduction to design techniques

Discontinued IP. OPB Ethernet Lite Media Access Controller (v1.01b) Introduction. Features. LogiCORE Facts

Digital Design with SystemVerilog

Today. Comments about assignment Max 1/T (skew = 0) Max clock skew? Comments about assignment 3 ASICs and Programmable logic Others courses

CSCE 313: Embedded Systems. Final Project Notes. Instructor: Jason D. Bakos

EECS150 - Digital Design Lecture 16 - Memory

Summary. Introduction. Application Note: Virtex, Virtex-E, Spartan-IIE, Spartan-3, Virtex-II, Virtex-II Pro. XAPP152 (v2.1) September 17, 2003

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

EE178 Lecture Module 2. Eric Crabill SJSU / Xilinx Fall 2007

INTRODUCTION TO VHDL ADVANCED COMPUTER ARCHITECTURES. Slides by: Pedro Tomás. Additional reading: - ARQUITECTURAS AVANÇADAS DE COMPUTADORES (AAC)

VHDL: Modeling RAM and Register Files. Textbook Chapters: 6.6.1, 8.7, 8.8, 9.5.2, 11.2

ENGG3380: Computer Organization and Design Lab4: Buses and Peripheral Devices

OPB Universal Serial Bus 2.0 Device (v1.00a)

COVER SHEET: Total: Regrade Info: 2 (6 points) 3 (8 points) 4 (10 points) 8 (12 points) 6 (6 points) 7 (6 points) 9 (30 points) 10 (4 points)

Review: Timing. EECS Components and Design Techniques for Digital Systems. Lec 13 Storage: Regs, SRAM, ROM. Outline.

SHIM: A Language for Hardware/Software Integration

Problem Set 10 Solutions

Altera s Avalon Communication Fabric

EECS150 - Digital Design Lecture 16 Memory 1

Field Programmable Gate Array

Discontinued IP. Slices. LUTs. FFs. Block RAMs. Instantiation

Spartan-6 Libraries Guide for HDL Designs. UG615 (v 14.1) April 24, 2012

Altera s Avalon Communication Fabric

Basic FPGA Architecture Xilinx, Inc. All Rights Reserved

LogiCORE IP Block Memory Generator v6.1

Discontinued IP. Slices LUTs FFs

Discontinued IP. Block RAMs

Sign here to give permission for your test to be returned in class, where others might see your score:

EE 459/500 HDL Based Digital Design with Programmable Logic. Lecture 15 Memories

Lecture 12 VHDL Synthesis

Spartan-6 FPGA Block RAM Resources

FPGAs in a Nutshell - Introduction to Embedded Systems-

In our case Dr. Johnson is setting the best practices

Example 15: Moving Sprites with Flash Background

ECE 545 Lecture 12. FPGA Resources. George Mason University

ECE 448 Lecture 13. FPGA Memories. George Mason University

FPGA.

FPGA Lecture for LUPO and GTO Vol , 31 August (revised 2013, 19 November) H. Baba

Sequential Logic - Module 5

OPB PCI Full Bridge (v1.02a)

Control and Datapath 8

Sign here to give permission for your test to be returned in class, where others might see your score:

ECE 699: Lecture 9. Programmable Logic Memories

LogiCORE IP Block Memory Generator v7.1

BADGE BitSim s Accelerated Display Graphics Engine IP block for ASIC & FPGA, is an advanced graphic controller.

OPB Double Data Rate (DDR) Synchronous DRAM (SDRAM) Controller

Latch Based Design (1A) Young Won Lim 2/18/15

Channel FIFO (CFIFO) (v1.00a)

ECE 545: Lecture 11. Programmable Logic Memories

ECE 545: Lecture 11. Programmable Logic Memories. Recommended reading. Memory Types. Memory Types. Memory Types specific to Xilinx FPGAs

XSV Flash Programming and Virtex Configuration

DIGITAL LOGIC DESIGN VHDL Coding for FPGAs

Constructing VHDL Models with CSA

ECE 545 Lecture 12. FPGA Embedded Resources 12/8/11. Resources. Recommended reading. Use of Embedded FPGA Resources in SHA-3 Candidates

USB Media Philip Li (pcl2007) Pamela Lee (pyl2001) Yanjie Ma (ym2009) Neeraj Bahati (nrb2001) Alex Kuo (aek2001) Michael Chuen (mpc2002)

ECE 545 Lecture 6. Behavioral Modeling of Sequential-Circuit Building Blocks. George Mason University

FPGA briefing Part II FPGA development DMW: FPGA development DMW:

VHDL Testbench. Test Bench Syntax. VHDL Testbench Tutorial 1. Contents

COVER SHEET: Total: Regrade Info: 5 (5 points) 2 (8 points) 6 (10 points) 7b (13 points) 7c (13 points) 7d (13 points)

Summary of FPGA & VHDL

Discontinued IP. OPB External Memory Controller (OPB EMC) (2.00a) Introduction. Features. LogiCORE Facts

EEL 4712 Digital Design Test 2 Spring Semester 2008

FPGA RAM (C1) Young Won Lim 5/13/16

CprE 583 Reconfigurable Computing

Logic Implementation on a Xilinx FPGA using VHDL WWU Linux platform assumed. rev 10/25/16

Timing in synchronous systems

[VARIABLE declaration] BEGIN. sequential statements

Digital Integrated Circuits

Midterm Exam Thursday, October 24, :00--2:15PM (75 minutes)

Codec. WM8731 Audio Codec

Simulation with ModelSim Altera from Quartus II

Hello, World: A Simple Application for the Field Programmable Port Extender (FPX)

XiNES Design Document. XiNES is a Nintendo Entertainment System simulator coded in pure VHDL

Sequential Statement

VHDL in 1h. Martin Schöberl

Topics. Midterm Finish Chapter 7

Schedule. ECE U530 Digital Hardware Synthesis. Rest of Semester. Midterm Question 1a

IJREAT International Journal of Research in Engineering & Advanced Technology, Volume 1, Issue 5, Oct-Nov, 2013 ISSN:

Lecture 11 Memories in Xilinx FPGAs

ECE 448 Lecture 4. Sequential-Circuit Building Blocks. Mixing Description Styles

Virtex-II Architecture

Platform Flash In-System Programmable Configuration PROMs

Transcription:

A Video Controller for an FPGA On-Chip A Video Controller Prof. Stephen A. Edwards sedwards@cs.columbia.edu NCTU, Summer 2005 Project specification: Flexible video controller Driven by C from the Microblaze Not interesting otherwise Only uses on-chip Specifically, we won t use the S or SD. Makes it easier to use it in projects that use other peripherals. Assume we have an XC2S300E-6PQ208C FPGA (slightly different than what is on the Digilent board). From the Xilinx Spartan-IIE 1.8V FPGA Family data sheet, we find Device CLB CLBs Distributed Block array Bits Bits XC2S300E 32 48 1536 98 304 64K Distributed uses the LUTs and is awkward. Block is dual-ported. We have at most 8K bytes. A Video Controller p. 1/5 A Video Controller p. 2/5 A Video Controller p. 3/5 Block Configuration Dual-Ported Memory Usage From the Xilinx Spartan-IIE 1.8V FPGA Family: Functional Description datasheet, Block s are 4096 bits each. The XC2S300E has 16 such blocks. Many different configurations. We like the byte-wide one: 512 8. The dual-ported nature is very convenient. Two truly independent input/output ports that do not have to be synchronized. We will use one port for the video controller, the other for the processor. VGA is 640 480 = 307 200 pixels Even at one bit per pixel, this requires 307 200 1024 = 300K bits = 37.5K bytes Too much for on-chip ; we only have 8K max. A Video Controller p. 4/57 A Video Controller p. 5/57 A Video Controller p. 6/57 Memory Usage Font Memory Map How about a text-only display? 80 24 is typical. 640 80 = 8 pixels horizontally/character 480 24 = 20 pixels vertically/character A bit too vertical. 8 16 is more typical. 480 16 = 30 lines 80 30 = 2400 characters Over 2K (2048). 2400 = 2048 + 352 Will fit in 2.5K = 2560 How about the font? For 8 16 characters, the 96 basic ASCII characters take 16 96 = 1536 = 1.5K Memory is our most valuable resource. We ve decided to allocate it as follows: 2.5K for a 80 30 character array 1.5K for a 96-character 8 16 font That is half (4K) of the 8K on-chip memory. Reasonable. Also nice because we can use standard IBM console fonts.

Timing It is reasonable to assume the shift register, AND gate, and controller will operate at full speed. But how fast is the? In the Spartan-IIE 1.5V FPGA Family: DC and Switching Characteristics datasheet: Symbol Description Min Max T BCKO CLK to DOUT 0.6ns 3.5ns T BACK /T BCKA Setup/hold on ADDR 1.1ns/0 - T BPWH Clock pulse width high 1.5ns - T BPWL Clock pulse width low 1.5ns - A Video Controller p. 12/5 Horizontal Timing HTOTAL Video FRONT_PORCH BACK_PORCH HACTIVE For a 25.175 MHz pixel clock, 96 pixels BACK_PORCH 48 HACTIVE 640 FRONT_PORCH 16 HTOTAL 800 A Video Controller p. 15/5 Vertical Timing VTOTAL Video VSYNC FRONT_PORCH BACK_PORCH VACTIVE VSYNC VSYNC 2 lines BACK_PORCH 33 VACTIVE 480 FRONT_PORCH 10 Microarchitecture Controller Char. 2.5K Dout VSYNC Din Addr BLANK Font 1.5K Video Shift Register A Video Controller p. 11/5 Pixel-Level Timing Clk i 1 i i+1 CharAddr LoadChar i 1 i i+1 CharData FontLoad i 1 i i+1 PixelData 3 2 1 0 7 6 5 4 3 2 1 0 7 Bit A Video Controller p. 14/5 End-of-line detail Clk 772 773 774 775 776 777 778 779 780 781 782 783 784 Hcount 78 79 Column LoadChar 78 79 CharData FontLoad 78 79 PixelData HBLANK 628 629 630 631 632 633 634 635 636 637 638 639 Pixel Aside That 640 480 exactly fits an 80 30 8 16 font is no accident. Historically, Standard Resolution Font Display CGA (1981) 640 200 8 8 80 25 EGA (1984) 640 350 8 14 80 25 EGA (1984) 640 350 8 8 80 43 VGA (1987) 640 400 8 16 80 25 VGA (1987) 640 400 8 14 80 28 VGA (1987) 640 400 8 8 80 50 VGA (1987) 640 480 8 16 80 30 VGA (1987) 640 480 8 14 80 34 VGA (1987) 640 480 8 8 80 60 A Video Controller p. 10/5 Timing Maximum clock frequency: 1 / 3ns = 333 MHz Highest data rate: 1 / 3.5ns = 285 MHz VGA dot clock is 25 MHz The is much, much faster than we need. We can assume data from the appears quickly after the clock. A Video Controller p. 13/5 Start-of-line Detail Clk 140 141 142 143 144 145 146 147 148 149 150 151 152 Hcount 0 1 Column LoadChar 0 1 CharData FontLoad 0 1 PixelData HBLANK 0 1 2 3 4 5 6 7 8 Pixel

Character Addresses Horizontal Signals Vertical Signals line character address, row 0 0,0 1,0 78,0 79,0 1 0,1 1,1 78,1 79,1 14 0,14 1,14 78,14 79,14 15 0,15 1,15 78,15 79,15 16 80,0 81,0 158,0 159,0 17 80,1 81,1 158,1 159,1 31 80,15 81,15 158,15 159,15 32 160,0 161,0 238,0 239,0 464 2320,0 2321,0 2398,0 2399,0 479 2320,15 2321,15 2398,15 2399,15 A Video Controller p. 19/5 Signal Description Pixel_Clock 25 MHz from system clock. Hcount[9:0] Horizontal position (0 799) VideoData Pixel data from shift register LoadNShift Shift register control. 143, 151, 775 FontData[7:0] Byte from font. FontLoad Load byte from font. 142, 150,, 774 FontAddr[3:0] Character row address (0 15) FontAddr[10:4] Character number (0 95) from char. LoadChar Load from char.. 141, 149,, 773 CharAddr[11:0] Character address: column plus row 80 Column[6:0] Column (0 79) = (Hcount 141) 8 HBLANK_N Horizontal blanking. Off 144 783 _N Horizontal Synchronization. 0 95 A Video Controller p. 20/5 Signal Description Vcount[9:0] Vertical position (0 524) Row[4:0] Row number (0 29) = (Vcount 35) 16 VBLANK_N Vertical blanking. Off lines 35 514 VSYNC_N Vertical Synchronization. Lines 0 and 1 A Video Controller p. 21/5 Interface to the B4_S8_S8 The video interface The OPB Interface From the Xilinx libraries guide: EN RST WE CLK ADDR DI DO Operation 0 - - - - - DO No-op 1 1 0 - - 0 Reset DO 1 1 1 addr data 0 Write 1 0 0 addr - [addr] Read 1 0 1 addr data data Write-through Both the character and font s are read-only, so we will use Signal Value EN 1 for read, 0 for hold RST 0 WE 0 ADDR read address DI 0 (unused) On-chip Peripheral Bus. Part of IBM s CoreConnect bus architecture. A lower-speed bus for peripherals such as our video controller. Inputs Outputs OPB_Clk sl_dbus OPB_Rst sl_xferack OPB_ABus sl_retry OPB_BE sl_toutsup OPB_DBus sl_errack OPB_RNW OPB_select OPB_seqAddr A Video Controller p. 22/57 A Video Controller p. 23/57 A Video Controller p. 24/57 OPB Signals Typical OPB Read Cycle Timing Typical OPB Write Cycle Timing OPB_Clk Bus clock: master synchronization OPB_Rst Global asynchronous reset OPB_ABus[31:0]Address OPB_BE[3:0] Byte enable OPB_DBus Data to slave OPB_RNW 1=read from slave, 0=write to slave OPB_select Transfer in progress OPB_seqAddr Next sequential address pending (unused) sl_dbus Data from slave. Must be 0 when inactive sl_xferack Transfer acknowledge. OPB_select 0 sl_retry Request master to retry operation (=0) sl_toutsup Suppress slave time-out (=0) OPB BE sl DBus sl xferack 00000000 valid 00000000 OPB signals arrive late; DBus and xferack needed early. OPB BE OBP DBus sl xferack

OPB interface block diagram OPB- Read Timing OPB- Write Timing OPB_DBus 0 VGA_DBus OPB_ABus OPB_Select OPB_RNW Controller 1. n -Data VGA DBus RST WE MemCycle1 00000000 valid 00000000 (one only) (always low) OPB DBus RST WE MemCycle1 (always high) (one only) MemCycle2 MemCycle2 A Video Controller p. 28/5 VGA xferack A Video Controller p. 29/5 VGA xferack A Video Controller p. 30/5 VHDL: Entity generics VHDL: OPB Ports VHDL: Video ports library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_arith.all; use ieee.std_logic_unsigned.all; entity opb_xsb300e_vga is generic ( C_OPB_AWIDTH : integer := 32; C_OPB_DWIDTH : integer := 32; C_BASEADDR : std_logic_vector(31 downto 0) := X"FEFF1000"; C_HIGHADDR : std_logic_vector(31 downto 0) := X"FEFF1FFF" ); port ( OPB_Clk OPB_Rst : in std_logic; : in std_logic; -- OPB signals OPB_ABus : in std_logic_vector(31 downto 0); OPB_BE : in std_logic_vector(3 downto 0); OPB_DBus : in std_logic_vector(31 downto 0); OPB_RNW : in std_logic; OPB_select : in std_logic; OPB_seqAddr : in std_logic; VGA_DBus : out std_logic_vector(31 downto 0); VGA_errAck : out std_logic; VGA_retry : out std_logic; VGA_toutSup : out std_logic; VGA_xferAck : out std_logic; -- Video signals Pixel_Clock : in std_logic; -- 25 MHz VIDOUT_RED : out std_logic; VIDOUT_GREEN : out std_logic; VIDOUT_BLUE : out std_logic; VIDOUT_ : out std_logic; VIDOUT_VSYNC : out std_logic ); end opb_xsb300e_vga; A Video Controller p. 31/5 A Video Controller p. 32/5 A Video Controller p. 33/5 VHDL: Architecture constants VHDL: OPB signals VHDL: Video signals 1 architecture Behavioral of opb_xsb300e_vga is constant BASEADDR : std_logic_vector(31 downto 0) := X"FEFF1000"; -- Video parameters constant HTOTAL : integer := 800; constant : integer := 96; constant HBACK_PORCH : integer := 48; constant HACTIVE : integer := 640; constant HFRONT_PORCH : integer := 16; constant VTOTAL : integer := 525; constant VSYNC : integer := 2; constant VBACK_PORCH : integer := 33; constant VACTIVE : integer := 480; constant VFRONT_PORCH : integer := 10; -- Latched input signals from the OPB signal ABus : std_logic_vector (31 downto 0); signal DBus : std_logic_vector (31 downto 0); signal RNW : std_logic; signal select_delayed : std_logic; -- Latched output data for the OPB signal DBus_out : std_logic_vector (31 downto 0); -- Signals for the OPB-mapped controller signal ChipSelect : std_logic; signal MemCycle1, MemCycle2 : std_logic; signal RamPageAddress : std_logic_vector(2 downto 0); signal RamSelect : std_logic_vector (7 downto 0); signal RST, WE : std_logic_vector (7 downto 0); signal DOUT0, DOUT1, DOUT2, DOUT3, DOUT4, DOUT5, DOUT6, DOUT7, : std_logic_vector(7 downto 0); signal ReadData : std_logic_vector(7 downto 0); -- Master horizontal and vertical video counters signal Hcount : std_logic_vector(9 downto 0); signal Vcount : std_logic_vector(9 downto 0); signal HBLANK_N, VBLANK_N : std_logic; signal EndOfLine, EndOfField : std_logic; -- Addresses and control for character signal LoadChar : std_logic; signal CharRow, CharColumn : std_logic_vector(9 downto 0); signal Column : std_logic_vector(6 downto 0); signal Row : std_logic_vector(4 downto 0); signal CharAddr : std_logic_vector(11 downto 0); signal CharRamPage :std_logic_vector(2 downto 0); signal CharRamSelect_N : std_logic_vector(4 downto 0); signal DOUTB0, DOUTB1, DOUTB2, DOUTB3, DOUTB4 : std_logic_vector(7 downto 0);

VHDL: Video signals 2 VHDL: B component VHDL: B initialization -- Addresses and control for font signal FontLoad : std_logic; signal FontAddr : std_logic_vector(10 downto 0); signal FontRamPage : std_logic_vector(1 downto 0); signal FontRamSelect_N : std_logic_vector(2 downto 0); signal DOUTB5, DOUTB6, DOUTB7 : std_logic_vector(7 downto 0); -- Shift register control, inputs, and data signal LoadNShift : std_logic; signal FontData : std_logic_vector(7 downto 0); signal ShiftData : std_logic_vector(7 downto 0); signal VideoData : std_logic; A Video Controller p. 37/5 -- 512 X 8 dual-ported Xilinx block component B4_S8_S8 port ( DOA : out std_logic_vector (7 downto 0); ADDRA : in std_logic_vector (8 downto 0); CLKA : in std_logic; DIA : in std_logic_vector (7 downto 0); ENA : in std_logic; RSTA : in std_logic; WEA : in std_logic; DOB : out std_logic_vector (7 downto 0); ADDRB : in std_logic_vector (8 downto 0); CLKB : in std_logic; DIB : in std_logic_vector (7 downto 0); ENB : in std_logic; RSTB : in std_logic; WEB : in std_logic); end component; -- Attributes that control the initial values -- loaded into block s attribute INIT_00 : string; attribute INIT_01 : string; A Video Controller p. 38/5 -- Standard IBM 8x16 console font from the Linux attribute INIT_00 of B4_S8_S8_5 : label is "000000001818001818183c3c3c18000000000000000000 attribute INIT_01 of B4_S8_S8_5 : label is "000000006c6cfe6c6c6cfe6c6c00000000000000000000 attribute INIT_02 of B4_S8_S8_5 : label is "0000000086c66030180cc6c200000000000010107cd616 attribute INIT_03 of B4_S8_S8_5 : label is "000000000000000000000030181818000000000076cccc attribute INIT_04 of B4_S8_S8_5 : label is "0000000030180c0c0c0c0c0c18300000000000000c1830 attribute INIT_05 of B4_S8_S8_5 : label is "00000000000018187e1818000000000000000000000066 attribute INIT_06 of B4_S8_S8_5 : label is "0000000000000000fe0000000000000000000030181818 attribute INIT_07 of B4_S8_S8_5 : label is "0000000000c06030180c06000000000000000000181800 attribute INIT_08 of B4_S8_S8_5 : label is "000000007e1818181818187838180000000000007cc6e6 attribute INIT_09 of B4_S8_S8_5 : label is "000000007cc60606063c0606c67c000000000000fec6c0 A Video Controller p. 39/5 attribute INIT_0a of B4_S8_S8_5 : label is VHDL: Character B instances VHDL: Font B instances VHDL: OPB inputs -- body of architecture B4_S8_S8_0 : B4_S8_S8 port map ( DOA => DOUT0, ADDRA => ABus(8 downto 0), CLKA => OPB_Clk, DIA => DBus(7 downto 0), ENA => 1, RSTA => RST(0), WEA => WE(0), DOB => DOUTB0, ADDRB => CharAddr(8 downto 0), CLKB => Pixel_Clock, DIB => X"00", ENB => 1, RSTB => CharRamSelect_N(0), WEB => 0 ); -- Four more like this A Video Controller p. 40/5 B4_S8_S8_5 : B4_S8_S8 port map ( DOA => DOUT5, ADDRA => ABus(8 downto 0), CLKA => OPB_Clk, DIA => DBus(7 downto 0), ENA => 1, RSTA => RST(5), WEA => WE(5), DOB => DOUTB5, ADDRB => FontAddr(8 downto 0), CLKB => Pixel_Clock, DIB => X"00", ENB => 1, RSTB => FontRamSelect_N(0), WEB => 0 ); -- Two more like this A Video Controller p. 41/5 -- OPB- controller -- Unused OPB control signals VGA_errAck <= 0 ; VGA_retry <= 0 ; VGA_toutSup <= 0 ; -- Latch late-arriving OPB signals LatchOPB: process (OPB_Clk, OPB_Rst) Abus <= ( others => 0 ); DBus <= ( others => 0 ); RNW <= 1 ; select_delayed <= 0 ; elsif OPB_Clk event and OPB_Clk = 1 then ABus <= OPB_ABus; DBus <= OPB_DBus; RNW <= OPB_RNW; select_delayed <= OPB_Select; end process LatchOPB; A Video Controller p. 42/5 VHDL: Chip select, page decode VHDL: FSM, B control VHDL: OPB output ChipSelect <= 1 when select_delayed = 1 and (ABus(31 downto 12) = BASEADDR(31 downto 12)) and MemCycle1 = 0 and MemCycle2 = 0 0 ; RamPageAddress <= ABus(11 downto 9); RamSelect <= "00000001" when RamPageAddress = "000" "00000010" when RamPageAddress = "001" "00000100" when RamPageAddress = "010" "00001000" when RamPageAddress = "011" "00010000" when RamPageAddress = "100" "00100000" when RamPageAddress = "101" "01000000" when RamPageAddress = "110" "10000000" when RamPageAddress = "111" "00000000"; MemCycleFSM : process(opb_clk, OPB_Rst) MemCycle1 <= 0 ; MemCycle2 <= 0 ; elsif OPB_Clk event and OPB_Clk = 1 then MemCycle2 <= MemCycle1; MemCycle1 <= ChipSelect; end process MemCycleFSM; VGA_xferAck <= MemCycle2; -- OPB output WE <= RamSelect when ChipSelect = 1 and RNW = 0 and OPB_Rst = 0 "00000000"; RST <= not RamSelect when ChipSelect = 1 and RNW = 1 and OPB_Rst = 0 "11111111"; ReadData <= DOUT0 or DOUT1 or DOUT2 or DOUT3 or DOUT4 or DOUT5 or DOUT6 or DOUT7 when MemCycle1 = 1 "00000000"; GenDOut: process (OPB_Clk, OPB_Rst) DBus_out <= ( others => 0 ); elsif OPB_Clk event and OPB_Clk = 1 then DBus_out <= ReadData & ReadData & ReadData & ReadData; end process GenDOut; VGA_DBus <= DBus_out;

VHDL: Video HCounter VHDL: Video VCounter VHDL: Hsync -- Video controller HCounter : process (Pixel_Clock, OPB_Rst) Hcount <= (others => 0 ); if EndOfLine = 1 then Hcount <= (others => 0 ); Hcount <= Hcount + 1; end process HCounter; EndOfLine <= 1 when Hcount = HTOTAL - 1 0 ; VCounter: process (Pixel_Clock, OPB_Rst) Vcount <= (others => 0 ); if EndOfLine = 1 then if EndOfField = 1 then Vcount <= (others => 0 ); Vcount <= Vcount + 1; end process VCounter; EndOfField <= 1 when Vcount = VTOTAL - 1 0 ; HSyncGen : process (Pixel_Clock, OPB_Rst) VIDOUT_ <= 0 ; if EndOfLine = 1 then VIDOUT_ <= 1 ; elsif Hcount = - 1 then VIDOUT_ <= 0 ; end process HSyncGen; A Video Controller p. 46/5 A Video Controller p. 47/5 A Video Controller p. 48/5 VHDL: HBlank VHDL: VSync VHDL: VBlank HBlankGen : process (Pixel_Clock, OPB_Rst) HBLANK_N <= 0 ; if Hcount = + HBACK_PORCH - 1 then HBLANK_N <= 1 ; elsif Hcount = + HBACK_PORCH + HACTIVE - 1 then HBLANK_N <= 0 ; end process HBlankGen; VSyncGen : process (Pixel_Clock, OPB_Rst) VIDOUT_VSYNC <= 0 ; if EndOfLine = 1 then if EndOfField = 1 then VIDOUT_VSYNC <= 1 ; elsif VCount = VSYNC - 1 then VIDOUT_VSYNC <= 0 ; end process VSyncGen; VBlankGen : process (Pixel_Clock, OPB_Rst) VBLANK_N <= 0 ; if EndOfLine = 1 then if Vcount = VSYNC + VBACK_PORCH - 1 then VBLANK_N <= 1 ; elsif VCount = VSYNC + VBACK_PORCH + VACTIVE - 1 then VBLANK_N <= 0 ; end process VBlankGen; A Video Controller p. 49/5 A Video Controller p. 50/5 A Video Controller p. 51/5 VHDL: Video Timing, addresses VHDL: character I/O VHDL: Font I/O LoadChar <= 1 when Hcount(2 downto 0) = X"5" 0 ; FontLoad <= 1 when Hcount(2 downto 0) = X"6" 0 ; LoadNShift <= 1 when Hcount(2 downto 0) = X"7" 0 ; CharColumn <= Hcount - - HBACK_PORCH + 4; Column <= CharColumn(9 downto 3); CharRow <= Vcount - VSYNC - VBACK_PORCH; Row <= CharRow(8 downto 4); -- Character address = Column + Row * 80 CharAddr <= Column + ("0" & Row(4 downto 0) & "000000") + ("000" & Row(4 downto 0) & "0000"); CharRamPage <= CharAddr(11 downto 9); CharRamSelect_N <= "11110" when CharRamPage = "000" "11101" when CharRamPage = "001" "11011" when CharRamPage = "010" "10111" when CharRamPage = "011" "01111" when CharRamPage = "100" "11111"; FontAddr(10 downto 4) <= (DOUTB0(6 downto 0) or DOUTB1(6 downto 0) or DOUTB2(6 downto 0) or DOUTB3(6 downto 0) or DOUTB4(6 downto 0)); FontAddr(3 downto 0) <= CharRow(3 downto 0); FontRamPage <= FontAddr(10 downto 9); FontRamSelect_N <= "110" when FontRamPage = "00" "110" when FontRamPage = "01" "101" when FontRamPage = "10" "011" when FontRamPage = "11" "111"; FontData <= DOUTB5 or DOUTB6 or DOUTB7;

VHDL: Shift Register VHDL: DAC output The Punchline ShiftRegister: process (Pixel_Clock, OPB_Rst) ShiftData <= X"00"; if LoadNShift = 1 then ShiftData <= FontData; ShiftData <= ShiftData(6 downto 0) & 0 ; end process ShiftRegister; VideoData <= ShiftData(7); VideoOut: process (Pixel_Clock, OPB_Rst) VIDOUT_RED <= 0 ; VIDOUT_BLUE <= 0 ; VIDOUT_GREEN <= 0 ; elsif Pixel_Clock event and Pixel_Clock = 1 if VideoData = 1 and HBLANK_N = 1 and VB VIDOUT_RED <= 1 ; VIDOUT_GREEN <= 1 ; VIDOUT_BLUE <= 1 ; VIDOUT_RED <= 0 ; VIDOUT_GREEN <= 0 ; VIDOUT_BLUE <= 0 ; end process VideoOut; end Behavioral; -- end of architecture This video controller is not quite right for the Spartan-3 chip on the Digilent boards. Our boards have an XC3S400, which has 32K of on-chip, not 8K. The block s are similar, but are 4K each, not 512 bytes. What is presented here works, but is wasting memory resources. A better design would use only 3 of the Spartan-3 block S, not 8. A Video Controller p. 55/5 A Video Controller p. 56/5 A Video Controller p. 57/5