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

Subversion Repositories ethmac

[/] [ethmac/] [tags/] [rel_14/] [rtl/] [verilog/] [eth_macstatus.v] - Diff between revs 37 and 42

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 37 Rev 42
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
////                                                              ////
////                                                              ////
////  eth_macstatus.v                                             ////
////  eth_macstatus.v                                             ////
////                                                              ////
////                                                              ////
////  This file is part of the Ethernet IP core project           ////
////  This file is part of the Ethernet IP core project           ////
////  http://www.opencores.org/projects/ethmac/                   ////
////  http://www.opencores.org/projects/ethmac/                   ////
////                                                              ////
////                                                              ////
////  Author(s):                                                  ////
////  Author(s):                                                  ////
////      - Igor Mohor (igorM@opencores.org)                      ////
////      - Igor Mohor (igorM@opencores.org)                      ////
////                                                              ////
////                                                              ////
////  All additional information is avaliable in the Readme.txt   ////
////  All additional information is avaliable in the Readme.txt   ////
////  file.                                                       ////
////  file.                                                       ////
////                                                              ////
////                                                              ////
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
////                                                              ////
////                                                              ////
//// Copyright (C) 2001 Authors                                   ////
//// Copyright (C) 2001 Authors                                   ////
////                                                              ////
////                                                              ////
//// This source file may be used and distributed without         ////
//// This source file may be used and distributed without         ////
//// restriction provided that this copyright statement is not    ////
//// restriction provided that this copyright statement is not    ////
//// removed from the file and that any derivative work contains  ////
//// removed from the file and that any derivative work contains  ////
//// the original copyright notice and the associated disclaimer. ////
//// the original copyright notice and the associated disclaimer. ////
////                                                              ////
////                                                              ////
//// This source file is free software; you can redistribute it   ////
//// This source file is free software; you can redistribute it   ////
//// and/or modify it under the terms of the GNU Lesser General   ////
//// and/or modify it under the terms of the GNU Lesser General   ////
//// Public License as published by the Free Software Foundation; ////
//// Public License as published by the Free Software Foundation; ////
//// either version 2.1 of the License, or (at your option) any   ////
//// either version 2.1 of the License, or (at your option) any   ////
//// later version.                                               ////
//// later version.                                               ////
////                                                              ////
////                                                              ////
//// This source is distributed in the hope that it will be       ////
//// This source is distributed in the hope that it will be       ////
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
//// PURPOSE.  See the GNU Lesser General Public License for more ////
//// PURPOSE.  See the GNU Lesser General Public License for more ////
//// details.                                                     ////
//// details.                                                     ////
////                                                              ////
////                                                              ////
//// 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
// CVS Revision History
//
//
// $Log: not supported by cvs2svn $
// $Log: not supported by cvs2svn $
 
// Revision 1.4  2002/01/23 10:28:16  mohor
 
// Link in the header changed.
 
