VGA Display Part 4 Text Generation

Slides:



Advertisements
Similar presentations
Arbitrary Waveform Discussion 5.5 Example 34.
Advertisements

1 VLSI DESIGN USING VHDL Part II A workshop by Dr. Junaid Ahmed Zubairi.
Ring Counter Discussion D5.3 Example 32. Ring Counter if rising_edge(CLK) then for i in 0 to 2 loop s(i)
Top-level VHDL Designs
Generic Multiplexers: Parameters Discussion D2.5 Example 8.
FPGAs and VHDL Lecture L12.1. FPGAs and VHDL Field Programmable Gate Arrays (FPGAs) VHDL –2 x 1 MUX –4 x 1 MUX –An Adder –Binary-to-BCD Converter –A Register.
Counters Discussion D5.3 Example 33. Counters 3-Bit, Divide-by-8 Counter 3-Bit Behavioral Counter in Verilog Modulo-5 Counter An N-Bit Counter.
ECE 448 Lecture 3 Combinational-Circuit Building Blocks Data Flow Modeling of Combinational Logic ECE 448 – FPGA and ASIC Design with VHDL.
ECE 448 Lecture 7 VGA Display Part 1
Random-Access Memory Distributed and Block RAM Discussion D10.3 Example 41.
4-bit Shift Register. 2-bit Register Serial-in-serial-out Shift Register.
1 Part V: VHDL CODING. 2 Design StructureData TypesOperators and AttributesConcurrent DesignSequential DesignSignals and VariablesState Machines A VHDL.
George Mason University FPGA Memories ECE 448 Lecture 13.
ECE 448 Lecture 8 VGA Display Part 2
EE4OI4 Engineering Design UP1core Library Functions.
George Mason University ECE 448 – FPGA and ASIC Design with VHDL VGA Display Part 1 VGA Synchronization ECE 448 Lecture 9.
George Mason University ECE 448 – FPGA and ASIC Design with VHDL VGA Display Part 2 Animation ECE 448 Lecture 9.
Copyright (c) 2003 by Valery Sklyarov and Iouliia Skliarova: DETUA, IEETA, Aveiro University, Portugal.
Data Storage VHDL ET062G & ET063G Lecture 4 Najeem Lawal 2012.
CDA 4253 FGPA System Design Xilinx FPGA Memories
George Mason University ECE 448 – FPGA and ASIC Design with VHDL VGA Display Part 3 Animation ECE 448 Lecture 11.
George Mason University ECE 448 – FPGA and ASIC Design with VHDL VGA Display Part 1 Synchronization & Pixel Generation ECE 448 Lecture 8.
George Mason University Behavioral Modeling of Sequential-Circuit Building Blocks ECE 545 Lecture 8.
Lecture 11 Xilinx FPGA Memories Part 2
George Mason University ECE 448 – FPGA and ASIC Design with VHDL VGA Display Part 3 Animation ECE 448 Lecture 11.
George Mason University ECE 448 – FPGA and ASIC Design with VHDL VGA Display Part 5 The Complete Pong Game ECE 448 Lecture 13.
Class Exercise 1B.
VGA Display Part 1 VGA Synchronization
Main Project : Simple Processor Mini-Project : Vending Machine Memory
Controllers for Keccak_F and AES Advanced Coding Style for Datapaths
Describing Combinational Logic Using Processes
VGA Display Part 2 Pixel Generation
VGA Display Part 3 Text Generation
Part II A workshop by Dr. Junaid Ahmed Zubairi
Part IV: VHDL CODING.
RTL Design Methodology
VGA Display Part 3 Animation
VGA Display Part 5 The Complete Pong Game
ECE 448 Lecture 3 Combinational-Circuit Building Blocks Data Flow Modeling of Combinational Logic ECE 448 – FPGA and ASIC Design with VHDL.
Programmable Logic Memories
Sequential-Circuit Building Blocks
Algorithmic State Machine (ASM) Charts: VHDL Code & Timing Diagrams
Introduction to ModelSim Implementing Sequential
Programmable Logic Memories
Lecture 18 PicoBlaze I/O Interface
ECE 448 Lecture 3 Combinational-Circuit Building Blocks Data Flow Modeling of Combinational Logic ECE 448 – FPGA and ASIC Design with VHDL.
ECE 448 Lecture 6 Modeling of Circuits with a Regular Structure Aliases, Constants, Packages Mixing Design Styles ECE 448 – FPGA and ASIC Design with.
Lecture 13 PicoBlaze I/O & Interrupt Interface
ECE 545 Lecture 17 RAM.
ECE 448 Lecture 13 Multipliers Timing Parameters
Modeling of Circuits with a Regular Structure
Behavioral Modeling of Sequential-Circuit Building Blocks
Sequntial-Circuit Building Blocks
ECE 448 Lecture 3 Combinational-Circuit Building Blocks Data Flow Modeling of Combinational Logic ECE 448 – FPGA and ASIC Design with VHDL.
Data Flow Description of Combinational-Circuit Building Blocks
Modeling of Circuits with a Regular Structure
Lecture 13 PicoBlaze I/O & Interrupt Interface
Data Flow Description of Combinational-Circuit Building Blocks
ECE 448 Lecture 4 Modeling of Circuits with a Regular Structure Constants, Aliases, Packages ECE 448 – FPGA and ASIC Design with VHDL.
Modeling of Circuits with a Regular Structure
ECE 448: Spring 2019 Lab 5 Julia Set Fractal.
ECE 545 Lecture 5 Simple Testbenches.
FPro Video Subsystem: VGA Frame Buffer Core
ECE 448 Lecture 6 Finite State Machines State Diagrams, State Tables, Algorithmic State Machine (ASM) Charts, and VHDL code ECE 448 – FPGA and ASIC Design.
Modeling of Circuits with Regular Structure
VGA Display: VGA Synchronization & Pixel Generation
Sequntial-Circuit Building Blocks
디 지 털 시 스 템 설 계 UP2 Kit를 이용한 카운터 설계
(Sequential-Circuit Building Blocks)
Presentation transcript:

