Line 40... |
Line 40... |
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
//
|
//
|
// CVS Revision History
|
// CVS Revision History
|
//
|
//
|
// $Log: not supported by cvs2svn $
|
// $Log: not supported by cvs2svn $
|
|
// Revision 1.5 2002/09/30 16:03:04 mihad
|
|
// Added meta flop module for easier meta stable FF identification during synthesis
|
|
//
|
// Revision 1.4 2002/09/25 15:53:52 mihad
|
// Revision 1.4 2002/09/25 15:53:52 mihad
|
// Removed all logic from asynchronous reset network
|
// Removed all logic from asynchronous reset network
|
//
|
//
|
// Revision 1.3 2002/02/01 15:25:13 mihad
|
// Revision 1.3 2002/02/01 15:25:13 mihad
|
// Repaired a few bugs, updated specification, added test bench files and design document
|
// Repaired a few bugs, updated specification, added test bench files and design document
|
Line 182... |
Line 185... |
assign raddr_out = rallow ? raddr_plus_one : raddr ;
|
assign raddr_out = rallow ? raddr_plus_one : raddr ;
|
|
|
always@(posedge rclock_in or posedge clear)
|
always@(posedge rclock_in or posedge clear)
|
begin
|
begin
|
if (clear)
|
if (clear)
|
// initial value is 3
|
|
raddr_plus_one <= #`FF_DELAY 3 ;
|
|
else if (flush_in)
|
|
raddr_plus_one <= #`FF_DELAY waddr + 1'b1 ; // when read fifo is flushed, values from write side are copied to read side
|
|
else if (rallow)
|
|
raddr_plus_one <= #`FF_DELAY raddr_plus_one + 1'b1 ;
|
|
end
|
|
|
|
// raddr is filled with raddr_plus_one on rising read clock edge when rallow is high
|
|
always@(posedge rclock_in or posedge clear)
|
|
begin
|
begin
|
if (clear)
|
raddr_plus_one <= #`FF_DELAY 3 ;
|
// initial value is 2
|
|
raddr <= #`FF_DELAY 2 ;
|
raddr <= #`FF_DELAY 2 ;
|
|
end
|
else if (flush_in)
|
else if (flush_in)
|
raddr <= #`FF_DELAY waddr ; // when flushed, copy value from write side
|
begin
|
|
raddr_plus_one <= #`FF_DELAY waddr + 1'b1 ;
|
|
raddr <= #`FF_DELAY waddr ;
|
|
end
|
else if (rallow)
|
else if (rallow)
|
|
begin
|
|
raddr_plus_one <= #`FF_DELAY raddr_plus_one + 1'b1 ;
|
raddr <= #`FF_DELAY raddr_plus_one ;
|
raddr <= #`FF_DELAY raddr_plus_one ;
|
end
|
end
|
|
end
|
|
|
/*-----------------------------------------------------------------------------------------------
|
/*-----------------------------------------------------------------------------------------------
|
Read address control consists of Read address counter and Grey Address pipeline
|
Read address control consists of Read address counter and Grey Address pipeline
|
There are 3 Grey addresses:
|
There are 3 Grey addresses:
|
- rgrey_addr is Grey Code of current read address
|
- rgrey_addr is Grey Code of current read address
|
- rgrey_next is Grey Code of next read address
|
- rgrey_next is Grey Code of next read address
|
--------------------------------------------------------------------------------------------------*/
|
--------------------------------------------------------------------------------------------------*/
|
|
// grey coded address pipeline for status generation in read clock domain
|
// grey code register for read address - represents current Read Address
|
|
always@(posedge rclock_in or posedge clear)
|
always@(posedge rclock_in or posedge clear)
|
begin
|
begin
|
if (clear)
|
if (clear)
|
// initial value is 0
|
|
rgrey_addr <= #`FF_DELAY 0 ;
|
|
else if (flush_in)
|
|
rgrey_addr <= #`FF_DELAY wgrey_addr ; // when flushed, copy value from write side
|
|
else if (rallow)
|
|
rgrey_addr <= #`FF_DELAY rgrey_next ;
|
|
end
|
|
|
|
// grey code register for next read address - represents Grey Code of next read address
|
|
always@(posedge rclock_in or posedge clear)
|
|
begin
|
begin
|
if (clear)
|
rgrey_addr <= #`FF_DELAY 0 ;
|
// initial value is 1
|
|
rgrey_next <= #`FF_DELAY 1 ;
|
rgrey_next <= #`FF_DELAY 1 ;
|
|
end
|
else if (flush_in)
|
else if (flush_in)
|
|
begin
|
|
rgrey_addr <= #`FF_DELAY wgrey_addr ; // when flushed, copy value from write side
|
rgrey_next <= #`FF_DELAY wgrey_next ;
|
rgrey_next <= #`FF_DELAY wgrey_next ;
|
|
end
|
else if (rallow)
|
else if (rallow)
|
|
begin
|
|
rgrey_addr <= #`FF_DELAY rgrey_next ;
|
rgrey_next <= #`FF_DELAY {raddr[ADDR_LENGTH - 1], calc_rgrey_next} ;
|
rgrey_next <= #`FF_DELAY {raddr[ADDR_LENGTH - 1], calc_rgrey_next} ;
|
end
|
end
|
|
end
|
|
|
/*--------------------------------------------------------------------------------------------
|
/*--------------------------------------------------------------------------------------------
|
Write address control consists of write address counter and two Grey Code Registers:
|
Write address control consists of write address counter and two Grey Code Registers:
|
- wgrey_addr represents current Grey Coded write address
|
- wgrey_addr represents current Grey Coded write address
|
- wgrey_next represents Grey Coded next write address
|
- wgrey_next represents Grey Coded next write address
|
----------------------------------------------------------------------------------------------*/
|
----------------------------------------------------------------------------------------------*/
|
// grey code register for write address
|
// grey coded address pipeline for status generation in write clock domain
|
always@(posedge wclock_in or posedge clear)
|
always@(posedge wclock_in or posedge clear)
|
begin
|
begin
|
if (clear)
|
if (clear)
|
begin
|
begin
|
// initial value is 0
|
|
wgrey_addr <= #`FF_DELAY 0 ;
|
wgrey_addr <= #`FF_DELAY 0 ;
|
end
|
|
else
|
|
if (wallow)
|
|
wgrey_addr <= #`FF_DELAY wgrey_next ;
|
|
end
|
|
|
|
// grey code register for next write address
|
|
always@(posedge wclock_in or posedge clear)
|
|
begin
|
|
if (clear)
|
|
begin
|
|
// initial value is 1
|
|
wgrey_next <= #`FF_DELAY 1 ;
|
wgrey_next <= #`FF_DELAY 1 ;
|
end
|
end
|
else
|
else
|
if (wallow)
|
if (wallow)
|
|
begin
|
|
wgrey_addr <= #`FF_DELAY wgrey_next ;
|
wgrey_next <= #`FF_DELAY {waddr[(ADDR_LENGTH - 1)], calc_wgrey_next} ;
|
wgrey_next <= #`FF_DELAY {waddr[(ADDR_LENGTH - 1)], calc_wgrey_next} ;
|
end
|
end
|
|
end
|
|
|
// write address counter - nothing special except initial value
|
// write address counter - nothing special except initial value
|
always@(posedge wclock_in or posedge clear)
|
always@(posedge wclock_in or posedge clear)
|
begin
|
begin
|
if (clear)
|
if (clear)
|