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

Subversion Repositories ethmac

[/] [ethmac/] [branches/] [unneback/] [rtl/] [verilog/] [eth_transmitcontrol.v] - Diff between revs 352 and 361

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

Rev 352 Rev 361
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
////                                                              ////
////                                                              ////
////  eth_transmitcontrol.v                                       ////
////  eth_transmitcontrol.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/project,ethmac                     ////
////  http://www.opencores.org/project,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.5  2002/11/19 17:37:32  mohor
// Revision 1.5  2002/11/19 17:37:32  mohor
// When control frame (PAUSE) was sent, status was written in the
// When control frame (PAUSE) was sent, status was written in the
// eth_wishbone module and both TXB and TXC interrupts were set. Fixed.
// eth_wishbone module and both TXB and TXC interrupts were set. Fixed.
// Only TXC interrupt is set.
// Only TXC interrupt is set.
//
//
// Revision 1.4  2002/01/23 10:28:16  mohor
// Revision 1.4  2002/01/23 10:28:16  mohor
// Link in the header changed.
// 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.
//
//
// Revision 1.1  2001/07/03 12:51:54  mohor
// Revision 1.1  2001/07/03 12:51:54  mohor
// Initial release of the MAC Control module.
// Initial release of the MAC Control module.
//
//
//
//
//
//
//
//
//
//
//
//
 
 
 
 
`include "timescale.v"
`include "timescale.v"
 
 
 
 
module eth_transmitcontrol (MTxClk, TxReset, TxUsedDataIn, TxUsedDataOut, TxDoneIn, TxAbortIn,
module eth_transmitcontrol (MTxClk, TxReset, TxUsedDataIn, TxUsedDataOut, TxDoneIn, TxAbortIn,
                            TxStartFrmIn, TPauseRq, TxUsedDataOutDetected, TxFlow, DlyCrcEn,
                            TxStartFrmIn, TPauseRq, TxUsedDataOutDetected, TxFlow, DlyCrcEn,
                            TxPauseTV, MAC, TxCtrlStartFrm, TxCtrlEndFrm, SendingCtrlFrm, CtrlMux,
                            TxPauseTV, MAC, TxCtrlStartFrm, TxCtrlEndFrm, SendingCtrlFrm, CtrlMux,
                            ControlData, WillSendControlFrame, BlockTxDone
                            ControlData, WillSendControlFrame, BlockTxDone
                           );
                           );
 
 
 
 
input         MTxClk;
input         MTxClk;
input         TxReset;
input         TxReset;
input         TxUsedDataIn;
input         TxUsedDataIn;
input         TxUsedDataOut;
input         TxUsedDataOut;
input         TxDoneIn;
input         TxDoneIn;
input         TxAbortIn;
input         TxAbortIn;
input         TxStartFrmIn;
input         TxStartFrmIn;
input         TPauseRq;
input         TPauseRq;
input         TxUsedDataOutDetected;
input         TxUsedDataOutDetected;
input         TxFlow;
input         TxFlow;
input         DlyCrcEn;
input         DlyCrcEn;
input  [15:0] TxPauseTV;
input  [15:0] TxPauseTV;
input  [47:0] MAC;
input  [47:0] MAC;
 
 
output        TxCtrlStartFrm;
output        TxCtrlStartFrm;
output        TxCtrlEndFrm;
output        TxCtrlEndFrm;
output        SendingCtrlFrm;
output        SendingCtrlFrm;
output        CtrlMux;
output        CtrlMux;
output [7:0]  ControlData;
output [7:0]  ControlData;
output        WillSendControlFrame;
output        WillSendControlFrame;
output        BlockTxDone;
output        BlockTxDone;
 
 
reg           SendingCtrlFrm;
reg           SendingCtrlFrm;
reg           CtrlMux;
reg           CtrlMux;
reg           WillSendControlFrame;
reg           WillSendControlFrame;
reg    [3:0]  DlyCrcCnt;
reg    [3:0]  DlyCrcCnt;
reg    [5:0]  ByteCnt;
reg    [5:0]  ByteCnt;
reg           ControlEnd_q;
reg           ControlEnd_q;
reg    [7:0]  MuxedCtrlData;
reg    [7:0]  MuxedCtrlData;
reg           TxCtrlStartFrm;
reg           TxCtrlStartFrm;
reg           TxCtrlStartFrm_q;
reg           TxCtrlStartFrm_q;
reg           TxCtrlEndFrm;
reg           TxCtrlEndFrm;
reg    [7:0]  ControlData;
reg    [7:0]  ControlData;
reg           TxUsedDataIn_q;
reg           TxUsedDataIn_q;
reg           BlockTxDone;
reg           BlockTxDone;
 
 
wire          IncrementDlyCrcCnt;
wire          IncrementDlyCrcCnt;
wire          ResetByteCnt;
wire          ResetByteCnt;
wire          IncrementByteCnt;
wire          IncrementByteCnt;
wire          ControlEnd;
wire          ControlEnd;
wire          IncrementByteCntBy2;
wire          IncrementByteCntBy2;
wire          EnableCnt;
wire          EnableCnt;
 
 
 
 
// A command for Sending the control frame is active (latched)
// A command for Sending the control frame is active (latched)
always @ (posedge MTxClk or posedge TxReset)
always @ (posedge MTxClk or posedge TxReset)
begin
begin
  if(TxReset)
  if(TxReset)
    WillSendControlFrame <=  1'b0;
    WillSendControlFrame <=  1'b0;
  else
  else
  if(TxCtrlEndFrm & CtrlMux)
  if(TxCtrlEndFrm & CtrlMux)
    WillSendControlFrame <=  1'b0;
    WillSendControlFrame <=  1'b0;
  else
  else
  if(TPauseRq & TxFlow)
  if(TPauseRq & TxFlow)
    WillSendControlFrame <=  1'b1;
    WillSendControlFrame <=  1'b1;