//
// Revision 1.3  2001/10/19 08:43:51  mohor
// Revision 1.3  2001/10/19 08:43:51  mohor
// eth_timescale.v changed to timescale.v This is done because of the
// eth_timescale.v changed to timescale.v This is done because of the
// simulation of the few cores in a one joined project.
// simulation of the few cores in a one joined project.
//
//
// Revision 1.2  2001/09/11 14:17:00  mohor
// Revision 1.2  2001/09/11 14:17:00  mohor
// Few little NCSIM warnings fixed.
// Few little NCSIM warnings fixed.
//
//
// Revision 1.1  2001/08/06 14:44:29  mohor
// Revision 1.1  2001/08/06 14:44:29  mohor
// A define FPGA added to select between Artisan RAM (for ASIC) and Block Ram (For Virtex).
// A define FPGA added to select between Artisan RAM (for ASIC) and Block Ram (For Virtex).
// Include files fixed to contain no path.
// Include files fixed to contain no path.
// File names and module names changed ta have a eth_ prologue in the name.
// File names and module names changed ta have a eth_ prologue in the name.
// File eth_timescale.v is used to define timescale
// File eth_timescale.v is used to define timescale
// All pin names on the top module are changed to contain _I, _O or _OE at the end.
// All pin names on the top module are changed to contain _I, _O or _OE at the end.
// Bidirectional signal MDIO is changed to three signals (Mdc_O, Mdi_I, Mdo_O
// Bidirectional signal MDIO is changed to three signals (Mdc_O, Mdi_I, Mdo_O
// and Mdo_OE. The bidirectional signal must be created on the top level. This
// and Mdo_OE. The bidirectional signal must be created on the top level. This
// is done due to the ASIC tools.
// is done due to the ASIC tools.
//
//
// Revision 1.1  2001/07/30 21:23:42  mohor
// Revision 1.1  2001/07/30 21:23:42  mohor
// Directory structure changed. Files checked and joind together.
// Directory structure changed. Files checked and joind together.
//
//
//
//
//
//
//
//
//
//
 
 
`include "timescale.v"
`include "timescale.v"
 
 
 
 
module eth_macstatus(
module eth_macstatus(
                      MRxClk, Reset, ReceivedLengthOK, ReceiveEnd, TransmitEnd, ReceivedPacketGood, RxCrcError,
                      MRxClk, Reset, ReceivedLengthOK, ReceiveEnd, ReceivedPacketGood, RxCrcError,
                      MRxErr, MRxDV, RxStateSFD, RxStateData, RxStatePreamble, RxStateIdle, Transmitting,
                      MRxErr, MRxDV, RxStateSFD, RxStateData, RxStatePreamble, RxStateIdle, Transmitting,
                      RxByteCnt, RxByteCntEq0, RxByteCntGreat2, RxByteCntMaxFrame, ReceivedPauseFrm
                      RxByteCnt, RxByteCntEq0, RxByteCntGreat2, RxByteCntMaxFrame, ReceivedPauseFrm,
 
                      InvalidSymbol, MRxD, LatchedCrcError, Collision, CollValid, RxLateCollision,
 
                      r_RecSmall, r_MinFL, r_MaxFL, ShortFrame, DribbleNibble, ReceivedPacketTooBig, r_HugEn,
 
                      LoadRxStatus
                    );
                    );
 
 
 
 
 
 
parameter Tp = 1;
parameter Tp = 1;
 
 
 
 
input         MRxClk;
input         MRxClk;
input         Reset;
input         Reset;
input         RxCrcError;
input         RxCrcError;
input         MRxErr;
input         MRxErr;
input         MRxDV;
input         MRxDV;
 
 
input         RxStateSFD;
input         RxStateSFD;
input   [1:0] RxStateData;
input   [1:0] RxStateData;
input         RxStatePreamble;
input         RxStatePreamble;
input         RxStateIdle;
input         RxStateIdle;
input         Transmitting;
input         Transmitting;
input  [15:0] RxByteCnt;
input  [15:0] RxByteCnt;
input         RxByteCntEq0;
input         RxByteCntEq0;
input         RxByteCntGreat2;
input         RxByteCntGreat2;
input         RxByteCntMaxFrame;
input         RxByteCntMaxFrame;
input         ReceivedPauseFrm;
input         ReceivedPauseFrm;
 
input   [3:0] MRxD;
 
input         Collision;
 
input   [5:0] CollValid;
 
input         r_RecSmall;
 
input  [15:0] r_MinFL;
 
input  [15:0] r_MaxFL;
 
input         r_HugEn;
 
 
output        ReceivedLengthOK;
output        ReceivedLengthOK;
output        ReceiveEnd;
output        ReceiveEnd;
output        ReceivedPacketGood;
output        ReceivedPacketGood;
output        TransmitEnd;
output        InvalidSymbol;
 
output        LatchedCrcError;
 
output        RxLateCollision;
 
output        ShortFrame;
 
output        DribbleNibble;
 
output        ReceivedPacketTooBig;
 
output        LoadRxStatus;
 
 
reg           ReceiveEnd;
reg           ReceiveEnd;
 
 
reg           LatchedCrcError;
reg           LatchedCrcError;
reg           LatchedMRxErr;
reg           LatchedMRxErr;
reg           PreloadRxStatus;
reg           LoadRxStatus;
reg    [15:0] LatchedRxByteCnt;
reg           InvalidSymbol;
 
 
wire          TakeSample;
wire          TakeSample;
 
