⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 eth_wishbone.v

📁 这是一个很好的Verilog 编写的8位RISC CPU源码(可做为MCU)
💻 V
📖 第 1 页 / 共 5 页
字号:
//////////////////////////////////////////////////////////////////////////                                                              ////////  eth_wishbone.v                                              ////////                                                              ////////  This file is part of the Ethernet IP core project           ////////  http://www.opencores.org/projects/ethmac/                   ////////                                                              ////////  Author(s):                                                  ////////      - Igor Mohor (igorM@opencores.org)                      ////////                                                              ////////  All additional information is avaliable in the Readme.txt   ////////  file.                                                       ////////                                                              //////////////////////////////////////////////////////////////////////////////                                                              //////// Copyright (C) 2001, 2002 Authors                             ////////                                                              //////// This source file may be used and distributed without         //////// restriction provided that this copyright statement is not    //////// removed from the file and that any derivative work contains  //////// the original copyright notice and the associated disclaimer. ////////                                                              //////// This source file is free software; you can redistribute it   //////// and/or modify it under the terms of the GNU Lesser General   //////// Public License as published by the Free Software Foundation; //////// either version 2.1 of the License, or (at your option) any   //////// later version.                                               ////////                                                              //////// This source is distributed in the hope that it will be       //////// useful, but WITHOUT ANY WARRANTY; without even the implied   //////// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      //////// PURPOSE.  See the GNU Lesser General Public License for more //////// details.                                                     ////////                                                              //////// You should have received a copy of the GNU Lesser General    //////// Public License along with this source; if not, download it   //////// from http://www.opencores.org/lgpl.shtml                     ////////                                                              ////////////////////////////////////////////////////////////////////////////// CVS Revision History//// $Log: eth_wishbone.v,v $// Revision 1.33  2002/09/04 18:47:57  mohor// Debug registers reg1, 2, 3, 4 connected. Synchronization of many signals// changed (bugs fixed). Access to un-alligned buffers fixed. RxAbort signal// was not used OK.//// Revision 1.32  2002/08/14 19:31:48  mohor// Register TX_BD_NUM is changed so it contains value of the Tx buffer descriptors. No// need to multiply or devide any more.//// Revision 1.31  2002/07/25 18:29:01  mohor// WriteRxDataToMemory signal changed so end of frame (when last word is// written to fifo) is changed.//// Revision 1.30  2002/07/23 15:28:31  mohor// Ram , used for BDs changed from generic_spram to eth_spram_256x32.//// Revision 1.29  2002/07/20 00:41:32  mohor// ShiftEnded synchronization changed.//// Revision 1.28  2002/07/18 16:11:46  mohor// RxBDAddress takes `ETH_TX_BD_NUM_DEF value after reset.//// Revision 1.27  2002/07/11 02:53:20  mohor// RxPointer bug fixed.//// Revision 1.26  2002/07/10 13:12:38  mohor// Previous bug wasn't succesfully removed. Now fixed.//// Revision 1.25  2002/07/09 23:53:24  mohor// Master state machine had a bug when switching from master write to// master read.//// Revision 1.24  2002/07/09 20:44:41  mohor// m_wb_cyc_o signal released after every single transfer.//// Revision 1.23  2002/05/03 10:15:50  mohor// Outputs registered. Reset changed for eth_wishbone module.//// Revision 1.22  2002/04/24 08:52:19  mohor// Compiler directives added. Tx and Rx fifo size incremented. A "late collision"// bug fixed.//// Revision 1.21  2002/03/29 16:18:11  lampret// Small typo fixed.//// Revision 1.20  2002/03/25 16:19:12  mohor// Any address can be used for Tx and Rx BD pointers. Address does not need// to be aligned.//// Revision 1.19  2002/03/19 12:51:50  mohor// Comments in Slovene language removed.//// Revision 1.18  2002/03/19 12:46:52  mohor// casex changed with case, fifo reset changed.//// Revision 1.17  2002/03/09 16:08:45  mohor// rx_fifo was not always cleared ok. Fixed.//// Revision 1.16  2002/03/09 13:51:20  mohor// Status was not latched correctly sometimes. Fixed.//// Revision 1.15  2002/03/08 06:56:46  mohor// Big Endian problem when sending frames fixed.//// Revision 1.14  2002/03/02 19:12:40  mohor// Byte ordering changed (Big Endian used). casex changed with case because// Xilinx Foundation had problems. Tested in HW. It WORKS.//// Revision 1.13  2002/02/26 16:59:55  mohor// Small fixes for external/internal DMA missmatches.//// Revision 1.12  2002/02/26 16:22:07  mohor// Interrupts changed//// Revision 1.11  2002/02/15 17:07:39  mohor// Status was not written correctly when frames were discarted because of// address mismatch.//// Revision 1.10  2002/02/15 12:17:39  mohor// RxStartFrm cleared when abort or retry comes.//// Revision 1.9  2002/02/15 11:59:10  mohor// Changes that were lost when updating from 1.5 to 1.8 fixed.//// Revision 1.8  2002/02/14 20:54:33  billditt// Addition  of new module eth_addrcheck.v//// Revision 1.7  2002/02/12 17:03:47  mohor// RxOverRun added to statuses.//// Revision 1.6  2002/02/11 09:18:22  mohor// Tx status is written back to the BD.//// Revision 1.5  2002/02/08 16:21:54  mohor// Rx status is written back to the BD.//// Revision 1.4  2002/02/06 14:10:21  mohor// non-DMA host interface added. Select the right configutation in eth_defines.//// Revision 1.3  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.//// Revision 1.2  2002/02/01 12:46:51  mohor// Tx part finished. TxStatus needs to be fixed. Pause request needs to be// added.//// Revision 1.1  2002/01/23 10:47:59  mohor// Initial version. Equals to eth_wishbonedma.v at this moment.////////// Build pause frame// Check GotData and evaluate data (abort or something like that comes before StartFrm)// m_wb_err_i should start status underrun or uverrun// r_RecSmall not used`include "eth_defines.v"`include "timescale.v"module eth_wishbone   (    // WISHBONE common    WB_CLK_I, WB_DAT_I, WB_DAT_O,     // WISHBONE slave 		WB_ADR_I, WB_WE_I, WB_ACK_O,     BDCs,     Reset,     // WISHBONE master    m_wb_adr_o, m_wb_sel_o, m_wb_we_o,     m_wb_dat_o, m_wb_dat_i, m_wb_cyc_o,     m_wb_stb_o, m_wb_ack_i, m_wb_err_i,     //TX    MTxClk, TxStartFrm, TxEndFrm, TxUsedData, TxData,     TxRetry, TxAbort, TxUnderRun, TxDone, PerPacketCrcEn,     PerPacketPad,     //RX    MRxClk, RxData, RxValid, RxStartFrm, RxEndFrm, RxAbort,         // Register    r_TxEn, r_RxEn, r_TxBDNum, TX_BD_NUM_Wr,     // Interrupts    TxB_IRQ, TxE_IRQ, RxB_IRQ, RxE_IRQ, Busy_IRQ,         // Rx Status    InvalidSymbol, LatchedCrcError, RxLateCollision, ShortFrame, DribbleNibble,    ReceivedPacketTooBig, RxLength, LoadRxStatus, ReceivedPacketGood,         // Tx Status    RetryCntLatched, RetryLimit, LateCollLatched, DeferLatched, CarrierSenseLost,         reg1, reg2, reg3, reg4    		);parameter Tp = 1;output [31:0] reg1, reg2, reg3, reg4;// WISHBONE commoninput           WB_CLK_I;       // WISHBONE clockinput  [31:0]   WB_DAT_I;       // WISHBONE data inputoutput [31:0]   WB_DAT_O;       // WISHBONE data output// WISHBONE slaveinput   [9:2]   WB_ADR_I;       // WISHBONE address inputinput           WB_WE_I;        // WISHBONE write enable inputinput           BDCs;           // Buffer descriptors are selectedoutput          WB_ACK_O;       // WISHBONE acknowledge output// WISHBONE masteroutput  [31:0]  m_wb_adr_o;     // output   [3:0]  m_wb_sel_o;     // output          m_wb_we_o;      // output  [31:0]  m_wb_dat_o;     // output          m_wb_cyc_o;     // output          m_wb_stb_o;     // input   [31:0]  m_wb_dat_i;     // input           m_wb_ack_i;     // input           m_wb_err_i;     // input           Reset;       // Reset signal// Rx Status signalsinput           InvalidSymbol;    // Invalid symbol was received during reception in 100 Mbps modeinput           LatchedCrcError;  // CRC errorinput           RxLateCollision;  // Late collision occured while receiving frameinput           ShortFrame;       // Frame shorter then the minimum size (r_MinFL) was received while small packets are enabled (r_RecSmall)input           DribbleNibble;    // Extra nibble receivedinput           ReceivedPacketTooBig;// Received packet is bigger than r_MaxFLinput    [15:0] RxLength;         // Length of the incoming frameinput           LoadRxStatus;     // Rx status was loadedinput           ReceivedPacketGood;// Received packet's length and CRC are good// Tx Status signalsinput     [3:0] RetryCntLatched;  // Latched Retry Counterinput           RetryLimit;       // Retry limit reached (Retry Max value + 1 attempts were made)input           LateCollLatched;  // Late collision occuredinput           DeferLatched;     // Defer indication (Frame was defered before sucessfully sent)input           CarrierSenseLost; // Carrier Sense was lost during the frame transmission// Txinput           MTxClk;         // Transmit clock (from PHY)input           TxUsedData;     // Transmit packet used datainput           TxRetry;        // Transmit packet retryinput           TxAbort;        // Transmit packet abortinput           TxDone;         // Transmission endedoutput          TxStartFrm;     // Transmit packet start frameoutput          TxEndFrm;       // Transmit packet end frameoutput  [7:0]   TxData;         // Transmit packet data byteoutput          TxUnderRun;     // Transmit packet under-runoutput          PerPacketCrcEn; // Per packet crc enableoutput          PerPacketPad;   // Per packet pading// Rxinput           MRxClk;         // Receive clock (from PHY)input   [7:0]   RxData;         // Received data byte (from PHY)input           RxValid;        // input           RxStartFrm;     // input           RxEndFrm;       // input           RxAbort;        // This signal is set when address doesn't match.//Registerinput           r_TxEn;         // Transmit enableinput           r_RxEn;         // Receive enableinput   [7:0]   r_TxBDNum;      // Receive buffer descriptor numberinput           TX_BD_NUM_Wr;   // RxBDNumber written// Interruptsoutput TxB_IRQ;output TxE_IRQ;output RxB_IRQ;output RxE_IRQ;output Busy_IRQ;reg TxB_IRQ;reg TxE_IRQ;reg RxB_IRQ;reg RxE_IRQ;reg             TxStartFrm;reg             TxEndFrm;reg     [7:0]   TxData;reg             TxUnderRun;reg             TxUnderRun_wb;reg             TxBDRead;wire            TxStatusWrite;reg     [1:0]   TxValidBytesLatched;reg    [15:0]   TxLength;reg    [15:0]   LatchedTxLength;reg   [14:11]   TxStatus;reg   [14:13]   RxStatus;reg             TxStartFrm_wb;reg             TxRetry_wb;reg             TxAbort_wb;reg             TxDone_wb;reg             TxDone_wb_q;reg             TxAbort_wb_q;reg             TxRetry_wb_q;reg             TxDone_wb_q2;reg             TxAbort_wb_q2;reg             TxRetry_wb_q2;reg             RxBDReady;reg             TxBDReady;reg             RxBDRead;wire            RxStatusWrite;reg    [31:0]   TxDataLatched;reg     [1:0]   TxByteCnt;reg             LastWord;reg             ReadTxDataFromFifo_tck;reg             BlockingTxStatusWrite;reg             BlockingTxBDRead;reg             Flop;reg     [7:0]   TxBDAddress;reg     [7:0]   RxBDAddress;reg             TxRetrySync1;reg             TxAbortSync1;reg             TxDoneSync1;reg             TxAbort_q;reg             TxRetry_q;reg             TxUsedData_q;reg    [31:0]   RxDataLatched2;// reg    [23:0]   RxDataLatched1;reg    [31:8]   RxDataLatched1;     // Big Endian Byte Orderingreg     [1:0]   RxValidBytes;reg     [1:0]   RxByteCnt;reg             LastByteIn;reg             ShiftWillEnd;reg             WriteRxDataToFifo;reg    [15:0]   LatchedRxLength;reg             RxAbortLatched;reg             ShiftEnded;reg             RxOverrun;reg             BDWrite;                    // BD Write Enable for access from WISHBONE sidereg             BDRead;                     // BD Read access from WISHBONE sidewire   [31:0]   RxBDDataIn;                 // Rx BD data inwire   [31:0]   TxBDDataIn;                 // Tx BD data inreg             TxEndFrm_wb;wire            TxRetryPulse;wire            TxDonePulse;wire            TxAbortPulse;wire            TxRetryPulse_q;wire            TxDonePulse_q;wire            TxAbortPulse_q;wire            StartRxBDRead;wire            StartTxBDRead;wire            TxIRQEn;wire            WrapTxStatusBit;wire            RxIRQEn;wire            WrapRxStatusBit;wire    [1:0]   TxValidBytes;wire    [7:0]   TempTxBDAddress;wire    [7:0]   TempRxBDAddress;wire            SetGotData;wire            GotDataEvaluate;reg             WB_ACK_O;wire    [6:0]   RxStatusIn;reg     [6:0]   RxStatusInLatched;reg WbEn, WbEn_q;reg RxEn, RxEn_q;reg TxEn, TxEn_q;wire ram_ce;wire ram_we;wire ram_oe;reg [7:0]   ram_addr;reg [31:0]  ram_di;wire [31:0] ram_do;wire StartTxPointerRead;reg  TxPointerRead;reg TxEn_needed;reg RxEn_needed;wire StartRxPointerRead;reg RxPointerRead; always @ (posedge WB_CLK_I or posedge Reset)begin  if(Reset)    begin      WB_ACK_O <=#Tp 1'b0;    end  else    begin      WB_ACK_O <=#Tp BDWrite & WbEn & WbEn_q | BDRead & WbEn & ~WbEn_q;    endendassign WB_DAT_O = ram_do;// Generic synchronous single-port RAM interfaceeth_spram_256x32 bd_ram (	// Generic synchronous single-port RAM interface	.clk(WB_CLK_I), .rst(Reset), .ce(ram_ce), .we(ram_we), .oe(ram_oe), .addr(ram_addr), .di(ram_di), .do(ram_do));assign ram_ce = 1'b1;assign ram_we = BDWrite & WbEn & WbEn_q | TxStatusWrite | RxStatusWrite;assign ram_oe = BDRead & WbEn & WbEn_q | TxEn & TxEn_q & (TxBDRead | TxPointerRead) | RxEn & RxEn_q & (RxBDRead | RxPointerRead);always @ (posedge WB_CLK_I or posedge Reset)begin  if(Reset)    TxEn_needed <=#Tp 1'b0;  else  if(~TxBDReady & r_TxEn & WbEn & ~WbEn_q)    TxEn_needed <=#Tp 1'b1;  else  if(TxPointerRead & TxEn & TxEn_q)    TxEn_needed <=#Tp 1'b0;end// Enabling access to the RAM for three devices.always @ (posedge WB_CLK_I or posedge Reset)begin  if(Reset)    begin      WbEn <=#Tp 1'b1;      RxEn <=#Tp 1'b0;      TxEn <=#Tp 1'b0;      ram_addr <=#Tp 8'h0;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -