vga_code
vga_code
module top(
input clk_25M, //int,
input [11:0] dataIn,
output hsynq,
output vsynq,
output [11:0] outData
);
wire enable_v_counter;
wire [15:0] h_count_value;
wire [15:0] v_count_value;
horizontal_counter vga_horiz (clk_25M, enable_v_counter, h_count_value);
vertical_counter vga_verti (clk_25M, enable_v_counter, v_count_value);
assign outData=(h_count_value <784 && h_count_value > 143 && v_count_value < 515 &&
v_count_value>34) ? dataIn:12'h0;
endmodule
module horizontal_counter(
input clk_25M,
output reg enable_v_counter=0,
output reg [15:0] h_count_value=0
);
end
else begin
h_count_value=0;
enable_v_counter=1;
end
end
endmodule
module vertical_counter(
input clk_25M,
input enable_v_counter,
output reg [15:0] v_count_value=0
);
else begin
v_count_value=0;
end
end
end
endmodule
module basic_clk_div(
input clk2,
output reg out25M
);
integer cnt3=0;
integer div=4;
always@(posedge clk2)
begin
cnt3=cnt3+1;
if(cnt3>=1 && cnt3 <=div/2) begin out25M=1; end
if(cnt3>=div/2+1 && cnt3 <=div) begin out25M=0; end
if(cnt3==div) begin cnt3=0; end
end
endmodule