wire          SetInvalidSymbol; // Invalid symbol was received during reception in 100Mbps 
 
 
// Crc error
// Crc error
always @ (posedge MRxClk or posedge Reset)
always @ (posedge MRxClk or posedge Reset)
begin
begin
  if(Reset)
  if(Reset)
    LatchedCrcError <=#Tp 1'b0;
    LatchedCrcError <=#Tp 1'b0;
  else
  else
    begin
 
      if(RxStateSFD)
      if(RxStateSFD)
        LatchedCrcError <=#Tp 1'b0;
    LatchedCrcError <=#Tp 1'b0;
      else
  else
      if(RxStateData[0])
  if(RxStateData[0])
        LatchedCrcError <=#Tp RxCrcError & ~RxByteCntEq0;
    LatchedCrcError <=#Tp RxCrcError & ~RxByteCntEq0;
    end
    end
end
 
 
 
 
 
// LatchedMRxErr
// LatchedMRxErr
always @ (posedge MRxClk or posedge Reset)
always @ (posedge MRxClk or posedge Reset)
begin
begin
  if(Reset)
  if(Reset)
    LatchedMRxErr <=#Tp 1'b0;
    LatchedMRxErr <=#Tp 1'b0;
  else
  else
  if(~MRxErr & MRxDV & RxStateIdle & ~Transmitting)
  if(~MRxErr & MRxDV & RxStateIdle & ~Transmitting)
    LatchedMRxErr <=#Tp 1'b0;
    LatchedMRxErr <=#Tp 1'b0;
  else
  else
  if(MRxErr & MRxDV & (RxStatePreamble | RxStateSFD | (|RxStateData) | RxStateIdle & ~Transmitting))
  if(MRxErr & MRxDV & (RxStatePreamble | RxStateSFD | (|RxStateData) | RxStateIdle & ~Transmitting))
    LatchedMRxErr <=#Tp 1'b1;
    LatchedMRxErr <=#Tp 1'b1;
end
end
 
 
 
 
// ReceivedPacketGood
// ReceivedPacketGood
assign ReceivedPacketGood = ~LatchedCrcError & ~LatchedMRxErr;
assign ReceivedPacketGood = ~LatchedCrcError & ~LatchedMRxErr;
 
 
 
 
// ReceivedLengthOK
// ReceivedLengthOK
assign ReceivedLengthOK = LatchedRxByteCnt[15:0] > 63 & LatchedRxByteCnt[15:0] < 1519;
assign ReceivedLengthOK = RxByteCnt[15:0] > 63 & RxByteCnt[15:0] < 1519;
 
 
 
 
 
 
// LatchedRxByteCnt[15:0]
 
 
 
 
// Time to take a sample
 
assign TakeSample = |RxStateData     & ~MRxDV & RxByteCntGreat2  |
 
                     RxStateData[0]  &  MRxDV & RxByteCntMaxFrame;
 
 
 
 
 
// LoadRxStatus
always @ (posedge MRxClk or posedge Reset)
always @ (posedge MRxClk or posedge Reset)
begin
begin
  if(Reset)
  if(Reset)
    LatchedRxByteCnt[15:0] <=#Tp 16'h0;
    LoadRxStatus <=#Tp 1'b0;
  else
  else
 
    LoadRxStatus <=#Tp TakeSample;
 
end
 
 
 
 
 
 
 
// ReceiveEnd
 
always @ (posedge MRxClk or posedge Reset)
    begin
    begin
      if(RxStateSFD)
  if(Reset)
        LatchedRxByteCnt[15:0] <=#Tp RxByteCnt[15:0];
    ReceiveEnd  <=#Tp 1'b0;
      else
      else
      if(RxStateData[0])
    ReceiveEnd  <=#Tp LoadRxStatus;
        LatchedRxByteCnt[15:0] <=#Tp RxByteCnt[15:0];
 
    end
 
