Line 40... |
Line 40... |
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
//
|
//
|
// CVS Revision History
|
// CVS Revision History
|
//
|
//
|
// $Log: not supported by cvs2svn $
|
// $Log: not supported by cvs2svn $
|
|
// Revision 1.2 2001/10/05 08:14:30 mihad
|
|
// Updated all files with inclusion of timescale file for simulation purposes.
|
|
//
|
// Revision 1.1.1.1 2001/10/02 15:33:47 mihad
|
// Revision 1.1.1.1 2001/10/02 15:33:47 mihad
|
// New project directory structure
|
// New project directory structure
|
//
|
//
|
//
|
//
|
|
|
/* FIFO_CONTROL module provides read/write address and status generation for
|
/* FIFO_CONTROL module provides read/write address and status generation for
|
FIFOs implemented with standard dual port SRAM cells in ASIC or FPGA designs */
|
FIFOs implemented with standard dual port SRAM cells in ASIC or FPGA designs */
|
`include "constants.v"
|
`include "pci_constants.v"
|
|
// synopsys translate_off
|
`include "timescale.v"
|
`include "timescale.v"
|
`ifdef FPGA
|
// synopsys translate_on
|
// fifo design in FPGA will be synchronous
|
|
`ifdef SYNCHRONOUS
|
|
`else
|
|
`define SYNCHRONOUS
|
|
`endif
|
|
`endif
|
|
|
|
module WBR_FIFO_CONTROL
|
module WBR_FIFO_CONTROL
|
(
|
(
|
rclock_in,
|
rclock_in,
|
wclock_in,
|
wclock_in,
|
Line 133... |
Line 131... |
wire rallow ;
|
wire rallow ;
|
|
|
// clear generation for FFs and registers
|
// clear generation for FFs and registers
|
wire clear = reset_in || flush_in ;
|
wire clear = reset_in || flush_in ;
|
|
|
`ifdef SYNCHRONOUS
|
|
|
|
reg wclock_nempty_detect ;
|
reg wclock_nempty_detect ;
|
always@(posedge reset_in or posedge wclock_in)
|
always@(posedge reset_in or posedge wclock_in)
|
begin
|
begin
|
if (reset_in)
|
if (reset_in)
|
wclock_nempty_detect <= #`FF_DELAY 1'b0 ;
|
wclock_nempty_detect <= #`FF_DELAY 1'b0 ;
|
Line 171... |
Line 167... |
|
|
// address output mux - when FIFO is empty, current actual address is driven out, when it is non - empty next address is driven out
|
// address output mux - when FIFO is empty, current actual address is driven out, when it is non - empty next address is driven out
|
// done for zero wait state burst
|
// done for zero wait state burst
|
assign raddr_out = rallow ? raddr_plus_one : raddr ;
|
assign raddr_out = rallow ? raddr_plus_one : raddr ;
|
|
|
// enable for this register
|
|
wire raddr_plus_one_en = rallow ;
|
|
always@(posedge rclock_in or posedge clear)
|
always@(posedge rclock_in or posedge clear)
|
begin
|
begin
|
if (clear)
|
if (clear)
|
begin
|
begin
|
raddr_plus_one[(ADDR_LENGTH - 1):1] <= #`FF_DELAY { (ADDR_LENGTH - 1){1'b0}} ;
|
// initial value is 3
|
raddr_plus_one[0] <= #`FF_DELAY 1'b1 ;
|
raddr_plus_one <= #`FF_DELAY 3 ;
|
end
|
end
|
else if (raddr_plus_one_en)
|
else if (rallow)
|
raddr_plus_one <= #`FF_DELAY raddr_plus_one + 1'b1 ;
|
raddr_plus_one <= #`FF_DELAY raddr_plus_one + 1'b1 ;
|
end
|
end
|
|
|
// raddr is filled with raddr_plus_one on rising read clock edge when rallow is high
|
// raddr is filled with raddr_plus_one on rising read clock edge when rallow is high
|
always@(posedge rclock_in or posedge clear)
|
always@(posedge rclock_in or posedge clear)
|
begin
|
begin
|
if (clear)
|
if (clear)
|
// initial value is 000......00
|
// initial value is 2
|
raddr <= #`FF_DELAY { ADDR_LENGTH{1'b0}} ;
|
raddr <= #`FF_DELAY 2 ;
|
else if (rallow)
|
else if (rallow)
|
raddr <= #`FF_DELAY raddr_plus_one ;
|
raddr <= #`FF_DELAY raddr_plus_one ;
|
end
|
end
|
|
|
`else
|
|
// asynchronous RAM storage for FIFOs - somewhat simpler control logic
|
|
//rallow generation
|
|
assign rallow = renable_in && ~empty ;
|
|
|
|
assign rallow_out = rallow ;
|
|
|
|
// read address counter - normal counter, nothing to it
|
|
// for asynchronous implementation, there is no need for pointing to next address.
|
|
// On clock edge that read is performed, read address will change and on the next clock edge
|
|
// asynchronous memory will provide next data
|
|
always@(posedge rclock_in or posedge clear)
|
|
begin
|
|
if (clear)
|
|
// initial value is 000......00
|
|
raddr <= #`FF_DELAY { ADDR_LENGTH{1'b0}} ;
|
|
else if (rallow)
|
|
raddr <= #`FF_DELAY raddr + 1'b1 ;
|
|
end
|
|
|
|
assign empty_out = empty ;
|
|
assign raddr_out = raddr ;
|
|
`endif
|
|
|
|
/*-----------------------------------------------------------------------------------------------
|
/*-----------------------------------------------------------------------------------------------
|
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
|
Line 230... |
Line 200... |
// grey code register for read address - represents current Read Address
|
// 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)
|
begin
|
begin
|
// initial value is 100.......01
|
// initial value is 0
|
rgrey_addr[(ADDR_LENGTH - 1)] <= #`FF_DELAY 1'b1 ;
|
rgrey_addr <= #`FF_DELAY 0 ;
|
rgrey_addr[(ADDR_LENGTH - 2):1] <= #`FF_DELAY { (ADDR_LENGTH - 2){1'b0} } ;
|
|
rgrey_addr[0] <= #`FF_DELAY 1'b1 ;
|
|
end
|
end
|
else
|
else
|
if (rallow)
|
if (rallow)
|
rgrey_addr <= #`FF_DELAY rgrey_next ;
|
rgrey_addr <= #`FF_DELAY rgrey_next ;
|
end
|
end
|
Line 245... |
Line 213... |
// grey code register for next read address - represents Grey Code of next read address
|
// grey code register for next read address - represents Grey Code of next read address
|
always@(posedge rclock_in or posedge clear)
|
always@(posedge rclock_in or posedge clear)
|
begin
|
begin
|
if (clear)
|
if (clear)
|
begin
|
begin
|
// initial value is 100......00
|
// initial value is 1
|
rgrey_next[(ADDR_LENGTH - 1)] <= #`FF_DELAY 1'b1 ;
|
rgrey_next <= #`FF_DELAY 1 ;
|
rgrey_next[(ADDR_LENGTH - 2):0] <= #`FF_DELAY { (ADDR_LENGTH - 1){1'b0} } ;
|
|
end
|
end
|
else
|
else
|
if (rallow)
|
if (rallow)
|
rgrey_next <= #`FF_DELAY {raddr[ADDR_LENGTH - 1], calc_rgrey_next} ;
|
rgrey_next <= #`FF_DELAY {raddr[ADDR_LENGTH - 1], calc_rgrey_next} ;
|
end
|
end
|
Line 264... |
Line 231... |
// grey code register for write address
|
// grey code register for write address
|
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 100.....001
|
// initial value is 0
|
wgrey_addr[(ADDR_LENGTH - 1)] <= #`FF_DELAY 1'b1 ;
|
wgrey_addr <= #`FF_DELAY 0 ;
|
wgrey_addr[(ADDR_LENGTH - 2):1] <= #`FF_DELAY { (ADDR_LENGTH - 2){1'b0} } ;
|
|
wgrey_addr[0] <= #`FF_DELAY 1'b1 ;
|
|
end
|
end
|
else
|
else
|
if (wallow)
|
if (wallow)
|
wgrey_addr <= #`FF_DELAY wgrey_next ;
|
wgrey_addr <= #`FF_DELAY wgrey_next ;
|
end
|
end
|
Line 279... |
Line 244... |
// grey code register for next write address
|
// grey code register for next write address
|
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 100......00
|
// initial value is 1
|
wgrey_next[(ADDR_LENGTH - 1)] <= #`FF_DELAY 1'b1 ;
|
wgrey_next <= #`FF_DELAY 1 ;
|
wgrey_next[(ADDR_LENGTH - 2):0] <= #`FF_DELAY { (ADDR_LENGTH - 1){1'b0} } ;
|
|
end
|
end
|
else
|
else
|
if (wallow)
|
if (wallow)
|
wgrey_next <= #`FF_DELAY {waddr[(ADDR_LENGTH - 1)], calc_wgrey_next} ;
|
wgrey_next <= #`FF_DELAY {waddr[(ADDR_LENGTH - 1)], calc_wgrey_next} ;
|
end
|
end
|
|
|
// write address counter - nothing special
|
// 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)
|
// initial value 00.........00
|
// initial value is 2
|
waddr <= #`FF_DELAY { (ADDR_LENGTH){1'b0} } ;
|
waddr <= #`FF_DELAY 2 ;
|
else
|
else
|
if (wallow)
|
if (wallow)
|
waddr <= #`FF_DELAY waddr + 1'b1 ;
|
waddr <= #`FF_DELAY waddr + 1'b1 ;
|
end
|
end
|
|
|