end
end
 
 
 
 
// Generation of the transmit control packet start frame
// Generation of the transmit control packet start frame
always @ (posedge MTxClk or posedge TxReset)
always @ (posedge MTxClk or posedge TxReset)
begin
begin
  if(TxReset)
  if(TxReset)
    TxCtrlStartFrm <=  1'b0;
    TxCtrlStartFrm <=  1'b0;
  else
  else
  if(TxUsedDataIn_q & CtrlMux)
  if(TxUsedDataIn_q & CtrlMux)
    TxCtrlStartFrm <=  1'b0;
    TxCtrlStartFrm <=  1'b0;
  else
  else
  if(WillSendControlFrame & ~TxUsedDataOut & (TxDoneIn | TxAbortIn | TxStartFrmIn | (~TxUsedDataOutDetected)))
  if(WillSendControlFrame & ~TxUsedDataOut & (TxDoneIn | TxAbortIn | TxStartFrmIn | (~TxUsedDataOutDetected)))
    TxCtrlStartFrm <=  1'b1;
    TxCtrlStartFrm <=  1'b1;
end
end
 
 
 
 
 
 
// Generation of the transmit control packet end frame
// Generation of the transmit control packet end frame
always @ (posedge MTxClk or posedge TxReset)
always @ (posedge MTxClk or posedge TxReset)
begin
begin
  if(TxReset)
  if(TxReset)
    TxCtrlEndFrm <=  1'b0;
    TxCtrlEndFrm <=  1'b0;
  else
  else
  if(ControlEnd | ControlEnd_q)
  if(ControlEnd | ControlEnd_q)
    TxCtrlEndFrm <=  1'b1;
    TxCtrlEndFrm <=  1'b1;
  else
  else
    TxCtrlEndFrm <=  1'b0;
    TxCtrlEndFrm <=  1'b0;
end
end
 
 
 
 
// Generation of the multiplexer signal (controls muxes for switching between
// Generation of the multiplexer signal (controls muxes for switching between
// normal and control packets)
// normal and control packets)
always @ (posedge MTxClk or posedge TxReset)
always @ (posedge MTxClk or posedge TxReset)
begin
begin
  if(TxReset)
  if(TxReset)
    CtrlMux <=  1'b0;
    CtrlMux <=  1'b0;
  else
  else
  if(WillSendControlFrame & ~TxUsedDataOut)
  if(WillSendControlFrame & ~TxUsedDataOut)
    CtrlMux <=  1'b1;
    CtrlMux <=  1'b1;
  else
  else
  if(TxDoneIn)
  if(TxDoneIn)
    CtrlMux <=  1'b0;
    CtrlMux <=  1'b0;
end
end
 
 
 
 
 
 
// Generation of the Sending Control Frame signal (enables padding and CRC)
// Generation of the Sending Control Frame signal (enables padding and CRC)
always @ (posedge MTxClk or posedge TxReset)
always @ (posedge MTxClk or posedge TxReset)
begin
begin
  if(TxReset)
  if(TxReset)
    SendingCtrlFrm <=  1'b0;
    SendingCtrlFrm <=  1'b0;
  else
  else
  if(WillSendControlFrame & TxCtrlStartFrm)
  if(WillSendControlFrame & TxCtrlStartFrm)
    SendingCtrlFrm <=  1'b1;
    SendingCtrlFrm <=  1'b1;
  else
  else
  if(TxDoneIn)
  if(TxDoneIn)
    SendingCtrlFrm <=  1'b0;
    SendingCtrlFrm <=  1'b0;
