From f9740139a6898aa8c37ba6123a6f1492d655abcb Mon Sep 17 00:00:00 2001 From: Ryan Berg Date: Sat, 5 Dec 2015 17:58:08 -0500 Subject: [PATCH] in progress AV commit --- Nexys4Game/src/hdl/AV_block.v | 43 +++++++++++++++++++++++ Nexys4Game/src/hdl/AV_integrator.v | 50 +++++++++++++++++++++++++++ Nexys4Game/src/hdl/AV_menu_graphics.v | 25 ++++++++++++++ Nexys4Game/src/hdl/nexys4_game.v | 11 +++++- Nexys4Game/src/hdl/xvga.v | 38 ++++++++++++++++++++ 5 files changed, 166 insertions(+), 1 deletion(-) create mode 100644 Nexys4Game/src/hdl/AV_integrator.v create mode 100644 Nexys4Game/src/hdl/AV_menu_graphics.v create mode 100644 Nexys4Game/src/hdl/xvga.v diff --git a/Nexys4Game/src/hdl/AV_block.v b/Nexys4Game/src/hdl/AV_block.v index aa0d978..7e23a1e 100644 --- a/Nexys4Game/src/hdl/AV_block.v +++ b/Nexys4Game/src/hdl/AV_block.v @@ -1,8 +1,51 @@ module AV_block( + input clk, + input clk65, + input pause, + output [3:0] VGA_R, + output [3:0] VGA_G, + output [3:0] VGA_B, + output VGA_HS, + output VGA_VS + ); + + wire [10:0] hcount; + wire [9:0] vcount; + + wire [12:0] menu_pixel; + + xvga xvga( + .vclock(clk65), + .hcount(hcount), + .vcount(vcount), + .vsync(VGA_VS), + .hsync(VGA_HS), + .blank(), + ); + + AV_integrator integrator( + .clk65(clk65), + .menu_pixel(menu_pixel), + .score_pixel(), + .string1_pixel(), + .string2_pixel(), + .string3_pixel(), + .string4_pixel(), + .string5_pixel(), + .string6_pixel(), + .bg_pixel(), + .pixel( {VGA_R, VGA_G, VGA_B} ) + ); + AV_menu_graphics menu( + .clk65(clk65), + .pause(pause), + .hcount(hcount), + .vcount(vcount), + .menu_pixel(menu_pixel) ); endmodule \ No newline at end of file diff --git a/Nexys4Game/src/hdl/AV_integrator.v b/Nexys4Game/src/hdl/AV_integrator.v new file mode 100644 index 0000000..330ecf0 --- /dev/null +++ b/Nexys4Game/src/hdl/AV_integrator.v @@ -0,0 +1,50 @@ +module AV_integrator( + input clk65, + + input [12:0] menu_pixel, + input [12:0] score_pixel, + input [12:0] string1_pixel, //MSB is whether or not to use the pixel + input [12:0] string2_pixel, + input [12:0] string3_pixel, + input [12:0] string4_pixel, + input [12:0] string5_pixel, + input [12:0] string6_pixel, + + input [11:0] bg_pixel, + + output reg [11:0] pixel + + + ); + + always @(posedge clk65) begin //maybe make this assign and wires instead? + + if( menu_pixel[12] == 1'b1 ) begin + pixel <= menu_pixel[11:0]; + end + else if( score_pixel[12] == 1'b1 ) begin + pixel <= score_pixel[11:0]; + end + else if( string1_pixel[12] == 1'b1 ) begin + pixel <= string1_pixel[11:0]; + end + else if( string2_pixel[12] == 1'b1 ) begin + pixel <= string2_pixel[11:0]; + end + else if( string3_pixel[12] == 1'b1 ) begin + pixel <= string3_pixel[11:0]; + end + else if( string4_pixel[12] == 1'b1 ) begin + pixel <= string4_pixel[11:0]; + end + else if( string5_pixel[12] == 1'b1 ) begin + pixel <= string5_pixel[11:0]; + end + else if( string6_pixel[12] == 1'b1 ) begin + pixel <= string6_pixel[11:0]; + end + else pixel <= bg_pixel[11:0]; + + end + +endmodule \ No newline at end of file diff --git a/Nexys4Game/src/hdl/AV_menu_graphics.v b/Nexys4Game/src/hdl/AV_menu_graphics.v new file mode 100644 index 0000000..551e07d --- /dev/null +++ b/Nexys4Game/src/hdl/AV_menu_graphics.v @@ -0,0 +1,25 @@ +module AV_menu_graphics( + input clk65, + input pause, + input [10:0] hcount, + input [9:0] vcount, + + output [12:0] menu_pixel + ); + + localparam WIDTH = 800; + localparam HEIGHT = 600; + localparam COLOR = 12'hD_D_D; + localparam startX = 100; + localparam startY = 50; + + + always @(posedge clk65) begin + if( hcount >= startX && hcount < (startX + WIDTH) && + vcount >= startY && vcount < (startY + HEIGHT)) + menu_pixel = {pause, COLOR}; + else menu_pixel = 0; + + end + +endmodule \ No newline at end of file diff --git a/Nexys4Game/src/hdl/nexys4_game.v b/Nexys4Game/src/hdl/nexys4_game.v index dbb3227..df90a22 100644 --- a/Nexys4Game/src/hdl/nexys4_game.v +++ b/Nexys4Game/src/hdl/nexys4_game.v @@ -37,6 +37,9 @@ module nexys4_game( wire CLK25MHZ; clock_4divider clk_divider(.clk(CLK100MHZ),.clk_div(CLK25MHZ)); + wire CLK65MHZ; + clk_wiz_65 clk_65(.clk_in(CLK100MHZ),.clk_out(CLK_65MHZ)); + // INSTANTIATE SEVEN SEGMENT DISPLAY wire [31:0] seg_data; wire [6:0] segments; @@ -108,7 +111,13 @@ module nexys4_game( ); AV_block AV( - + .clk(CLK100MHZ), + .clk65(CLK65MHZ), + .VGA_R(VGA_R), + .VGA_G(VGA_G), + .VGA_B(VGA_B), + .VGA_HS(VGA_HS), + .VGA_VS(VGA_VS) diff --git a/Nexys4Game/src/hdl/xvga.v b/Nexys4Game/src/hdl/xvga.v new file mode 100644 index 0000000..31d34d0 --- /dev/null +++ b/Nexys4Game/src/hdl/xvga.v @@ -0,0 +1,38 @@ +module xvga(input vclock, + output reg [10:0] hcount, // pixel number on current line + output reg [9:0] vcount, // line number + output reg vsync,hsync,blank); + + // horizontal: 1344 pixels total + // display 1024 pixels per line + reg hblank,vblank; + wire hsyncon,hsyncoff,hreset,hblankon; + assign hblankon = (hcount == 1023); + assign hsyncon = (hcount == 1047); + assign hsyncoff = (hcount == 1183); + assign hreset = (hcount == 1343); + + // vertical: 806 lines total + // display 768 lines + wire vsyncon,vsyncoff,vreset,vblankon; + assign vblankon = hreset & (vcount == 767); + assign vsyncon = hreset & (vcount == 776); + assign vsyncoff = hreset & (vcount == 782); + assign vreset = hreset & (vcount == 805); + + // sync and blanking + wire next_hblank,next_vblank; + assign next_hblank = hreset ? 0 : hblankon ? 1 : hblank; + assign next_vblank = vreset ? 0 : vblankon ? 1 : vblank; + always @(posedge vclock) begin + hcount <= hreset ? 0 : hcount + 1; + hblank <= next_hblank; + hsync <= hsyncon ? 0 : hsyncoff ? 1 : hsync; // active low + + vcount <= hreset ? (vreset ? 0 : vcount + 1) : vcount; + vblank <= next_vblank; + vsync <= vsyncon ? 0 : vsyncoff ? 1 : vsync; // active low + + blank <= next_vblank | (next_hblank & ~hreset); + end +endmodule \ No newline at end of file