Example VGA Text Display TYWu VGA Connector VGA

  • Slides: 33
Download presentation
Example: VGA Text Display TYWu

Example: VGA Text Display TYWu

VGA Connector

VGA Connector

VGA Connector • Starter Kit

VGA Connector • Starter Kit

VGA Connector • XSA-100

VGA Connector • XSA-100

640 x 480 VGA Display

640 x 480 VGA Display

640 x 480 VGA Display

640 x 480 VGA Display

VGA/SVGA • Timing Charts

VGA/SVGA • Timing Charts

VGA/SVGA • Timing

VGA/SVGA • Timing

vga_text_10 c. v module sync_gen 50 (clk, Counter. X, Counter. Y, Valid, vga_h_sync, vga_v_sync);

vga_text_10 c. v module sync_gen 50 (clk, Counter. X, Counter. Y, Valid, vga_h_sync, vga_v_sync); : endmodule vgafla_g(clock, vga_hsync , vga_vsync, vga_red 0, vga_green 0, vga_blue 0, vga_red 1, vga_green 1, vga_blue 1); : sync_gen 50 sync. VGA(. clk(clock), . Counter. X(XPos), . Counter. Y(YPos), . Valid(Valid), . vga_h_sync(vga_hsync), . vga_v_sync(vga_vsync)); genchar_u 1(XPos, YPos, out_scan, in_text); : endmodule genchar(Counter. X, Counter. Y, out_scan, in_text); : endmodule

module sync_gen 50 //Counters always @ (posedge clk) begin if (Reset. Cnt. X) Counter.

module sync_gen 50 //Counters always @ (posedge clk) begin if (Reset. Cnt. X) Counter. X[10: 0] <= 11'b 0; else Counter. X[10: 0] <= Counter. X[10: 0] + 1; if (Reset. Cnt. Y) Counter. Y[9: 0] <= 10'b 0; else if (Enable. Cnt. Y) Counter. Y[9: 0] <= Counter. Y + 1; else Counter. Y[9: 0] <= Counter. Y[9: 0]; end //Synchronizer controller always @(posedge clk ) begin Reset. Cnt. X <= (Counter. X[10: 0] ==1586); // was 381 was 798 Enable. Cnt. Y <= (Counter. X[10: 0] == 1300); // was 39 was 25 Reset. Cnt. Y <= (Counter. Y[9: 0] ==527); end //signal synchronizer always @(posedge clk) begin vga_h_sync <= ~((Counter. X[10: 0] >= 1304) && (Counter. X[10: 0] <= 1493)); vga_v_sync <= ~((Counter. Y[9: 0] == 493) || (Counter. Y[9: 0] == 494 )); Valid <= (((Counter. X == 1587) || (Counter. X < 1288)) && ((Counter. Y == 527) || (Counter. Y < 480 )) ); end

module vgafla_g (TOP) : assign in_text=80'b 0000_00000001_00000010_00000011_00000100_00000101_000 00110_00000111_00001000_00001001; /* specify your text here */

module vgafla_g (TOP) : assign in_text=80'b 0000_00000001_00000010_00000011_00000100_00000101_000 00110_00000111_00001000_00001001; /* specify your text here */ wire red 0 = Valid && out_scan; wire red 1 = Valid && out_scan; wire green 0 = Valid && out_scan; wire green 1 = Valid && out_scan; wire blue 0 = Valid && out_scan; wire blue 1 = Valid && out_scan; assign vga_red 0 = red 0 ? 1'b 1 : 1'b 0; assign vga_green 0 = green 0 ? 1'b 1: 1'b 0; assign vga_blue 0 = blue 0 ? 1'b 1: 1'b 0; assign vga_red 1 = red 1 ? 1'b 1: 1'b 0; assign vga_green 1 = green 1 ? 1'b 1: 1'b 0; assign vga_blue 1 = blue 1? 1'b 1: 1'b 0 ; :

module genchar `define TOTAL_SCREEN_CHAR 10 /* counted from No 0 */ `define LOG 2_TOTAL_SCREEN_CHAR

