// FPGA VGA Graphics Part 1: Top Module (static squares) // (C)2017-2018 Will Green - Licensed under the MIT License // Heavily modified by Jens True // Learn more at https://timetoexplore.net/blog/arty-fpga-vga-verilog-01 `default_nettype none module vgasquare( input wire CLK, // board clock input wire PIXEL_CLK, // Pixel clock: 25Mhz (or 25.125MHz) for VGA input wire RST_BTN, // reset button input wire [9:0] box_x1, input wire [9:0] box_x2, input wire [8:0] box_y1, input wire [8:0] box_y2, input wire [5:0] box_color, //1 bit for each color Foreground and background output wire VGA_HS_O, // horizontal sync output output wire VGA_VS_O, // vertical sync output output wire VGA_R, // 1-bit VGA red output output wire VGA_G, // 1-bit VGA green output output wire VGA_B // 1-bit VGA blue output ); wire rst = ~RST_BTN; // reset is active low on AXI bus wire [9:0] x; // current pixel x position: 10-bit value: 0-1023 wire [8:0] y; // current pixel y position: 9-bit value: 0-511 vga640x480 display ( .i_clk(CLK), .i_pix_stb(PIXEL_CLK), .i_rst(rst), .o_hs(VGA_HS_O), .o_vs(VGA_VS_O), .o_x(x), .o_y(y) ); // Draw one square wire square; assign square = ((x > box_x1) & (y > box_y1) & (x < box_x2) & (y < box_y1)) ? 1 : 0; //Is box within range? assign VGA_R = square ? box_color[0] : box_color[3]; // Set R (Foreground and then background) assign VGA_G = square ? box_color[1] : box_color[4]; // Set G assign VGA_B = square ? box_color[2] : box_color[5]; // Set B endmodule