OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [orpsocv2/] [rtl/] [verilog/] [ethmac/] [eth_fifo.v] - Diff between revs 409 and 439

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 409 Rev 439
Line 5... Line 5...
////  This file is part of the Ethernet IP core project           ////
////  This file is part of the Ethernet IP core project           ////
////  http://www.opencores.org/project,ethmac                   ////
////  http://www.opencores.org/project,ethmac                   ////
////                                                              ////
////                                                              ////
////  Author(s):                                                  ////
////  Author(s):                                                  ////
////      - Igor Mohor (igorM@opencores.org)                      ////
////      - Igor Mohor (igorM@opencores.org)                      ////
 
////      - Julius Baxter (julius@opencores.org)                  ////
////                                                              ////
////                                                              ////
////  All additional information is avaliable in the Readme.txt   ////
////  All additional information is avaliable in the Readme.txt   ////
////  file.                                                       ////
////  file.                                                       ////
////                                                              ////
////                                                              ////
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
Line 35... Line 36...
//// You should have received a copy of the GNU Lesser General    ////
//// You should have received a copy of the GNU Lesser General    ////
//// Public License along with this source; if not, download it   ////
//// Public License along with this source; if not, download it   ////
//// from http://www.opencores.org/lgpl.shtml                     ////
//// from http://www.opencores.org/lgpl.shtml                     ////
////                                                              ////
////                                                              ////
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
//
 
// CVS Revision History
 
//
 
// $Log: not supported by cvs2svn $
 
// Revision 1.3  2002/04/22 13:45:52  mohor
 
// Generic ram or Xilinx ram can be used in fifo (selectable by setting
 
// ETH_FIFO_XILINX in ethmac_defines.v).
 
//
 
// Revision 1.2  2002/03/25 13:33:04  mohor
 
// When clear and read/write are active at the same time, cnt and pointers are
 
// set to 1.
 
//
 
// Revision 1.1  2002/02/05 16:44:39  mohor
 
// Both rx and tx part are finished. Tested with wb_clk_i between 10 and 200
 
// MHz. Statuses, overrun, control frame transmission and reception still  need
 
// to be fixed.
 
//
 
//
 
 
 
`include "ethmac_defines.v"
`include "ethmac_defines.v"
`include "timescale.v"
`include "timescale.v"
 
 
module eth_fifo (data_in, data_out, clk, reset, write, read, clear, almost_full, full, almost_empty, empty, cnt);
module eth_fifo (data_in, data_out, clk, reset, write, read, clear,
 
                 almost_full, full, almost_empty, empty, cnt);
 
 
