LARGE pic.
Code: Select all
module VDACif( input clk108,
input hstart,
input vstart,
input hblank,
input vblank,
input VSYNCout,
output reg [4:0] Red_data = 0,
output reg [5:0] Green_data = 0,
output reg [4:0] Blue_data = 0,
output reg DACBLANKn = 1
);
reg countflag;
reg [9:0] X = 0;
reg [8:0] Y = 0;
parameter
Xmax = 640,
Ymax = 480;
always @(posedge clk108)
if ( hstart )
countflag <= 1; //countflag active in display area
else if ( hblank )
countflag <= 0;
always @(posedge clk108)
if ( countflag )
X <= X + 1; //count inside the border
else
X <= 0;
always @(posedge clk108)
if ( X == Xmax )
Y <= Y + 1;
else if ( Y == Ymax )
Y <= 0;
always @(posedge clk108) //outgoing data to videoDAC
if ( countflag & (( X == 0 & Y == 0 ) | ( X == 639 & Y == 479 ))) begin
Red_data <= 0;
Green_data <= 6'b111111;
Blue_data <= 0; //Priority 1, plot green pixel at Min & Max corners
end
else if ( vblank & VSYNCout ) begin
Red_data <= 0;
Green_data <= 0;
Blue_data <= 0; //Priority 2, send black during vertical retrace
end
else if ( !countflag ) begin
Red_data <= 0;
Green_data <= 0;
Blue_data <= 5'b11111; //Priority 3, blue border
end
else if ( X[0] ) begin
Red_data <= 5'b11111;
Green_data <= 0;
Blue_data <= 0; //Priority 4, odd pixels red
end
else begin
Red_data <= 0;
Green_data <= 0;
Blue_data <= 5'b11111; // even pixels blue
end
endmodule