data/full_repos/permissive/138243369/vgaout.v
data/verilator_xmls/d4d8ec97-20cb-4e17-8916-720ce0d73fe6.xml
module vgaout(
input wire sysclk,
input wire [2:0] pixel_data,
input wire rst,
output reg [21:0] pixel_addr,
output wire VGA_R,
output wire VGA_G,
output wire VGA_B,
output wire VGA_HS,
output wire VGA_VS);

wire pclk;
reg count;
reg [10:0] x_counter, y_counter;

reg [2:0] pixel_rgb;

initial begin
	count = 0;
	x_counter = 0;
	y_counter = 0;
	pixel_rgb = 3'b000;
end


assign pclk = count;
always @(posedge sysclk or posedge rst) begin
	if (rst) begin
		count <= 0;
	end
	else begin
		count <= ~count;
	end
end

always @(posedge pclk or posedge rst) begin
	if (rst) begin
		x_counter <= 0;
		y_counter <= 0;
	end
	else begin

		pixel_addr <= {x_counter, y_counter};
		pixel_rgb <= pixel_data;

		if (x_counter == 800) begin
			x_counter <= 0;
			if (y_counter == 521) begin
				y_counter <= 0;
			end
			else begin
				y_counter <= y_counter + 1;
			end
		end
		else
			x_counter <= x_counter + 1;
	end
end


assign VGA_R = pixel_rgb[2] && (x_counter > 151 && x_counter < 791) && (y_counter > 36 && y_counter < 516);
assign VGA_G = pixel_rgb[1] && (x_counter > 151 && x_counter < 791) && (y_counter > 36 && y_counter < 516);
assign VGA_B = pixel_rgb[0] && (x_counter > 151 && x_counter < 791) && (y_counter > 36 && y_counter < 516);

assign VGA_HS = (x_counter < 8 || x_counter > 103);

assign VGA_VS = (y_counter < 2 || y_counter > 3);

endmodule
module vgaout(
input wire sysclk,
input wire [2:0] pixel_data,
input wire rst,
output reg [21:0] pixel_addr,
output wire VGA_R,
output wire VGA_G,
output wire VGA_B,
output wire VGA_HS,
output wire VGA_VS);


wire pclk;
reg count;
reg [10:0] x_counter, y_counter;

reg [2:0] pixel_rgb;

initial begin
	count = 0;
	x_counter = 0;
	y_counter = 0;
	pixel_rgb = 3'b000;
end


assign pclk = count;
always @(posedge sysclk or posedge rst) begin
	if (rst) begin
		count <= 0;
	end
	else begin
		count <= ~count;
	end
end

always @(posedge pclk or posedge rst) begin
	if (rst) begin
		x_counter <= 0;
		y_counter <= 0;
	end
	else begin

		pixel_addr <= {x_counter, y_counter};
		pixel_rgb <= pixel_data;

		if (x_counter == 800) begin
			x_counter <= 0;
			if (y_counter == 521) begin
				y_counter <= 0;
			end
			else begin
				y_counter <= y_counter + 1;
			end
		end
		else
			x_counter <= x_counter + 1;
	end
end


assign VGA_R = pixel_rgb[2] && (x_counter > 151 && x_counter < 791) && (y_counter > 36 && y_counter < 516);
assign VGA_G = pixel_rgb[1] && (x_counter > 151 && x_counter < 791) && (y_counter > 36 && y_counter < 516);
assign VGA_B = pixel_rgb[0] && (x_counter > 151 && x_counter < 791) && (y_counter > 36 && y_counter < 516);

assign VGA_HS = (x_counter < 8 || x_counter > 103);

assign VGA_VS = (y_counter < 2 || y_counter > 3);

endmodule