end
end
 
 
 
 
always @ (posedge MTxClk or posedge TxReset)
always @ (posedge MTxClk or posedge TxReset)
begin
begin
  if(TxReset)
  if(TxReset)
    TxUsedDataIn_q <=  1'b0;
    TxUsedDataIn_q <=  1'b0;
  else
  else
    TxUsedDataIn_q <=  TxUsedDataIn;
    TxUsedDataIn_q <=  TxUsedDataIn;
end
end
 
 
 
 
 
 
// Generation of the signal that will block sending the Done signal to the eth_wishbone module
// Generation of the signal that will block sending the Done signal to the eth_wishbone module
// While sending the control frame
// While sending the control frame
always @ (posedge MTxClk or posedge TxReset)
always @ (posedge MTxClk or posedge TxReset)
begin
begin
  if(TxReset)
  if(TxReset)
    BlockTxDone <=  1'b0;
    BlockTxDone <=  1'b0;
  else
  else
  if(TxCtrlStartFrm)
  if(TxCtrlStartFrm)
    BlockTxDone <=  1'b1;
    BlockTxDone <=  1'b1;
  else
  else
  if(TxStartFrmIn)
  if(TxStartFrmIn)
    BlockTxDone <=  1'b0;
    BlockTxDone <=  1'b0;
end
end
 
 
 
 
always @ (posedge MTxClk)
always @ (posedge MTxClk)
begin
begin
  ControlEnd_q     <=  ControlEnd;
  ControlEnd_q     <=  ControlEnd;
  TxCtrlStartFrm_q <=  TxCtrlStartFrm;
  TxCtrlStartFrm_q <=  TxCtrlStartFrm;
end
end
 
 
 
 
assign IncrementDlyCrcCnt = CtrlMux & TxUsedDataIn &  ~DlyCrcCnt[2];
assign IncrementDlyCrcCnt = CtrlMux & TxUsedDataIn &  ~DlyCrcCnt[2];
 
 
 
 
// Delayed CRC counter
// Delayed CRC counter
always @ (posedge MTxClk or posedge TxReset)
always @ (posedge MTxClk or posedge TxReset)
begin
begin
  if(TxReset)
  if(TxReset)
    DlyCrcCnt <=  4'h0;
    DlyCrcCnt <=  4'h0;
  else
  else
  if(ResetByteCnt)
  if(ResetByteCnt)
    DlyCrcCnt <=  4'h0;
    DlyCrcCnt <=  4'h0;
  else
  else
  if(IncrementDlyCrcCnt)
  if(IncrementDlyCrcCnt)
    DlyCrcCnt <=  DlyCrcCnt + 1'b1;
    DlyCrcCnt <=  DlyCrcCnt + 1'b1;
end
end
 
 
 
 
assign ResetByteCnt = TxReset | (~TxCtrlStartFrm & (TxDoneIn | TxAbortIn));
assign ResetByteCnt = TxReset | (~TxCtrlStartFrm & (TxDoneIn | TxAbortIn));
assign IncrementByteCnt = CtrlMux & (TxCtrlStartFrm & ~TxCtrlStartFrm_q & ~TxUsedDataIn | TxUsedDataIn & ~ControlEnd);
assign IncrementByteCnt = CtrlMux & (TxCtrlStartFrm & ~TxCtrlStartFrm_q & ~TxUsedDataIn | TxUsedDataIn & ~ControlEnd);
assign IncrementByteCntBy2 = CtrlMux & TxCtrlStartFrm & (~TxCtrlStartFrm_q) & TxUsedDataIn;     // When TxUsedDataIn and CtrlMux are set at the same time
assign IncrementByteCntBy2 = CtrlMux & TxCtrlStartFrm & (~TxCtrlStartFrm_q) & TxUsedDataIn;     // When TxUsedDataIn and CtrlMux are set at the same time
 
 
assign EnableCnt = (~DlyCrcEn | DlyCrcEn & (&DlyCrcCnt[1:0]));
assign EnableCnt = (~DlyCrcEn | DlyCrcEn & (&DlyCrcCnt[1:0]));
// Byte counter
// Byte counter
always @ (posedge MTxClk or posedge TxReset)
always @ (posedge MTxClk or posedge TxReset)
begin
begin
  if(TxReset)
  if(TxReset)
    ByteCnt <=  6'h0;
    ByteCnt <=  6'h0;
  else
  else
  if(ResetByteCnt)
  if(ResetByteCnt)
    ByteCnt <=  6'h0;
    ByteCnt <=  6'h0;
  else
  else
  if(IncrementByteCntBy2 & EnableCnt)
  if(IncrementByteCntBy2 & EnableCnt)
    ByteCnt <=  (ByteCnt[5:0] ) + 2'h2;
    ByteCnt <=  (ByteCnt[5:0] ) + 2'h2;
  else
  else
  if(IncrementByteCnt & EnableCnt)
  if(IncrementByteCnt & EnableCnt)
    ByteCnt <=  (ByteCnt[5:0] ) + 1'b1;
    ByteCnt <=  (ByteCnt[5:0] ) + 1'b1;