VGA Display Part 4 Text Generation ECE 448 Lecture 13 VGA Display Part 4 Text Generation ECE 448 – FPGA and ASIC Design with VHDL

Required Reading P. Chu, FPGA Prototyping by VHDL Examples Chapter 13, VGA Controller II: Text Source Codes of Examples http://academic.csuohio.edu/chu_p/rtl/fpga_vhdl.html Basys 3 FPGA Board Reference Manual 7. VGA Port ECE 448 – FPGA and ASIC Design with VHDL

Text Generation ECE 448 – FPGA and ASIC Design with VHDL

Text Generation Basics Each character is treated as a tile The patterns of the tiles constitute the font of the character set We use an 8 x 16 font, similar to the one used in early IBM PCs In this font each character is represented as an 8 x 16 pixel pattern The character patterns are stored in the pattern memory, known as font ROM For a 7-bit ASCII we need 128 x 16 x 8 = 2k x 8 ROM ECE 448 – FPGA and ASIC Design with VHDL

Font Pattern of A ECE 448 – FPGA and ASIC Design with VHDL

Artix-7 FPGA Family ECE 448 – FPGA and ASIC Design with VHDL

Font ROM in VHDL (1) library ieee; use ieee.std_logic_1164.all; use ieee.numeric_std.all; entity font_rom is port( clk: in std_logic; addr: in std_logic_vector(10 downto 0); data: out std_logic_vector(7 downto 0) ); end font_rom; ECE 448 – FPGA and ASIC Design with VHDL

Font ROM in VHDL (2) architecture arch of font_rom is constant ADDR_WIDTH: integer:=11; constant DATA_WIDTH: integer:=8; signal addr_reg: std_logic_vector(ADDR_WIDTH-1 downto 0); type rom_type is array (0 to 2**ADDR_WIDTH-1) of std_logic_vector(DATA_WIDTH-1 downto 0); ECE 448 – FPGA and ASIC Design with VHDL