end
end
 
 
 
 
 
// Invalid Symbol received during 100Mbps mode
 
assign SetInvalidSymbol = MRxDV & MRxErr & ~LatchedMRxErr & MRxD[3:0] == 4'he;
 
 
// Time to take a sample
 
assign TakeSample = |RxStateData     & ~MRxDV & RxByteCntGreat2  |
// InvalidSymbol
                     RxStateData[0]  &  MRxDV & RxByteCntMaxFrame;
always @ (posedge MRxClk or posedge Reset)
 
begin
 
  if(Reset)
 
    InvalidSymbol <=#Tp 1'b0;
 
  else
 
  if(LoadRxStatus & ~SetInvalidSymbol)
 
    InvalidSymbol <=#Tp 1'b0;
 
  else
 
  if(SetInvalidSymbol)
 
    InvalidSymbol <=#Tp 1'b1;
 
end
 
 
 
 
// PreloadRxStatus
// Late Collision
 
 
 
reg RxLateCollision;
 
reg RxColWindow;
 
// Collision Window
always @ (posedge MRxClk or posedge Reset)
always @ (posedge MRxClk or posedge Reset)
begin
begin
  if(Reset)
  if(Reset)
    PreloadRxStatus <=#Tp 1'b0;
    RxLateCollision <=#Tp 1'b0;
 
  else
 
  if(LoadRxStatus)
 
    RxLateCollision <=#Tp 1'b0;
  else
  else
    PreloadRxStatus <=#Tp TakeSample;
  if(Collision & (~RxColWindow | r_RecSmall))
 
    RxLateCollision <=#Tp 1'b1;
end
end
 
 
 
// Collision Window
 
always @ (posedge MRxClk or posedge Reset)
 
begin
 
  if(Reset)
 
    RxColWindow <=#Tp 1'b1;
 
  else
 
  if(~Collision & RxByteCnt[5:0] == CollValid[5:0] & RxStateData[1])
 
    RxColWindow <=#Tp 1'b0;
 
  else
 
  if(RxStateIdle)
 
    RxColWindow <=#Tp 1'b1;
 
end
 
 
 
 
// ReceiveEnd
// ShortFrame
 
reg ShortFrame;
always @ (posedge MRxClk or posedge Reset)
always @ (posedge MRxClk or posedge Reset)
begin
begin
  if(Reset)
  if(Reset)
    ReceiveEnd  <=#Tp 1'b0;
    ShortFrame <=#Tp 1'b0;
  else
  else
    ReceiveEnd  <=#Tp PreloadRxStatus;
  if(LoadRxStatus)
 
    ShortFrame <=#Tp 1'b0;
 
  else
 
  if(TakeSample)
 
    ShortFrame <=#Tp r_RecSmall & RxByteCnt[15:0] < r_MinFL[15:0];
end
end
 
 
 
 
 
// DribbleNibble
 
reg DribbleNibble;
 
always @ (posedge MRxClk or posedge Reset)
 
begin
 
  if(Reset)
 
    DribbleNibble <=#Tp 1'b0;
 
  else
 
  if(RxStateSFD)
 
    DribbleNibble <=#Tp 1'b0;
 
  else
 
  if(~MRxDV & RxStateData[1])
 
    DribbleNibble <=#Tp 1'b1;
 
end
 
 
 
 
 
reg ReceivedPacketTooBig;
 
assign ReceivedLengthOK = RxByteCnt[15:0] > 63 & RxByteCnt[15:0] < 1519;
 
always @ (posedge MRxClk or posedge Reset)
 
begin
 
  if(Reset)
 
    ReceivedPacketTooBig <=#Tp 1'b0;
 
  else
 
  if(LoadRxStatus)
 
    ReceivedPacketTooBig <=#Tp 1'b0;
 
  else
 
  if(TakeSample)
 
    ReceivedPacketTooBig <=#Tp ~r_HugEn & RxByteCnt[15:0] > r_MaxFL[15:0];
 
end
 
 
endmodule
endmodule
 
 

powered by: WebSVN 2.1.0

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