end
end
 
 
 
 
assign ControlEnd = ByteCnt[5:0] == 6'h22;
assign ControlEnd = ByteCnt[5:0] == 6'h22;
 
 
 
 
// Control data generation (goes to the TxEthMAC module)
// Control data generation (goes to the TxEthMAC module)
always @ (ByteCnt or DlyCrcEn or MAC or TxPauseTV or DlyCrcCnt)
always @ (ByteCnt or DlyCrcEn or MAC or TxPauseTV or DlyCrcCnt)
begin
begin
  case(ByteCnt)
  case(ByteCnt)
    6'h0:    if(~DlyCrcEn | DlyCrcEn & (&DlyCrcCnt[1:0]))
    6'h0:    if(~DlyCrcEn | DlyCrcEn & (&DlyCrcCnt[1:0]))
               MuxedCtrlData[7:0] = 8'h01;                   // Reserved Multicast Address
               MuxedCtrlData[7:0] = 8'h01;                   // Reserved Multicast Address
             else
             else
                                                         MuxedCtrlData[7:0] = 8'h0;
                                                         MuxedCtrlData[7:0] = 8'h0;
    6'h2:      MuxedCtrlData[7:0] = 8'h80;
    6'h2:      MuxedCtrlData[7:0] = 8'h80;
    6'h4:      MuxedCtrlData[7:0] = 8'hC2;
    6'h4:      MuxedCtrlData[7:0] = 8'hC2;
    6'h6:      MuxedCtrlData[7:0] = 8'h00;
    6'h6:      MuxedCtrlData[7:0] = 8'h00;
    6'h8:      MuxedCtrlData[7:0] = 8'h00;
    6'h8:      MuxedCtrlData[7:0] = 8'h00;
    6'hA:      MuxedCtrlData[7:0] = 8'h01;
    6'hA:      MuxedCtrlData[7:0] = 8'h01;
    6'hC:      MuxedCtrlData[7:0] = MAC[47:40];
    6'hC:      MuxedCtrlData[7:0] = MAC[47:40];
    6'hE:      MuxedCtrlData[7:0] = MAC[39:32];
    6'hE:      MuxedCtrlData[7:0] = MAC[39:32];
    6'h10:     MuxedCtrlData[7:0] = MAC[31:24];
    6'h10:     MuxedCtrlData[7:0] = MAC[31:24];
    6'h12:     MuxedCtrlData[7:0] = MAC[23:16];
    6'h12:     MuxedCtrlData[7:0] = MAC[23:16];
    6'h14:     MuxedCtrlData[7:0] = MAC[15:8];
    6'h14:     MuxedCtrlData[7:0] = MAC[15:8];
    6'h16:     MuxedCtrlData[7:0] = MAC[7:0];
    6'h16:     MuxedCtrlData[7:0] = MAC[7:0];
    6'h18:     MuxedCtrlData[7:0] = 8'h88;                   // Type/Length
    6'h18:     MuxedCtrlData[7:0] = 8'h88;                   // Type/Length
    6'h1A:     MuxedCtrlData[7:0] = 8'h08;
    6'h1A:     MuxedCtrlData[7:0] = 8'h08;
    6'h1C:     MuxedCtrlData[7:0] = 8'h00;                   // Opcode
    6'h1C:     MuxedCtrlData[7:0] = 8'h00;                   // Opcode
    6'h1E:     MuxedCtrlData[7:0] = 8'h01;
    6'h1E:     MuxedCtrlData[7:0] = 8'h01;
    6'h20:     MuxedCtrlData[7:0] = TxPauseTV[15:8];         // Pause timer value
    6'h20:     MuxedCtrlData[7:0] = TxPauseTV[15:8];         // Pause timer value
    6'h22:     MuxedCtrlData[7:0] = TxPauseTV[7:0];
    6'h22:     MuxedCtrlData[7:0] = TxPauseTV[7:0];
    default:   MuxedCtrlData[7:0] = 8'h0;
    default:   MuxedCtrlData[7:0] = 8'h0;
  endcase
  endcase
end
end
 
 
 
 
// Latched Control data
// Latched Control data
always @ (posedge MTxClk or posedge TxReset)
always @ (posedge MTxClk or posedge TxReset)
begin
begin
  if(TxReset)
  if(TxReset)
    ControlData[7:0] <=  8'h0;
    ControlData[7:0] <=  8'h0;
  else
  else
  if(~ByteCnt[0])
  if(~ByteCnt[0])
    ControlData[7:0] <=  MuxedCtrlData[7:0];
    ControlData[7:0] <=  MuxedCtrlData[7:0];
end
end
 
 
 
 
 
 
endmodule
endmodule
 
 

powered by: WebSVN 2.1.0

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