Font ROM in VHDL (3) constant ROM: rom_type:=( -- 2^11-by-8 "00000000", -- 0 "00000000", -- 1 "00000000", -- 2 "00000000", -- 3 "00000000", -- 4 "00000000", -- 5 "00000000", -- 6 "00000000", -- 7 "00000000", -- 8 "00000000", -- 9 "00000000", -- a "00000000", -- b "00000000", -- c "00000000", -- d "00000000", -- e "00000000", -- f ECE 448 – FPGA and ASIC Design with VHDL

Font ROM in VHDL (4) -- code x01 (smiley face) "00000000", -- 0 "00000000", -- 1 "01111110", -- 2 ****** "10000001", -- 3 * * "10100101", -- 4 * * * * "10000001", -- 5 * * "10000001", -- 6 * * "10111101", -- 7 * **** * "10011001", -- 8 * ** * "10000001", -- 9 * * "10000001", -- a * * "01111110", -- b ****** "00000000", -- c "00000000", -- d "00000000", -- e "00000000", -- f ECE 448 – FPGA and ASIC Design with VHDL

Font ROM in VHDL (5) – version 1 ………………… "00000000" -- f ); begin data_next <= ROM(to_integer(unsigned(addr))); -- addr register to infer block RAM process (clk) if (clk'event and clk = '1') then data <= data_next; end if; end process; end arch; ECE 448 – FPGA and ASIC Design with VHDL

Font ROM in VHDL (5) – version 2 ………………… "00000000" -- f ); begin -- addr register to infer block RAM process (clk) if (clk'event and clk = '1') then addr_reg <= addr; end if; end process; data <= ROM(to_integer(unsigned(addr_reg))); end arch; ECE 448 – FPGA and ASIC Design with VHDL

Font ROM in VHDL (6) The complete code available at http://academic.csuohio.edu/chu_p/rtl/fpga_vhdl.html File: ch13/list_ch13_01_font_rom.vhd ECE 448 – FPGA and ASIC Design with VHDL

Font Pattern of A ECE 448 – FPGA and ASIC Design with VHDL

Character coordinates 640 pixels  640/8 = 80 characters 1 2 3 4 5 6 7 8 9 10 75 76 77 78 79 1 2 3 480 pixels  480/16 = 30 characters . . . . . . . . . . . . . . . . . . . 26 27 28 29 ECE 448 – FPGA and ASIC Design with VHDL

Text Generation Circuit [0..15] [0..29] [0..127] [0..2047] [0..79] [0..7] ECE 448 – FPGA and ASIC Design with VHDL

Text Generation Circuit in VHDL (1) library ieee; use ieee.std_logic_1164.all; use ieee.numeric_std.all; entity font_test_gen is port( clk: in std_logic; video_on: in std_logic; pixel_x, pixel_y: std_logic_vector(9 downto 0); rgb_text: out std_logic_vector(2 downto 0) ); end font_test_gen; ECE 448 – FPGA and ASIC Design with VHDL

Text Generation Circuit in VHDL (2) architecture arch of font_test_gen is signal rom_addr: std_logic_vector(10 downto 0); signal char_addr: std_logic_vector(6 downto 0); signal row_addr: std_logic_vector(3 downto 0); signal bit_addr: std_logic_vector(2 downto 0); signal font_word: std_logic_vector(7 downto 0); signal font_bit, text_bit_on: std_logic; ECE 448 – FPGA and ASIC Design with VHDL

Text Generation Circuit [0..15] [0..29] [0..127] [0..2047] [0..79] [0..7] ECE 448 – FPGA and ASIC Design with VHDL

Text Generation Circuit in VHDL (3) -- instantiate font ROM font_unit: entity work.font_rom port map(clk=>clk, addr=>rom_addr, data=>font_word); -- font ROM interface row_addr<=pixel_y(3 downto 0); rom_addr <= char_addr & row_addr; bit_addr<=pixel_x(2 downto 0); font_bit <= font_word(to_integer(unsigned(not bit_addr))); ECE 448 – FPGA and ASIC Design with VHDL

not bit_addr bit_addr= 0 1 2 3 4 5 6 7 f(bit_addr)= 7 6 5 4 3 2 1 0 0 1 2 3 4 5 6 7 f(bit_addr)= 7 6 5 4 3 2 1 0 f(bit_addr) = 7 – bit_addr = bit_addr Example: 2 = 0102 5 = 1012 = 7-2 = 2 ECE 448 – FPGA and ASIC Design with VHDL

not A ai 1 – ai ai 1 1 ... 1 – an-1 an-2 … a0 1 1 1 an-1 an-2 … a0 n-1 n-2 ... 0 ai 1 – ai ai 1 1 ... 1 – an-1 an-2 … a0 1 1 1 an-1 an-2 … a0 (2n-1) – A = A ECE 448 – FPGA and ASIC Design with VHDL

Repeated display of all 128 characters 32 chars 31 32 63 64 79 95 4 chars 128 characters 128 characters 128 characters 3 4 128 characters 128 characters 128 characters 7 24 128 characters 128 characters 128 characters 27 28 128 characters 128 characters 128 characters 31 ECE 448 – FPGA and ASIC Design with VHDL

Text Generation Circuit in VHDL (4) char_addr <=pixel_y(5 downto 4) & pixel_x(7 downto 3); -- 32 consecutive characters displayed in 4 rows -- This 32 x 4 region displayed repetitively on the screen ECE 448 – FPGA and ASIC Design with VHDL

Repeated display of all 128 characters 32 chars 31 79 255 4 chars 128 characters 3 63 29 ECE 448 – FPGA and ASIC Design with VHDL

Text Generation Circuit in VHDL (4) text_bit_on <= font_bit when pixel_x(9 downto 8)="00" and pixel_y(9 downto 6)="0000" else '0'; -- Only the top-left portion of the screen -- (256 x 64 pixels = 32 characters x 4 lines) turned on ECE 448 – FPGA and ASIC Design with VHDL

Text Generation Circuit [0..15] [0..29] [0..127] [0..2047] [0..79] [0..7] ECE 448 – FPGA and ASIC Design with VHDL

Text Generation Circuit in VHDL (5) -- rgb multiplexing circuit process(video_on, text_bit_on) begin if video_on='0' then rgb_text <= "000"; --blank else if text_bit_on='1' then rgb_text <= "010"; -- green rgb_text <= "000"; -- black end if; end process; end arch; ECE 448 – FPGA and ASIC Design with VHDL

Font Scaling by a Factor of 2 (1) -- instantiate font ROM font_unit: entity work.font_rom port map(clk=>clk, addr=>rom_addr, data=>font_word); -- font ROM interface -- row_addr<=pixel_y(3 downto 0); -- without scaling row_addr<=pixel_y(4 downto 1); -- with scaling rom_addr <= char_addr & row_addr; -- bit_addr<=pixel_x(2 downto 0); -- without scaling bit_addr<=pixel_x(3 downto 1); -- with scaling font_bit <= font_word(to_integer(unsigned(not bit_addr))); ECE 448 – FPGA and ASIC Design with VHDL

Font Scaling by a Factor of 2 (2) -- char_addr <=pixel_y(5 downto 4) & pixel_x(7 downto 3); -- without scaling char_addr <=pixel_y(6 downto 5) & pixel_x(8 downto 4); -- with scaling -- 32 consecutive characters displayed in 4 rows -- This 32 x 4 region displayed repetitively on the screen text_bit_on <= -- font_bit when pixel_x(9 downto 8)="00" and -- pixel_y(9 downto 6)="0000" else -- '0'; font_bit when pixel_x(9)=”0" and pixel_y(9 downto 7)="000" else '0'; -- Only the top-left portion of the screen -- (256 x 64 pixels = 32 characters x 4 lines) turned on ECE 448 – FPGA and ASIC Design with VHDL

Text Generation Circuit with Tile Memory [0..15] [0..29] & [0..79] [7..0] [0..29] [0..79] [0..2047] [0..7] ECE 448 – FPGA and ASIC Design with VHDL

Full-Screen Text Display in VHDL (1) library ieee; use ieee.std_logic_1164.all; use ieee.numeric_std.all; entity text_screen_gen is port( clk, reset: std_logic; btn: std_logic_vector(2 downto 0); sw: std_logic_vector(6 downto 0); video_on: in std_logic; pixel_x, pixel_y: in std_logic_vector(9 downto 0); text_rgb: out std_logic_vector(2 downto 0) ); end text_screen_gen; ECE 448 – FPGA and ASIC Design with VHDL

Full-Screen Text Display in VHDL (2) architecture arch of text_screen_gen is -- font ROM signal char_addr: std_logic_vector(6 downto 0); signal rom_addr: std_logic_vector(10 downto 0); signal row_addr: std_logic_vector(3 downto 0); signal bit_addr: unsigned(2 downto 0); signal font_word: std_logic_vector(7 downto 0); signal font_bit: std_logic; -- tile RAM signal we: std_logic; signal addr_r, addr_w: std_logic_vector(11 downto 0); signal din, dout: std_logic_vector(6 downto 0); -- 80-by-30 tile map constant MAX_X: integer:=80; constant MAX_Y: integer:=30; ECE 448 – FPGA and ASIC Design with VHDL

Full-Screen Text Display in VHDL (3) -- cursor signal cur_x_reg, cur_x_next: unsigned(6 downto 0); signal cur_y_reg, cur_y_next: unsigned(4 downto 0); signal move_x_tick, move_y_tick: std_logic; signal cursor_on: std_logic; -- delayed pixel count signal pix_x1_reg, pix_y1_reg: unsigned(9 downto 0); signal pix_x2_reg, pix_y2_reg: unsigned(9 downto 0); -- object output signals signal font_rgb, font_rev_rgb: std_logic_vector(2 downto 0); ECE 448 – FPGA and ASIC Design with VHDL

Full-Screen Text Display in VHDL (4) begin -- instantiate debounce circuit for two buttons debounce_unit0: entity work.debounce port map(clk=>clk, reset=>reset, sw=>btn(0), db_level=>open, db_tick=>move_x_tick); debounce_unit1: entity work.debounce port map(clk=>clk, reset=>reset, sw=>btn(1), db_level=>open, db_tick=>move_y_tick); ECE 448 – FPGA and ASIC Design with VHDL

Full-Screen Text Display in VHDL (5) -- instantiate font ROM font_unit: entity work.font_rom port map(clk=>clk, addr=>rom_addr, data=>font_word); -- instantiate dual port tile RAM (2^12-by-7) video_ram: entity work.xilinx_dual_port_ram_sync generic map(ADDR_WIDTH=>12, DATA_WIDTH=>7) port map(clk=>clk, we=>we, addr_a=>addr_w, addr_b=>addr_r, din_a=>din, dout_a=>open, dout_b=>dout); ECE 448 – FPGA and ASIC Design with VHDL

Full-Screen Text Display in VHDL (6) -- registers process (clk) begin if (clk'event and clk='1') then cur_x_reg <= cur_x_next; cur_y_reg <= cur_y_next; pix_x1_reg <= unsigned(pixel_x); -- 2 clock delay pix_x2_reg <= pix_x1_reg; pix_y1_reg <= unsigned(pixel_y); pix_y2_reg <= pix_y1_reg; end if; end process; ECE 448 – FPGA and ASIC Design with VHDL

Text Generation Circuit with Tile Memory [0..15] [0..29] & [0..79] [7..0] [0..29] [0..79] [0..2047] [0..7] ECE 448 – FPGA and ASIC Design with VHDL

Full-Screen Text Display in VHDL (7) -- tile RAM write addr_w <=std_logic_vector(cur_y_reg & cur_x_reg); we <= btn(2); din <= sw; -- tile RAM read -- use non-delayed coordinates to form tile RAM address addr_r <=pixel_y(8 downto 4) & pixel_x(9 downto 3); char_addr <= dout; -- font ROM row_addr<=pixel_y(3 downto 0); rom_addr <= char_addr & row_addr; -- use delayed coordinate to select a bit bit_addr<=pix_x2_reg(2 downto 0); font_bit <= font_word(to_integer(not bit_addr)); ECE 448 – FPGA and ASIC Design with VHDL

Full-Screen Text Display in VHDL (8) -- new cursor position cur_x_next <= (others=>'0') when move_x_tick='1' and -- wrap around cur_x_reg=MAX_X-1 else cur_x_reg + 1 when move_x_tick='1' else cur_x_reg ; cur_y_next <= (others=>'0') when move_y_tick='1' and -- wrap around cur_y_reg=MAX_Y-1 else cur_y_reg + 1 when move_y_tick='1' else cur_y_reg; ECE 448 – FPGA and ASIC Design with VHDL

Full-Screen Text Display in VHDL (9) -- object signals -- green over black and reversed video for cursor font_rgb <="010" when font_bit='1' else "000"; font_rev_rgb <="000" when font_bit='1' else "010"; -- use delayed coordinates for comparison cursor_on <='1' when pix_y2_reg(8 downto 4)=cur_y_reg and pix_x2_reg(9 downto 3)=cur_x_reg else '0'; ECE 448 – FPGA and ASIC Design with VHDL

Full-Screen Text Display in VHDL (10) -- rgb multiplexing circuit process(video_on,cursor_on,font_rgb,font_rev_rgb) begin if video_on='0' then text_rgb <= "000"; --blank else if cursor_on='1' then text_rgb <= font_rev_rgb; text_rgb <= font_rgb; end if; end process; end arch; ECE 448 – FPGA and ASIC Design with VHDL