module genchar `define TOTAL_SCREEN_CHAR 10 /* counted from No 0 */ `define LOG 2_TOTAL_SCREEN_CHAR 3 /* floor(Log 2 10) = 3 */ `define TOTAL_SUPPORT_CHAR 16 /* now, I only implement characters: 0, 1, 2 */ `define LOG 2_TOTAL_SUPPORT_CHAR 3 /* Log 2 16 -1 = 3, assume that we can support 16 characters*/ module genchar(Counter. X, Counter. Y, out_scan, in_text); input [9: 0] Counter. Y; input [10: 0] Counter. X; output out_scan; /* out_scan is used to show a pixel in the screen */ input [`TOTAL_SCREEN_CHAR*8 -1: 0] in_text; /* 10 words, each word need 8 bits for encoding */ /* 0: 0000 */ /* 1: 00000001 */ /* 2: 00000010 */ /* if we want show 012. . . => in_text is ". . . 000000010, 00000001, 0000 */

module genchar reg out_scan; reg[`LOG 2_TOTAL_SCREEN_CHAR : 0] char_no_on_screen; reg[10: 0] line_fac; /* line

module genchar reg out_scan; reg[`LOG 2_TOTAL_SCREEN_CHAR : 0] char_no_on_screen; reg[10: 0] line_fac; /* line 0 ~ line 7 ; each line keep 16*8(=128) pixels */ reg[7: 0] char_encode; reg[`LOG 2_TOTAL_SUPPORT_CHAR+3: 0] char_fac; reg[4: 0] col_fac; reg[10: 0] index; reg[10: 0] char_no_on_screen_mul_8; reg[9: 0] div. Y; reg[10: 0] div. X; wire[0: `TOTAL_SUPPORT_CHAR*8 -1] line 0; wire[0: `TOTAL_SUPPORT_CHAR*8 -1] line 1; wire[0: `TOTAL_SUPPORT_CHAR*8 -1] line 2; wire[0: `TOTAL_SUPPORT_CHAR*8 -1] line 3; wire[0: `TOTAL_SUPPORT_CHAR*8 -1] line 4; wire[0: `TOTAL_SUPPORT_CHAR*8 -1] line 5; wire[0: `TOTAL_SUPPORT_CHAR*8 -1] line 6; wire[0: `TOTAL_SUPPORT_CHAR*8 -1] line 7; wire[0: `TOTAL_SUPPORT_CHAR*64 -1] all_lines;

module genchar wire[0: 7] dumy; wire[0: 7] c 0_0; /* line 0 of char

module genchar wire[0: 7] dumy; wire[0: 7] c 0_0; /* line 0 of char 0 ; char 0 means that the character's encode is 0 */ /* In fact, char 0 describes number 0 */ wire[0: 7] c 0_1; wire[0: 7] c 0_2; wire[0: 7] c 0_3; wire[0: 7] c 0_4; wire[0: 7] c 0_5; wire[0: 7] c 0_6; wire[0: 7] c 0_7; : assign dumy=8'b 0000; assign c 0_0=8'b 0000; assign c 0_1=8'b 11111110; assign c 0_2=8'b 10000010; assign c 0_3=8'b 10000010; assign c 0_4=8'b 10000010; assign c 0_5=8'b 10000010; assign c 0_6=8'b 10000010; assign c 0_7=8'b 11111110; :

