1 / 33

Example: VGA Text Display

Example: VGA Text Display. TYWu. VGA Connector. VGA Connector. Starter Kit. VGA Connector. XSA-100. 640x480 VGA Display. 640x480 VGA Display. VGA/SVGA. Timing Charts. VGA/SVGA. Timing. vga_text_10c.v. module sync_gen50 (clk, CounterX, CounterY, Valid, vga_h_sync, vga_v_sync); :

Télécharger la présentation

Example: VGA Text Display

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Example: VGA Text Display TYWu

  2. VGA Connector

  3. VGA Connector • Starter Kit

  4. VGA Connector • XSA-100

  5. 640x480 VGA Display

  6. 640x480 VGA Display

  7. VGA/SVGA • Timing Charts

  8. VGA/SVGA • Timing

  9. vga_text_10c.v module sync_gen50 (clk, CounterX, CounterY, Valid, vga_h_sync, vga_v_sync); : endmodule module vgafla_g(clock, vga_hsync , vga_vsync, vga_red0, vga_green0, vga_blue0, vga_red1, vga_green1, vga_blue1); : sync_gen50 syncVGA( .clk(clock), .CounterX(XPos), .CounterY(YPos), .Valid(Valid), .vga_h_sync(vga_hsync), .vga_v_sync(vga_vsync)); genchar genchar_u1(XPos, YPos, out_scan, in_text); : endmodule module genchar(CounterX, CounterY, out_scan,in_text); : endmodule

  10. module sync_gen50 //Counters always @ (posedge clk) begin if (ResetCntX) CounterX[10:0] <= 11'b0; else CounterX[10:0] <= CounterX[10:0] + 1; if (ResetCntY) CounterY[9:0] <= 10'b0; else if (EnableCntY) CounterY[9:0] <= CounterY + 1; else CounterY[9:0] <= CounterY[9:0]; end //Synchronizer controller always @(posedge clk ) begin ResetCntX <= (CounterX[10:0] ==1586); // was 381 was 798 EnableCntY <= (CounterX[10:0] == 1300); // was 39 was 25 ResetCntY <= (CounterY[9:0] ==527); end //signal synchronizer always @(posedge clk) begin vga_h_sync <= ~((CounterX[10:0] >= 1304) && (CounterX[10:0] <= 1493)); vga_v_sync <= ~((CounterY[9:0] == 493) || (CounterY[9:0] == 494 )); Valid <= (((CounterX == 1587) || (CounterX < 1288)) && ((CounterY == 527) || (CounterY < 480 )) ); end

  11. module vgafla_g (TOP) : assign in_text=80'b00000000_00000001_00000010_00000011_00000100_00000101_00000110_00000111_00001000_00001001; /* specify your text here */ wire red0 = Valid && out_scan; wire red1 = Valid && out_scan; wire green0 = Valid && out_scan; wire green1 = Valid && out_scan; wire blue0 = Valid && out_scan; wire blue1 = Valid && out_scan; assign vga_red0 = red0 ? 1'b1 :1'b0; assign vga_green0 = green0 ? 1'b1:1'b0; assign vga_blue0 = blue0 ? 1'b1:1'b0; assign vga_red1 = red1 ? 1'b1: 1'b0; assign vga_green1 = green1 ? 1'b1: 1'b0; assign vga_blue1 = blue1? 1'b1:1'b0 ; :

  12. module genchar `define TOTAL_SCREEN_CHAR 10 /* counted from No 0 */ `define LOG2_TOTAL_SCREEN_CHAR 3 /* floor(Log2 10) = 3 */ `define TOTAL_SUPPORT_CHAR 16 /* now, I only implement characters: 0, 1, 2 */ `define LOG2_TOTAL_SUPPORT_CHAR 3 /* Log2 16 -1 = 3, assume that we can support 16 characters*/ module genchar(CounterX, CounterY, out_scan,in_text); input [9:0] CounterY; input [10:0] CounterX; 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: 00000000 */ /* 1: 00000001 */ /* 2: 00000010 */ /* if we want show 012... => in_text is ".....000000010,00000001,00000000 */

  13. module genchar reg out_scan; reg[`LOG2_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[`LOG2_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] divY; reg[10:0] divX; wire[0:`TOTAL_SUPPORT_CHAR*8-1] line0; wire[0:`TOTAL_SUPPORT_CHAR*8-1] line1; wire[0:`TOTAL_SUPPORT_CHAR*8-1] line2; wire[0:`TOTAL_SUPPORT_CHAR*8-1] line3; wire[0:`TOTAL_SUPPORT_CHAR*8-1] line4; wire[0:`TOTAL_SUPPORT_CHAR*8-1] line5; wire[0:`TOTAL_SUPPORT_CHAR*8-1] line6; wire[0:`TOTAL_SUPPORT_CHAR*8-1] line7; wire[0:`TOTAL_SUPPORT_CHAR*64-1] all_lines;

  14. module genchar wire[0:7] dumy; wire[0:7] c0_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] c0_1; wire[0:7] c0_2; wire[0:7] c0_3; wire[0:7] c0_4; wire[0:7] c0_5; wire[0:7] c0_6; wire[0:7] c0_7; : assign dumy=8'b00000000; assign c0_0=8'b00000000; assign c0_1=8'b11111110; assign c0_2=8'b10000010; assign c0_3=8'b10000010; assign c0_4=8'b10000010; assign c0_5=8'b10000010; assign c0_6=8'b10000010; assign c0_7=8'b11111110; :

  15. module genchar assign line0={c0_0,c1_0,c2_0,c3_0,c4_0,c5_0,c6_0,c7_0,c8_0,c9_0,dumy,dumy,dumy,dumy,dumy,dumy}; /* Only the first 3 records are usable because only 3 characters (0,1,2) are supported now. */ assign line1={c0_1,c1_1,c2_1,c3_1,c4_1,c5_1,c6_1,c7_1,c8_1,c9_1,dumy,dumy,dumy,dumy,dumy,dumy}; assign line2={c0_2,c1_2,c2_2,c3_2,c4_2,c5_2,c6_2,c7_2,c8_2,c9_2,dumy,dumy,dumy,dumy,dumy,dumy}; assign line3={c0_3,c1_3,c2_3,c3_3,c4_3,c5_3,c6_3,c7_3,c8_3,c9_3,dumy,dumy,dumy,dumy,dumy,dumy}; assign line4={c0_4,c1_4,c2_4,c3_4,c4_4,c5_4,c6_4,c7_4,c8_4,c9_4,dumy,dumy,dumy,dumy,dumy,dumy}; assign line5={c0_5,c1_5,c2_5,c3_5,c4_5,c5_5,c6_5,c7_5,c8_5,c9_5,dumy,dumy,dumy,dumy,dumy,dumy}; assign line6={c0_6,c1_6,c2_6,c3_6,c4_6,c5_6,c6_6,c7_6,c8_6,c9_6,dumy,dumy,dumy,dumy,dumy,dumy}; assign line7={c0_7,c1_7,c2_7,c3_7,c4_7,c5_7,c6_7,c7_7,c8_7,c9_7,dumy,dumy,dumy,dumy,dumy,dumy}; assign all_lines={line0,line1,line2,line3,line4,line5,line6,line7};

  16. module genchar always @(CounterX or CounterY or in_text or all_lines) begin out_scan = 0; divY = (CounterY >> 1)-64; divX = (CounterX >> 1)-64; if (divY >= 0 && divY < 8 && divX >= 0 && divX < (`TOTAL_SCREEN_CHAR*8)) begin char_no_on_screen = divX >> 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 = divX - char_no_on_screen_mul_8; /* 0~7 */ line_fac = divY << 7; /* (<< 7) == (* 128) Because each line contains 128 pixels*/ index = char_fac + line_fac + col_fac; out_scan = all_lines[index]; end end

  17. 0 1 2 3 …..9 line0 line1 line7 all_lines • all_lines 2-D Storage 1-D Storage

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

  19. Formula 8*8 col_fac= divX - char_no_on_screen_mul_8 0 1 2 3 …..9 line0 line1 line7 char_fac = char_encode * 8 = 3*8 = 24 Line_fac = divY*128

  20. 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?

  21. tb.v • tb.v (partial code) `timescale 1ns/100ps module tb; reg clock; wire vga_hsync, vga_vsync, vga_red0, vga_green0, vga_blue0, vga_red1, vga_green1, vga_blue1; vgafla_g U1(clock, vga_hsync , vga_vsync, vga_red0, vga_green0, vga_blue0, vga_red1, vga_green1, vga_blue1); initial begin U1.syncVGA.ResetCntX=1; U1.syncVGA.ResetCntY=1; #40 U1.syncVGA.ResetCntX=0; U1.syncVGA.ResetCntY=0; #????; $finish; end : endmodule

  22. Waveform • vga_hsync

  23. Waveform • vga_hsync

  24. Waveform • vga_hsync

  25. Waveform • Valid

  26. Waveform • vga_vsync

  27. Waveform • vga_vsync

  28. Waveform • Valid

  29. Exercise 1 • Draw a Circle • (CounterX-600)*(CounterX-600)+(CounterY-240)*(CounterY-240) < R (0,0) (0,0) R (600,240) (639,479) (1288,479)

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

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

  32. Exercise 2 • Color Ring

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

More Related