Line 48... |
Line 48... |
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
//
|
//
|
// CVS Revision History
|
// CVS Revision History
|
//
|
//
|
// $Log: not supported by cvs2svn $
|
// $Log: not supported by cvs2svn $
|
|
// Revision 1.19 2003/07/03 09:30:44 mohor
|
|
// PCI_BIST replaced with CAN_BIST.
|
|
//
|
// Revision 1.18 2003/06/27 22:14:23 simons
|
// Revision 1.18 2003/06/27 22:14:23 simons
|
// Overrun fifo implemented with FFs, because it is not possible to create such a memory.
|
// Overrun fifo implemented with FFs, because it is not possible to create such a memory.
|
//
|
//
|
// Revision 1.17 2003/06/27 20:56:15 simons
|
// Revision 1.17 2003/06/27 20:56:15 simons
|
// Virtual silicon ram instances added.
|
// Virtual silicon ram instances added.
|
Line 151... |
Line 154... |
|
|
input clk;
|
input clk;
|
input rst;
|
input rst;
|
input wr;
|
input wr;
|
input [7:0] data_in;
|
input [7:0] data_in;
|
input [7:0] addr;
|
input [5:0] addr;
|
input reset_mode;
|
input reset_mode;
|
input release_buffer;
|
input release_buffer;
|
input extended_mode;
|
input extended_mode;
|
input fifo_selected;
|
input fifo_selected;
|
|
|
Line 209... |
Line 212... |
|
|
// Delayed write signal
|
// Delayed write signal
|
always @ (posedge clk or posedge rst)
|
always @ (posedge clk or posedge rst)
|
begin
|
begin
|
if (rst)
|
if (rst)
|
wr_q <= 0;
|
wr_q <=#Tp 1'b0;
|
else if (reset_mode)
|
else if (reset_mode)
|
wr_q <=#Tp 0;
|
wr_q <=#Tp 1'b0;
|
else
|
else
|
wr_q <=#Tp wr;
|
wr_q <=#Tp wr;
|
end
|
end
|
|
|
|
|
// length counter
|
// length counter
|
always @ (posedge clk or posedge rst)
|
always @ (posedge clk or posedge rst)
|
begin
|
begin
|
if (rst)
|
if (rst)
|
len_cnt <= 0;
|
len_cnt <= 4'h0;
|
else if (reset_mode | write_length_info)
|
else if (reset_mode | write_length_info)
|
len_cnt <=#Tp 1'b0;
|
len_cnt <=#Tp 4'h0;
|
else if (wr & (~fifo_full))
|
else if (wr & (~fifo_full))
|
len_cnt <=#Tp len_cnt + 1'b1;
|
len_cnt <=#Tp len_cnt + 1'b1;
|
end
|
end
|
|
|
|
|
// wr_info_pointer
|
// wr_info_pointer
|
always @ (posedge clk or posedge rst)
|
always @ (posedge clk or posedge rst)
|
begin
|
begin
|
if (rst)
|
if (rst)
|
wr_info_pointer <= 0;
|
wr_info_pointer <= 6'h0;
|
else if (write_length_info & (~info_full) | initialize_memories)
|
else if (write_length_info & (~info_full) | initialize_memories)
|
wr_info_pointer <=#Tp wr_info_pointer + 1'b1;
|
wr_info_pointer <=#Tp wr_info_pointer + 1'b1;
|
else if (reset_mode)
|
else if (reset_mode)
|
wr_info_pointer <=#Tp 0;
|
wr_info_pointer <=#Tp 6'h0;
|
end
|
end
|
|
|
|
|
|
|
// rd_info_pointer
|
// rd_info_pointer
|
always @ (posedge clk or posedge rst)
|
always @ (posedge clk or posedge rst)
|
begin
|
begin
|
if (rst)
|
if (rst)
|
rd_info_pointer <= 0;
|
rd_info_pointer <= 6'h0;
|
else if (reset_mode)
|
else if (reset_mode)
|
rd_info_pointer <=#Tp 0;
|
rd_info_pointer <=#Tp 6'h0;
|
else if (release_buffer & (~fifo_empty))
|
else if (release_buffer & (~fifo_empty))
|
rd_info_pointer <=#Tp rd_info_pointer + 1'b1;
|
rd_info_pointer <=#Tp rd_info_pointer + 1'b1;
|
end
|
end
|
|
|
|
|
// rd_pointer
|
// rd_pointer
|
always @ (posedge clk or posedge rst)
|
always @ (posedge clk or posedge rst)
|
begin
|
begin
|
if (rst)
|
if (rst)
|
rd_pointer <= 0;
|
rd_pointer <= 5'h0;
|
else if (release_buffer & (~fifo_empty))
|
else if (release_buffer & (~fifo_empty))
|
rd_pointer <=#Tp rd_pointer + length_info;
|
rd_pointer <=#Tp rd_pointer + {2'h0, length_info};
|
else if (reset_mode)
|
else if (reset_mode)
|
rd_pointer <=#Tp 0;
|
rd_pointer <=#Tp 5'h0;
|
end
|
end
|
|
|
|
|
// wr_pointer
|
// wr_pointer
|
always @ (posedge clk or posedge rst)
|
always @ (posedge clk or posedge rst)
|
begin
|
begin
|
if (rst)
|
if (rst)
|
wr_pointer <= 0;
|
wr_pointer <= 5'h0;
|
else if (wr & (~fifo_full))
|
else if (wr & (~fifo_full))
|
wr_pointer <=#Tp wr_pointer + 1'b1;
|
wr_pointer <=#Tp wr_pointer + 1'b1;
|
else if (reset_mode)
|
else if (reset_mode)
|
wr_pointer <=#Tp 0;
|
wr_pointer <=#Tp 5'h0;
|
end
|
end
|
|
|
|
|
// latch_overrun
|
// latch_overrun
|
always @ (posedge clk or posedge rst)
|
always @ (posedge clk or posedge rst)
|
begin
|
begin
|
if (rst)
|
if (rst)
|
latch_overrun <= 0;
|
latch_overrun <= 1'b0;
|
else if (reset_mode | write_length_info)
|
else if (reset_mode | write_length_info)
|
latch_overrun <=#Tp 0;
|
latch_overrun <=#Tp 1'b0;
|
else if (wr & fifo_full)
|
else if (wr & fifo_full)
|
latch_overrun <=#Tp 1'b1;
|
latch_overrun <=#Tp 1'b1;
|
end
|
end
|
|
|
|
|
// Counting data in fifo
|
// Counting data in fifo
|
always @ (posedge clk or posedge rst)
|
always @ (posedge clk or posedge rst)
|
begin
|
begin
|
if (rst)
|
if (rst)
|
fifo_cnt <= 0;
|
fifo_cnt <= 7'h0;
|
else if (wr & (~release_buffer) & (~fifo_full))
|
else if (wr & (~release_buffer) & (~fifo_full))
|
fifo_cnt <=#Tp fifo_cnt + 1'b1;
|
fifo_cnt <=#Tp fifo_cnt + 1'b1;
|
else if ((~wr) & release_buffer & (~fifo_empty))
|
else if ((~wr) & release_buffer & (~fifo_empty))
|
fifo_cnt <=#Tp fifo_cnt - length_info;
|
fifo_cnt <=#Tp fifo_cnt - {3'h0, length_info};
|
else if (wr & release_buffer & (~fifo_full) & (~fifo_empty))
|
else if (wr & release_buffer & (~fifo_full) & (~fifo_empty))
|
fifo_cnt <=#Tp fifo_cnt - length_info + 1'b1;
|
fifo_cnt <=#Tp fifo_cnt - {3'h0, length_info} + 1'b1;
|
else if (reset_mode)
|
else if (reset_mode)
|
fifo_cnt <=#Tp 0;
|
fifo_cnt <=#Tp 7'h0;
|
end
|
end
|
|
|
assign fifo_full = fifo_cnt == 64;
|
assign fifo_full = fifo_cnt == 7'd64;
|
assign fifo_empty = fifo_cnt == 0;
|
assign fifo_empty = fifo_cnt == 7'd0;
|
|
|
|
|
// Counting data in length_fifo and overrun_info fifo
|
// Counting data in length_fifo and overrun_info fifo
|
always @ (posedge clk or posedge rst)
|
always @ (posedge clk or posedge rst)
|
begin
|
begin
|
if (rst)
|
if (rst)
|
info_cnt <= 0;
|
info_cnt <=#Tp 7'h0;
|
|
else if (reset_mode)
|
|
info_cnt <=#Tp 7'h0;
|
else if (write_length_info ^ release_buffer)
|
else if (write_length_info ^ release_buffer)
|
begin
|
begin
|
if (release_buffer & (~info_empty))
|
if (release_buffer & (~info_empty))
|
info_cnt <=#Tp info_cnt - 1'b1;
|
info_cnt <=#Tp info_cnt - 1'b1;
|
else if (write_length_info & (~info_full))
|
else if (write_length_info & (~info_full))
|
info_cnt <=#Tp info_cnt + 1'b1;
|
info_cnt <=#Tp info_cnt + 1'b1;
|
end
|
end
|
end
|
end
|
|
|
assign info_full = info_cnt == 64;
|
assign info_full = info_cnt == 7'd64;
|
assign info_empty = info_cnt == 0;
|
assign info_empty = info_cnt == 7'd0;
|
|
|
|
|
// Selecting which address will be used for reading data from rx fifo
|
// Selecting which address will be used for reading data from rx fifo
|
always @ (extended_mode or rd_pointer or addr)
|
always @ (extended_mode or rd_pointer or addr)
|
begin
|
begin
|
if (extended_mode) // extended mode
|
if (extended_mode) // extended mode
|
begin
|
read_address = rd_pointer + (addr - 6'd16);
|
read_address <= rd_pointer + (addr - 8'd16);
|
|
end
|
|
else // normal mode
|
else // normal mode
|
begin
|
read_address = rd_pointer + (addr - 6'd20);
|
read_address <= rd_pointer + (addr - 8'd20);
|
|
end
|
|
end
|
end
|
|
|
|
|
always @ (posedge clk or posedge rst)
|
always @ (posedge clk or posedge rst)
|
begin
|
begin
|
if (rst)
|
if (rst)
|
initialize_memories <= 1;
|
initialize_memories <= 1'b1;
|
else if (&wr_info_pointer)
|
else if (&wr_info_pointer)
|
initialize_memories <=#Tp 1'b0;
|
initialize_memories <=#Tp 1'b0;
|
end
|
end
|
|
|
|
|