module genchar assign line 0={c 0_0, c 1_0, c 2_0, c 3_0, c 4_0,

module genchar assign line 0={c 0_0, c 1_0, c 2_0, c 3_0, c 4_0, c 5_0, c 6_0, c 7_0, c 8_0, c 9_0, dumy, dumy}; /* Only the first 3 records are usable because only 3 characters (0, 1, 2) are supported now. */ assign line 1={c 0_1, c 1_1, c 2_1, c 3_1, c 4_1, c 5_1, c 6_1, c 7_1, c 8_1, c 9_1, dumy, dumy}; assign line 2={c 0_2, c 1_2, c 2_2, c 3_2, c 4_2, c 5_2, c 6_2, c 7_2, c 8_2, c 9_2, dumy, dumy}; assign line 3={c 0_3, c 1_3, c 2_3, c 3_3, c 4_3, c 5_3, c 6_3, c 7_3, c 8_3, c 9_3, dumy, dumy}; assign line 4={c 0_4, c 1_4, c 2_4, c 3_4, c 4_4, c 5_4, c 6_4, c 7_4, c 8_4, c 9_4, dumy, dumy}; assign line 5={c 0_5, c 1_5, c 2_5, c 3_5, c 4_5, c 5_5, c 6_5, c 7_5, c 8_5, c 9_5, dumy, dumy}; assign line 6={c 0_6, c 1_6, c 2_6, c 3_6, c 4_6, c 5_6, c 6_6, c 7_6, c 8_6, c 9_6, dumy, dumy}; assign line 7={c 0_7, c 1_7, c 2_7, c 3_7, c 4_7, c 5_7, c 6_7, c 7_7, c 8_7, c 9_7, dumy, dumy}; assign all_lines={line 0, line 1, line 2, line 3, line 4, line 5, line 6, line 7};

module genchar always @(Counter. X or Counter. Y or in_text or all_lines) begin out_scan

module genchar always @(Counter. X or Counter. Y or in_text or all_lines) begin out_scan = 0; div. Y = (Counter. Y >> 1)-64; div. X = (Counter. X >> 1)-64; if (div. Y >= 0 && div. Y < 8 && div. X >= 0 && div. X < (`TOTAL_SCREEN_CHAR*8)) begin char_no_on_screen = div. X >> 3; /* (>> 3) == (/ 8) */ char_no_on_screen_mul_8 = char_no_on_screen << 3; char_encode = { in_text[char_no_on_screen_mul_8+7], in_text[char_no_on_screen_mul_8+6], in_text[char_no_on_screen_mul_8+5], in_text[char_no_on_screen_mul_8+4], in_text[char_no_on_screen_mul_8+3], in_text[char_no_on_screen_mul_8+2], in_text[char_no_on_screen_mul_8+1], in_text[char_no_on_screen_mul_8]}; char_fac = char_encode << 3; /* * 8 */ col_fac = div. X - char_no_on_screen_mul_8; /* 0~7 */ line_fac = div. Y << 7; /* (<< 7) == (* 128) Because each line contains 128 pixels*/ index = char_fac + line_fac + col_fac; out_scan = all_lines[index]; end

all_lines • all_lines 2 -D Storage line 0 line 1 line 7 0 1

all_lines • all_lines 2 -D Storage line 0 line 1 line 7 0 1 2 3 …. . 9 1 -D Storage

Get and Post • A Screen Get 0 1 2 3 …. . 9

Get and Post • A Screen Get 0 1 2 3 …. . 9 0 Post

Formula 8*8 col_fac= div. X - char_no_on_screen_mul_8 line 0 line 1 line 7 0

Formula 8*8 col_fac= div. X - char_no_on_screen_mul_8 line 0 line 1 line 7 0 1 2 3 …. . 9 char_fac = char_encode * 8 = 3*8 = 24 Line_fac = div. Y*128

Lab • Steps – Write the test-bench – Answer the following questions • •

Lab • Steps – Write the test-bench – Answer the following questions • • • B us (Synch. Pulse)? C us (Back Porch)? D us (Active)? E us (Front Porch)? Q us, R us, T us?

tb. v • tb. v (partial code) `timescale 1 ns/100 ps module tb; reg

tb. v • tb. v (partial code) `timescale 1 ns/100 ps module tb; reg clock; wire vga_hsync, vga_vsync, vga_red 0, vga_green 0, vga_blue 0, vga_red 1, vga_green 1, vga_blue 1; vgafla_g U 1(clock, vga_hsync , vga_vsync, vga_red 0, vga_green 0, vga_blue 0, vga_red 1, vga_green 1, vga_blue 1); initial begin U 1. sync. VGA. Reset. Cnt. X=1; U 1. sync. VGA. Reset. Cnt. Y=1; #40 U 1. sync. VGA. Reset. Cnt. X=0; U 1. sync. VGA. Reset. Cnt. Y=0; #? ? ; $finish; end : endmodule

Waveform • vga_hsync

Waveform • vga_hsync

Waveform • vga_hsync

Waveform • vga_hsync

Waveform • vga_hsync

Waveform • vga_hsync

Waveform • Valid

Waveform • Valid

Waveform • vga_vsync

Waveform • vga_vsync

Waveform • vga_vsync

Waveform • vga_vsync

Waveform • Valid

Waveform • Valid

Exercise 1 • Draw a Circle – (Counter. X-600)*(Counter. X-600)+(Counter. Y 240)*(Counter. Y-240) <

Exercise 1 • Draw a Circle – (Counter. X-600)*(Counter. X-600)+(Counter. Y 240)*(Counter. Y-240) < R (0, 0) R (600, 240) (639, 479) (1288, 479)

Exercise 1 • R is controlled by 3 switches – 100, 150, 200

Exercise 1 • R is controlled by 3 switches – 100, 150, 200

Exercise 1 • Hint … reg dx, dy; … always … … If (Counter.

Exercise 1 • Hint … reg dx, dy; … always … … If (Counter. X<600) dx=600 -Counter. X; else dx=Counter. X-600;

Exercise 2 • Color Ring

Exercise 2 • Color Ring

Project • Running Ring Section (Only showing the red part) 12 1 2

Project • Running Ring Section (Only showing the red part) 12 1 2