parameter DATA_WIDTH    = 32;
parameter DATA_WIDTH    = 32;
parameter DEPTH         = 8;
parameter DEPTH         = 8;
parameter CNT_WIDTH     = 4;
parameter CNT_WIDTH     = 3;
 
 
input                     clk;
input                     clk;
input                     reset;
input                     reset;
input                     write;
input                     write;
input                     read;
input                     read;
Line 92... Line 76...
  if(clear)
  if(clear)
    cnt <= { {(CNT_WIDTH-1){1'b0}}, read^write};
    cnt <= { {(CNT_WIDTH-1){1'b0}}, read^write};
  else
  else
  if(read ^ write)
  if(read ^ write)
    if(read)
    if(read)
      cnt <= cnt - 1'b1;
      cnt <= cnt - 1;
    else
    else
      cnt <= cnt + 1'b1;
      cnt <= cnt + 1;
end
end
 
 
 
 
`ifdef ETH_FIFO_GENERIC
`ifdef ETH_FIFO_GENERIC
 
 
   reg     [DATA_WIDTH-1:0]  fifo  [0:DEPTH-1] /*synthesis syn_ramstyle = "no_rw_check"*/ ;
   reg     [DATA_WIDTH-1:0]  fifo  [0:DEPTH-1] /*synthesis syn_ramstyle = "no_rw_check"*/ ;
 
 
 
 
   // This should make the synthesis tool infer RAMs
   // This should make the synthesis tool infer a RAM
   reg [CNT_WIDTH-2:0] waddr, raddr, raddr_reg;
   reg [CNT_WIDTH-1:0] waddr, raddr, raddr_reg;
   reg                 clear_reg; // Register the clear pulse   
   reg                 clear_reg; // Register the clear pulse   
 
 
 
   reg                 fallthrough_read;
 
   reg [CNT_WIDTH-1:0] fallthrough_read_addr;
 
 
 
 
 
   always @(posedge clk)
 
     if (reset)
 
       fallthrough_read <= 0;
 
     else
 
       fallthrough_read <= empty & write;
 
 
 
   always @(posedge clk)
 
     if (empty & write)
 
       fallthrough_read_addr <= waddr;
 
 
   always @(posedge clk)
   always @(posedge clk)
     if (reset)
     if (reset)
       waddr <= 0;
       waddr <= 0;
     else if (write)
     else if (write)
       waddr <= waddr + 1;
       waddr <= waddr + 1;
 
 
   wire                raddr_reg_adv;
 
   reg                 read_reg;
   reg                 read_reg;
   always @(posedge clk)
   always @(posedge clk)
     read_reg <= read;
     read_reg <= read;
 
 
   // Advance the address after a read = first/next word fallthrough   
 
   assign raddr_reg_adv = (cnt > 2) & read_reg;
 
 
 
   always @(posedge clk)
   always @(posedge clk)
     if (reset)
     if (reset)
       raddr <= 0;
       raddr <= 0;
     else if (clear)
     else if (clear)
       raddr <= waddr;
       raddr <= waddr;
Line 140... Line 134...
     clear_reg <= clear;
     clear_reg <= clear;
 
 
   always @ (posedge clk)
   always @ (posedge clk)
     if (read | clear_reg)
     if (read | clear_reg)
       raddr_reg <= raddr;
       raddr_reg <= raddr;
 
     else if (fallthrough_read) // To pulse RE for fall-through on Xilinx
 
       raddr_reg <= fallthrough_read_addr;
 
 
   assign  data_out = fifo[raddr_reg];
   assign  data_out = fifo[raddr_reg];
 
 
 
 
   always @(posedge clk)
   always @(posedge clk)
Line 152... Line 148...
     else if (final_read & read & !write)
     else if (final_read & read & !write)
       final_read <= ~final_read;
       final_read <= ~final_read;
     else if ((cnt == 1) & read & !write)
     else if ((cnt == 1) & read & !write)
       final_read <= 1; // Indicate last read data has been output
       final_read <= 1; // Indicate last read data has been output
 
 
 
 
   assign empty = ~(|cnt);
   assign empty = ~(|cnt);
   assign almost_empty = cnt==1;
   assign almost_empty = cnt==1;
   assign full  = cnt == DEPTH;
   assign full  = {{32-CNT_WIDTH{1'b0}},cnt} == (DEPTH-1);
   assign almost_full  = &cnt[CNT_WIDTH-2:0];
   assign almost_full  = &cnt[CNT_WIDTH-1:0];
 
 
`else // !`ifdef ETH_FIFO_GENERIC
`else // !`ifdef ETH_FIFO_GENERIC
 
 
reg     [CNT_WIDTH-2:0]   read_pointer;
reg     [CNT_WIDTH-1:0]   read_pointer;
reg     [CNT_WIDTH-2:0]   write_pointer;
reg     [CNT_WIDTH-1:0]   write_pointer;
 
 
 
 
always @ (posedge clk or posedge reset)
always @ (posedge clk or posedge reset)
begin
begin
  if(reset)
  if(reset)
    read_pointer <= 0;
    read_pointer <= 0;
  else
  else
  if(clear)
  if(clear)
    //read_pointer <= { {(CNT_WIDTH-2){1'b0}}, read};
    //read_pointer <= { {(CNT_WIDTH-1){1'b0}}, read};
    read_pointer <= { {(CNT_WIDTH-2){1'b0}}, 1'b1};
    read_pointer <= { {(CNT_WIDTH-1){1'b0}}, 1'b1};
  else
  else
  if(read & ~empty)
  if(read & ~empty)
    read_pointer <= read_pointer + 1'b1;
    read_pointer <= read_pointer + 1'b1;
end
end
 
 
Line 183... Line 178...
begin
begin
  if(reset)
  if(reset)
    write_pointer <= 0;
    write_pointer <= 0;
  else
  else
  if(clear)
  if(clear)
    write_pointer <= { {(CNT_WIDTH-2){1'b0}}, write};
    write_pointer <= { {(CNT_WIDTH-1){1'b0}}, write};
  else
  else
  if(write & ~full)
  if(write & ~full)
    write_pointer <= write_pointer + 1'b1;
    write_pointer <= write_pointer + 1'b1;
end
end
 
 
Line 215... Line 210...
`endif // !`ifdef ETH_FIFO_XILINX
`endif // !`ifdef ETH_FIFO_XILINX
 
 
 
 
assign empty = ~(|cnt);
assign empty = ~(|cnt);
assign almost_empty = cnt == 1;
assign almost_empty = cnt == 1;
assign full  = cnt == DEPTH;
assign full  = cnt == (DEPTH-1);
assign almost_full  = &cnt[CNT_WIDTH-2:0];
assign almost_full  = &cnt[CNT_WIDTH-1:0];
 
 
`endif // !`ifdef ETH_FIFO_GENERIC
`endif // !`ifdef ETH_FIFO_GENERIC
 
 
 
 
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.