go-board-code/vga_sync_pulse_generator.v

35 lines
870 B
Coq
Raw Normal View History

2024-07-06 18:51:29 +00:00
// Remember, this "magically works" on the Go Board.
// If you're using a different clock speed, you need to
// do a different thing here.
module VGA_Sync_Pulse_Generator (
input i_Clk,
output o_HSync,
output o_VSync,
output reg [$clog2(TOTAL_COLUMNS)-1:0] o_rawX,
output reg [$clog2(TOTAL_ROWS)-1:0] o_rawY
);
// remember overscan
parameter ACTIVE_COLUMNS = 640;
parameter ACTIVE_ROWS = 480;
parameter TOTAL_COLUMNS = 800;
parameter TOTAL_ROWS = 525;
always @(posedge i_Clk) begin
if (o_rawX == TOTAL_COLUMNS - 1) begin
o_rawX <= 0;
if (o_rawY == TOTAL_ROWS - 1) begin
o_rawY <= 0;
end else begin
o_rawY <= o_rawY + 1;
end
end else begin
o_rawX <= o_rawX + 1;
end
end
assign o_HSync = (o_rawX < ACTIVE_COLUMNS) ? 1 : 0;
assign o_VSync = (o_rawY < ACTIVE_ROWS) ? 1 : 0;
endmodule