📄 mac_rx_ctrl.v
字号:
////////////////////////////////////////////////////////////////////////// //////// MAC_rx_ctrl.v //////// //////// This file is part of the Ethernet IP core project //////// http://www.opencores.org/projects.cgi/web/ethernet_tri_mode///////// //////// Author(s): //////// - Jon Gao (gaojon@yahoo.com) //////// //////// ////////////////////////////////////////////////////////////////////////////// //////// Copyright (C) 2001 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: MAC_rx_ctrl.v,v $// Revision 1.4 2006/06/25 04:58:56 maverickist// no message//// Revision 1.3 2006/01/19 14:07:54 maverickist// verification is complete.//// Revision 1.3 2005/12/16 06:44:17 Administrator// replaced tab with space.// passed 9.6k length frame test.//// Revision 1.2 2005/12/13 12:15:37 Administrator// no message//// Revision 1.1.1.1 2005/12/13 01:51:45 Administrator// no message// module MAC_rx_ctrl (Reset , Clk , //RMII interface MCrs_dv , //MRxD , // MRxErr , // //CRC_chk interface CRC_en , CRC_init ,CRC_err , //MAC_rx_add_chk interface MAC_add_en , MAC_rx_add_chk_err , //broadcast_filter broadcast_ptr , broadcast_drop , //flow_control signals pause_quanta , pause_quanta_val , //MAC_rx_FF interface Fifo_data , Fifo_data_en , Fifo_data_err , Fifo_data_end , Fifo_full , //RMON interface Rx_pkt_type_rmon , Rx_pkt_length_rmon , Rx_apply_rmon , Rx_pkt_err_type_rmon , //CPU RX_IFG_SET ,RX_MAX_LENGTH,RX_MIN_LENGTH);input Reset ; input Clk ; //RMII interface input MCrs_dv ; input [7:0] MRxD ; input MRxErr ; //CRC_chk interfaceoutput CRC_en ; output CRC_init; input CRC_err ; //MAC_rx_add_chk interfaceoutput MAC_add_en ;input MAC_rx_add_chk_err ; //broadcast_filteroutput broadcast_ptr ;input broadcast_drop ; //flow_control signals output [15:0] pause_quanta ; output pause_quanta_val ; //MAC_rx_FF interfaceoutput [7:0] Fifo_data ;output Fifo_data_en ;output Fifo_data_err ;output Fifo_data_end ;input Fifo_full; //RMON interfaceoutput [15:0] Rx_pkt_length_rmon ;output Rx_apply_rmon ;output [2:0] Rx_pkt_err_type_rmon ;output [2:0] Rx_pkt_type_rmon ; //CPUinput [5:0] RX_IFG_SET ;input [15:0] RX_MAX_LENGTH ;// 1518input [6:0] RX_MIN_LENGTH ;// 64//******************************************************************************//internal signals//******************************************************************************parameter State_idle =4'd00;parameter State_preamble =4'd01;parameter State_SFD =4'd02;parameter State_data =4'd03;parameter State_checkCRC =4'd04;parameter State_OkEnd =4'd07;parameter State_drop =4'd08;parameter State_ErrEnd =4'd09;parameter State_CRCErrEnd =4'd10;parameter State_FFFullDrop =4'd11;parameter State_FFFullErrEnd =4'd12;parameter State_IFG =4'd13;parameter Pause_idle =4'd0; parameter Pause_pre_syn =4'd1; parameter Pause_quanta_hi =4'd2; parameter Pause_quanta_lo =4'd3; parameter Pause_syn =4'd4; reg [3:0] Current_state /* synthesis syn_keep=1 */; reg [3:0] Next_state; reg [3:0] Pause_current /* synthesis syn_keep=1 */; reg [3:0] Pause_next; reg [5:0] IFG_counter; reg Crs_dv ; reg [7:0] RxD ;reg [7:0] RxD_dl1 ;reg RxErr ;reg [15:0] Frame_length_counter;reg Too_long;reg Too_short;reg Fifo_data_en;reg Fifo_data_end;reg Fifo_data_err;reg CRC_en;reg CRC_init;reg Rx_apply_rmon;reg Rx_apply_rmon_tmp;reg Rx_apply_rmon_tmp_pl1;reg [2:0] Rx_pkt_err_type_rmon;reg MAC_add_en;reg [2:0] Rx_pkt_type_rmon;reg [7:0] pause_quanta_h ;reg [15:0] pause_quanta ;reg pause_quanta_val ;reg pause_quanta_val_tmp;reg pause_frame_ptr ;reg broadcast_ptr ;//******************************************************************************//delay signals //****************************************************************************** always @ (posedge Reset or posedge Clk) if (Reset) begin Crs_dv <=0; RxD <=0; RxErr <=0; end else begin Crs_dv <=MCrs_dv ; RxD <=MRxD ; RxErr <=MRxErr ; endalways @ (posedge Reset or posedge Clk) if (Reset) RxD_dl1 <=0; else RxD_dl1 <=RxD; //******************************************************************************//State_machine //****************************************************************************** always @ (posedge Reset or posedge Clk) if (Reset) Current_state <=State_idle; else Current_state <=Next_state; always @ (*) case (Current_state) State_idle: if (Crs_dv&&RxD==8'h55) Next_state =State_preamble; else Next_state =Current_state; State_preamble: if (!Crs_dv) Next_state =State_ErrEnd; else if (RxErr) Next_state =State_drop; else if (RxD==8'hd5) Next_state =State_SFD; else if (RxD==8'h55) Next_state =Current_state; else Next_state =State_drop; State_SFD: if (!Crs_dv) Next_state =State_ErrEnd; else if (RxErr) Next_state =State_drop; else Next_state =State_data; State_data: if (!Crs_dv&&!Too_short&&!Too_long) Next_state =State_checkCRC; else if (!Crs_dv&&(Too_short||Too_long)) Next_state =State_ErrEnd; else if (Fifo_full) Next_state =State_FFFullErrEnd; else if (RxErr||MAC_rx_add_chk_err||Too_long||broadcast_drop) Next_state =State_drop; else Next_state =State_data; State_checkCRC: if (CRC_err) Next_state =State_CRCErrEnd; else Next_state =State_OkEnd; State_drop: if (!Crs_dv) Next_state =State_ErrEnd; else Next_state =Current_state; State_OkEnd: Next_state =State_IFG; State_ErrEnd: Next_state =State_IFG; State_CRCErrEnd: Next_state =State_IFG;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -