Code: Select all
always @(posedge clk50)
if ( vstart ) //reset address counter at top left of screen
SRAddr <= 0;
else if ( pclk & countflag )
SRAddr <= SRAddr +1; //increment RAM address counter
Code: Select all
always @(posedge clk50)
if ( vstart ) //reset address counter at top left of screen
SRAddr <= 0;
else if ( pclk & countflag )
SRAddr <= SRAddr +1; //increment RAM address counter

Code: Select all
always @(posedge clk50)
if ( pclk ) begin
Red_data <= countflag ? SRDtemp [15:11] : 0; //outgoing data to videoDAC
Green_data <= countflag ? SRDtemp [10:5] : 0;
Blue_data <= countflag ? SRDtemp [4:0] : 0;
end
Code: Select all
module SRAMif( output reg [20:0] SRAddr = 0,
output reg WEn = 1,
output reg SRCS = 1,
input [15:0] SRD,
output reg [4:0] Red_data,
output reg [5:0] Green_data,
output reg [4:0] Blue_data,
output reg DACBLANKn = 1,
input clk50,
input pclk,
input hstart,
input vstart,
input hblank
);
reg [15:0] SRDtemp;
reg countflag;
always @(posedge clk50)
if ( pclk )
if ( hstart )
countflag <= 1; //countflag active in display area
else if ( hblank )
countflag <= 0;
always @(posedge clk50)
if ( vstart ) //reset address counter at top left of screen
SRAddr <= 0;
else if ( countflag )
SRAddr <= SRAddr + 1; //increment RAM address counter
always @(posedge clk50)
if ( pclk & countflag )
begin
SRDtemp <= SRD; //latch incoming data;
Red_data <= hblank ? 0 : SRDtemp [15:11]; //outgoing data to videoDAC
Green_data <= hblank ? 0 : SRDtemp [10:5];
Blue_data <= hblank ? 0 : SRDtemp [4:0];
end
endmodule