/******************************************************************************/
/* */
/* Copyright (c) 1999 Sun Microsystems, Inc. All rights reserved. */
/* */
/* The contents of this file are subject to the current version of the Sun */
/* Community Source License, microSPARCII ("the License"). You may not use */
/* this file except in compliance with the License. You may obtain a copy */
/* of the License by searching for "Sun Community Source License" on the */
/* World Wide Web at http://www.sun.com. See the License for the rights, */
/* obligations, and limitations governing use of the contents of this file. */
/* */
/* Sun Microsystems, Inc. has intellectual property rights relating to the */
/* technology embodied in these files. In particular, and without limitation, */
/* these intellectual property rights may include one or more U.S. patents, */
/* foreign patents, or pending applications. */
/* */
/* Sun, Sun Microsystems, the Sun logo, all Sun-based trademarks and logos, */
/* Solaris, Java and all Java-based trademarks and logos are trademarks or */
/* registered trademarks of Sun Microsystems, Inc. in the United States and */
/* other countries. microSPARC is a trademark or registered trademark of */
/* SPARC International, Inc. All SPARC trademarks are used under license and */
/* are trademarks or registered trademarks of SPARC International, Inc. in */
/* the United States and other countries. Products bearing SPARC trademarks */
/* are based upon an architecture developed by Sun Microsystems, Inc. */
/* */
/******************************************************************************/
/***************************************************************************
****************************************************************************
***
*** Program File: @(#)fifo4_4.v
***
*** Description:
*** Implements a 4 deep 4 bit wide fifo for holding the afx byte marks.
***
****************************************************************************
****************************************************************************/
module fifo4_4
( reset, //fifo reset
clock, //fifo clock
data_in, //data in (variable width)
read, //read fifo
write, //write fifo
full_count, //full count
data_out); //fifo data out
// Fifo is 4 entries deep, variable width default is 2 bit
// deviates slightly from the standard fifo in that the full count decrement
// from reads is delayed. This is to take into consideration the asynch
// nature of reading the entries. We need to be able to stream reads while
// the "ack" on reads is delayed for full handling. The decrement signal
// will not be stable until 1/2 way through this clock.
parameter WIDTH = 3;
input reset
;
input clock
;
input [WIDTH:0] data_in
;
input read
;
input write
;
output [2:0] full_count
;
output [WIDTH:0] data_out
;
reg [WIDTH:0] reg0
,reg1
,reg2
,reg3
;
reg [1:0] wr_ptr
, rd_ptr
;
reg [2:0] full_count;
wire [WIDTH:0] data_out = mux4to1(rd_ptr,reg0,reg1,reg2,reg3);
// load fifos and increment of read and write pointers
always @(posedge clock)
begin
if (write & wr_ptr == 2'b00)
reg0 <= #1 data_in;
if (write & wr_ptr == 2'b01)
reg1 <= #1 data_in;
if (write & wr_ptr == 2'b10)
reg2 <= #1 data_in;
if (write & wr_ptr == 2'b11)
reg3 <= #1 data_in;
end
always @(posedge clock)
begin
if (reset)
begin
rd_ptr <= 2'b00;
end
else if (read)
rd_ptr <= #1 (rd_ptr + 2'b01);
end
always @(posedge clock)
begin
if (reset)
begin
wr_ptr <= 2'b00;
end
else if (write)
wr_ptr <= #1 (wr_ptr + 2'b01);
end
// generate full_count; 0 at reset
// increment on write and no read
// decrement on read and no write
// holds on either no read, no write OR read and write
always @(posedge clock)
begin
if (reset )
full_count <= 3'b000;
else if (write & ~read)
full_count <= #1 (full_count + 3'b001);
else if (~write & read)
full_count <= #1 (full_count - 3'b001);
end
function [WIDTH:0] mux4to1;
input [1:0] rd_ptr;
input [WIDTH:0] reg0;
input [WIDTH:0] reg1;
input [WIDTH:0] reg2;
input [WIDTH:0] reg3;
begin
case(rd_ptr)
2'b00: mux4to1 = reg0;
2'b01: mux4to1 = reg1;
2'b10: mux4to1 = reg2;
2'b11: mux4to1 = reg3;
endcase
end
endfunction
endmodule
| This page: |
Created: | Thu Aug 19 12:02:09 1999 |
| From: |
../../../sparc_v8/ssparc/pcic/afx_slave/afx_slave_fifo/rtl/fifo4_4.v
|