1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2024-12-23 03:29:39 +00:00

updated presets

This commit is contained in:
Steven Hugg 2018-01-13 14:48:58 -06:00
parent 45756f682d
commit a456f3d9cf

View File

@ -2,55 +2,58 @@
`define HVSYNC_GENERATOR_H `define HVSYNC_GENERATOR_H
module hvsync_generator( module hvsync_generator(
clk, reset, hsync, vsync, display_on, hpos, vpos); input clk,
input reset,
input clk; output hsync, vsync,
input reset; output display_on,
output reg hsync, vsync; output [8:0] hpos,
output reg display_on; output [8:0] vpos
output reg [8:0] hpos; );
output reg [8:0] vpos;
// constant declarations for TV-simulator sync parameters // constant declarations for TV-simulator sync parameters
localparam H_DISPLAY = 256; // horizontal display area localparam H_DISPLAY = 256; // horizontal display width
localparam H_L_BORDER = 23; // horizontal left border (back porch) localparam H_BACK = 23; // horizontal left border (back porch)
localparam H_R_BORDER = 7; // horizontal right border (front porch) localparam H_FRONT = 7; // horizontal right border (front porch)
localparam H_RETRACE = 23; // horizontal retrace (sync) localparam H_SYNC = 23; // horizontal sync width
localparam H_MAX = H_DISPLAY + H_L_BORDER + H_R_BORDER + H_RETRACE - 1; localparam H_SYNC_START = H_DISPLAY + H_FRONT;
localparam START_H_RETRACE = H_DISPLAY + H_R_BORDER; localparam H_SYNC_END = H_DISPLAY + H_FRONT + H_SYNC - 1;
localparam END_H_RETRACE = H_DISPLAY + H_R_BORDER + H_RETRACE - 1; localparam H_MAX = H_DISPLAY + H_BACK + H_FRONT + H_SYNC - 1;
localparam V_DISPLAY = 240; // vertical display area localparam V_DISPLAY = 240; // vertical display height
localparam V_T_BORDER = 4; // vertical top border localparam V_TOP = 5; // vertical top border
localparam V_B_BORDER = 14; // vertical bottom border localparam V_BOTTOM = 14; // vertical bottom border
localparam V_RETRACE = 4; // vertical retrace (sync) localparam V_SYNC = 3; // vertical sync # lines
localparam V_MAX = V_DISPLAY + V_T_BORDER + V_B_BORDER + V_RETRACE - 1; localparam V_SYNC_START = V_DISPLAY + V_BOTTOM;
localparam START_V_RETRACE = V_DISPLAY + V_B_BORDER; localparam V_SYNC_END = V_DISPLAY + V_BOTTOM + V_SYNC - 1;
localparam END_V_RETRACE = V_DISPLAY + V_B_BORDER + V_RETRACE - 1; localparam V_MAX = V_DISPLAY + V_TOP + V_BOTTOM + V_SYNC - 1;
wire hmaxxed = (hpos == H_MAX) || reset; wire hmaxxed = (hpos == H_MAX) || reset;
wire vmaxxed = (vpos == V_MAX) || reset; wire vmaxxed = (vpos == V_MAX) || reset;
// increment horizontal position counter // increment horizontal position counter
always @(posedge clk) always @(posedge clk)
begin
if(hmaxxed) if(hmaxxed)
hpos <= 0; hpos <= 0;
else else
hpos <= hpos + 1; hpos <= hpos + 1;
end;
// increment vertical position counter // increment vertical position counter
always @(posedge clk) always @(posedge clk)
begin
if(hmaxxed) if(hmaxxed)
if (!vmaxxed) if (!vmaxxed)
vpos <= vpos + 1; vpos <= vpos + 1;
else else
vpos <= 0; vpos <= 0;
end;
// compute hsync + vsync + display_on signals // compute hsync + vsync + display_on signals
always @(posedge clk) always @(posedge clk)
begin begin
hsync <= (hpos>=START_H_RETRACE && hpos<=END_H_RETRACE); hsync <= (hpos>=H_SYNC_START && hpos<=H_SYNC_END);
vsync <= (vpos==START_V_RETRACE); vsync <= (vpos>=V_SYNC_START && vpos<=V_SYNC_END);
display_on <= (hpos<H_DISPLAY) && (vpos<V_DISPLAY); display_on <= (hpos<H_DISPLAY) && (vpos<V_DISPLAY);
end end