1 //////////////////////////////////////////////////////////////////////
3 //// RMON_addr_gen.v ////
5 //// This file is part of the Ethernet IP core project ////
6 //// http://www.opencores.org/projects.cgi/web/ethernet_tri_mode/////
9 //// - Jon Gao (gaojon@yahoo.com) ////
12 //////////////////////////////////////////////////////////////////////
14 //// Copyright (C) 2001 Authors ////
16 //// This source file may be used and distributed without ////
17 //// restriction provided that this copyright statement is not ////
18 //// removed from the file and that any derivative work contains ////
19 //// the original copyright notice and the associated disclaimer. ////
21 //// This source file is free software; you can redistribute it ////
22 //// and/or modify it under the terms of the GNU Lesser General ////
23 //// Public License as published by the Free Software Foundation; ////
24 //// either version 2.1 of the License, or (at your option) any ////
25 //// later version. ////
27 //// This source is distributed in the hope that it will be ////
28 //// useful, but WITHOUT ANY WARRANTY; without even the implied ////
29 //// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
30 //// PURPOSE. See the GNU Lesser General Public License for more ////
33 //// You should have received a copy of the GNU Lesser General ////
34 //// Public License along with this source; if not, download it ////
35 //// from http://www.opencores.org/lgpl.shtml ////
37 //////////////////////////////////////////////////////////////////////
39 // CVS Revision History
41 // $Log: RMON_addr_gen.v,v $
42 // Revision 1.4 2006/06/25 04:58:57 maverickist
45 // Revision 1.3 2006/01/19 14:07:55 maverickist
46 // verification is complete.
48 // Revision 1.2 2005/12/16 06:44:19 Administrator
49 // replaced tab with space.
50 // passed 9.6k length frame test.
52 // Revision 1.1.1.1 2005/12/13 01:51:45 Administrator
61 Apply_rmon ,//pluse signal looks like eop
74 input [2:0] Pkt_type_rmon ;
75 input [15:0] Pkt_length_rmon ;
76 input Apply_rmon ;//pluse signal looks like eop
77 input [2:0] Pkt_err_type_rmon ;
80 output [4:0] Reg_addr ;
81 output [15:0] Reg_data ;
84 output Reg_drop_apply ;
86 //******************************************************************************
88 //******************************************************************************
89 parameter StateIdle =4'd0;
90 parameter StatePktLength =4'd1;
91 parameter StatePktNumber =4'd2;
92 parameter StatePktType =4'd3;
93 parameter StatePktRange =4'd4;
95 reg [3:0] CurrentState /* synthesys syn_keep=1 */;
98 reg [2:0] PktTypeReg ;
99 reg [15:0] PktLengthReg ;
100 reg [2:0] PktErrTypeReg ;
104 reg [15:0] Reg_data ;
106 //******************************************************************************
107 //register boundery signals
109 //******************************************************************************
112 reg Apply_rmon_pulse;
113 reg [2:0] Pkt_type_rmon_dl1 ;
114 reg [15:0] Pkt_length_rmon_dl1 ;
115 reg [2:0] Pkt_err_type_rmon_dl1 ;
117 always @(posedge Clk or posedge Reset)
120 Pkt_type_rmon_dl1 <=0;
121 Pkt_length_rmon_dl1 <=0;
122 Pkt_err_type_rmon_dl1 <=0;
126 Pkt_type_rmon_dl1 <=Pkt_type_rmon ;
127 Pkt_length_rmon_dl1 <=Pkt_length_rmon ;
128 Pkt_err_type_rmon_dl1 <=Pkt_err_type_rmon ;
131 always @(posedge Clk or posedge Reset)
139 Apply_rmon_dl1 <=Apply_rmon;
140 Apply_rmon_dl2 <=Apply_rmon_dl1;
143 always @(Apply_rmon_dl1 or Apply_rmon_dl2)
144 if (Apply_rmon_dl1&!Apply_rmon_dl2)
151 always @(posedge Clk or posedge Reset)
158 else if (Apply_rmon_pulse&&CurrentState==StateIdle)
160 PktTypeReg <=Pkt_type_rmon_dl1 ;
161 PktLengthReg <=Pkt_length_rmon_dl1 ;
162 PktErrTypeReg <=Pkt_err_type_rmon_dl1 ;
166 //******************************************************************************
168 //******************************************************************************
169 always @(posedge Clk or posedge Reset)
171 CurrentState <=StateIdle;
173 CurrentState <=NextState;
175 always @(CurrentState or Apply_rmon_pulse or Reg_next)
178 if (Apply_rmon_pulse)
179 NextState =StatePktLength;
181 NextState =StateIdle;
184 NextState =StatePktNumber;
186 NextState =CurrentState;
189 NextState =StatePktType;
191 NextState =CurrentState;
194 NextState =StatePktRange;
196 NextState =CurrentState;
199 NextState =StateIdle;
201 NextState =CurrentState;
203 NextState =StateIdle;
206 //******************************************************************************
208 //******************************************************************************
210 always @ (CurrentState)
211 if (CurrentState==StatePktLength||CurrentState==StatePktNumber||
212 CurrentState==StatePktType||CurrentState==StatePktRange)
218 always @ (posedge Clk or posedge Reset)
221 else case (CurrentState)
229 Reg_addr <=5'd02; //broadcast
231 Reg_addr <=5'd03; //multicast
233 Reg_addr <=5'd16; //pause frame
235 Reg_addr <=5'd04; //unicast
248 else if (PktLengthReg==64)
250 else if (PktLengthReg<128)
252 else if (PktLengthReg<256)
254 else if (PktLengthReg<512)
256 else if (PktLengthReg<1024)
258 else if (PktLengthReg<1519)
270 always @ (CurrentState or PktLengthReg)
273 Reg_data =PktLengthReg;
285 always @ (posedge Clk or posedge Reset)
288 else if (CurrentState!=StateIdle&&Apply_rmon_pulse)