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

Subversion Repositories ethernet_tri_mode

[/] [ethernet_tri_mode/] [trunk/] [rtl/] [verilog/] [RMON/] [RMON_addr_gen.v] - Blame information for rev 6

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 5 maverickis
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  RMON_addr_gen.v                                             ////
4
////                                                              ////
5
////  This file is part of the Ethernet IP core project           ////
6
////  http://www.opencores.org/projects.cgi/web/ethernet_tri_mode/////
7
////                                                              ////
8
////  Author(s):                                                  ////
9
////      - Jon Gao (gaojon@yahoo.com)                            ////
10
////                                                              ////
11
////                                                              ////
12
//////////////////////////////////////////////////////////////////////
13
////                                                              ////
14
//// Copyright (C) 2001 Authors                                   ////
15
////                                                              ////
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. ////
20
////                                                              ////
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.                                               ////
26
////                                                              ////
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 ////
31
//// details.                                                     ////
32
////                                                              ////
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                     ////
36
////                                                              ////
37
//////////////////////////////////////////////////////////////////////
38
//                                                                    
39
// CVS Revision History                                               
40
//                                                                    
41 6 maverickis
// $Log: not supported by cvs2svn $
42
// Revision 1.1.1.1  2005/12/13 01:51:45  Administrator
43
// no message
44
//         
45 5 maverickis
module RMON_addr_gen(
46
Clk                                     ,
47
Reset                           ,
48
//RMON                                             
49
Pkt_type_rmon           ,
50
Pkt_length_rmon         ,
51
Apply_rmon              ,//pluse signal looks like eop 
52
Pkt_err_type_rmon       ,
53
//                                                 
54
Reg_apply                       ,
55
Reg_addr                        ,
56
Reg_data                        ,
57
Reg_next                        ,
58
//CPU                                              
59
Reg_drop_apply
60
);
61
input                   Clk                                     ;
62
input                   Reset                           ;
63
                                //RMON
64
input[2:0]               Pkt_type_rmon           ;
65
input[15:0]              Pkt_length_rmon         ;
66
input                   Apply_rmon              ;//pluse signal looks like eop
67
input[2:0]               Pkt_err_type_rmon       ;
68
                                //RMON_ctrl
69
output                  Reg_apply                       ;
70
output[4:0]              Reg_addr                        ;
71
output[15:0]     Reg_data                        ;
72
input                   Reg_next                        ;
73
                                //CPU
74
output                  Reg_drop_apply          ;
75
 
76
//******************************************************************************
77
//internal signals                                                              
78
//******************************************************************************
79
parameter               StateIdle               =5'b00001;
80
parameter               StatePktLength  =5'b00010;
81
parameter               StatePktNumber  =5'b00100;
82
parameter               StatePktType    =5'b01000;
83
parameter               StatePktRange   =5'b10000;
84
 
85
reg[4:0]         CurrentState;
86
reg[4:0]         NextState;
87
 
88
reg[2:0]         PktTypeReg              ;
89
reg[15:0]                PktLengthReg    ;
90
reg[2:0]         PktErrTypeReg   ;
91
 
92
reg                             Reg_apply               ;
93
reg[4:0]         Reg_addr                        ;
94
reg[15:0]                Reg_data                        ;
95
reg                             Reg_drop_apply  ;
96
//******************************************************************************
97
//register boundery signals    
98
 
99
//******************************************************************************
100
reg                             Apply_rmon_dl1;
101
reg                             Apply_rmon_dl2;
102
reg                             Apply_rmon_pulse;
103
reg[2:0]         Pkt_type_rmon_dl1               ;
104
reg[15:0]                Pkt_length_rmon_dl1         ;
105
reg[2:0]         Pkt_err_type_rmon_dl1   ;
106
 
107
always @(posedge Clk or posedge Reset)
108
        if (Reset)
109
                begin
110
                Pkt_type_rmon_dl1               <=0;
111
                Pkt_length_rmon_dl1         <=0;
112
                Pkt_err_type_rmon_dl1   <=0;
113
                end
114
        else
115
                begin
116
                Pkt_type_rmon_dl1               <=Pkt_type_rmon         ;
117
                Pkt_length_rmon_dl1         <=Pkt_length_rmon   ;
118
                Pkt_err_type_rmon_dl1   <=Pkt_err_type_rmon     ;
119
                end
120
 
121
always @(posedge Clk or posedge Reset)
122
        if (Reset)
123
                begin
124
                Apply_rmon_dl1  <=0;
125
                Apply_rmon_dl2  <=0;
126
                end
127
        else
128
                begin
129
                Apply_rmon_dl1  <=Apply_rmon;
130
                Apply_rmon_dl2  <=Apply_rmon_dl1;
131
                end
132
 
133
always @(Apply_rmon_dl1 or Apply_rmon_dl2)
134
        if (Apply_rmon_dl1&!Apply_rmon_dl2)
135
                Apply_rmon_pulse        =1;
136
        else
137
                Apply_rmon_pulse        =0;
138
 
139
 
140
 
141
always @(posedge Clk or posedge Reset)
142
        if (Reset)
143
                begin
144
                PktTypeReg                      <=0;
145
                PktLengthReg        <=0;
146
                PktErrTypeReg       <=0;
147
                end
148
        else if (Apply_rmon_pulse&&CurrentState==StateIdle)
149
                begin
150
                PktTypeReg                      <=Pkt_type_rmon_dl1             ;
151
                PktLengthReg        <=Pkt_length_rmon_dl1       ;
152
                PktErrTypeReg       <=Pkt_err_type_rmon_dl1     ;
153
                end
154
 
155
 
156
//******************************************************************************
157
//State Machine                                                             
158
//******************************************************************************
159
always @(posedge Clk or posedge Reset)
160
        if (Reset)
161
                CurrentState    <=StateIdle;
162
        else
163
                CurrentState    <=NextState;
164
 
165
always @(CurrentState or Apply_rmon_pulse or Reg_next)
166
        case (CurrentState)
167
                StateIdle:
168
                        if (Apply_rmon_pulse)
169
                                NextState       =StatePktLength;
170
                        else
171
                                NextState       =StateIdle;
172
                StatePktLength:
173
                        if (Reg_next)
174
                                NextState       =StatePktNumber;
175
                        else
176
                                NextState       =CurrentState;
177
                StatePktNumber:
178
                        if (Reg_next)
179
                                NextState       =StatePktType;
180
                        else
181
                                NextState       =CurrentState;
182
                StatePktType:
183
                        if (Reg_next)
184
                                NextState       =StatePktRange;
185
                        else
186
                                NextState       =CurrentState;
187
                StatePktRange:
188
                        if (Reg_next)
189
                                NextState       =StateIdle;
190
                        else
191
                                NextState       =CurrentState;
192
                default:
193
                                NextState       =StateIdle;
194
        endcase
195
 
196
//******************************************************************************
197
//gen output signals                                                            
198
//******************************************************************************
199
//Reg_apply
200
always @ (CurrentState)
201
        if (CurrentState==StatePktLength||CurrentState==StatePktNumber||
202
                CurrentState==StatePktType||CurrentState==StatePktRange)
203
                Reg_apply       =1;
204
        else
205
                Reg_apply       =0;
206
 
207
//Reg_addr
208
always @ (posedge Clk or posedge Reset)
209
        if (Reset)
210
                Reg_addr        <=0;
211
        else case (CurrentState)
212
                        StatePktLength:
213
                                Reg_addr        <=5'd00;
214
                        StatePktNumber:
215
                                Reg_addr        <=5'd01;
216
                        StatePktType:
217
                                case(PktTypeReg)
218
                                        3'b011:
219
                                                Reg_addr        <=5'd02;        //broadcast
220
                                        3'b001:
221
                                                Reg_addr        <=5'd03;        //multicast     
222
                                        3'b100:
223
                                                Reg_addr        <=5'd16;        //pause frame   
224
                                        default:
225
                                                Reg_addr        <=5'd04;        //unicast
226
                                endcase
227
                        StatePktRange:
228
                                case(PktErrTypeReg)
229
                                        3'b001:
230
                                                Reg_addr        <=5'd05;
231
                                        3'b010:
232
                                                Reg_addr        <=5'd06;
233
                                        3'b011:
234
                                                Reg_addr        <=5'd07;
235
                                        3'b100:
236
                                                if (PktLengthReg<64)
237
                                                        Reg_addr        <=5'd08;
238
                                                else if (PktLengthReg==64)
239
                                                        Reg_addr        <=5'd09;
240
                                                else if (PktLengthReg<128)
241
                                                        Reg_addr        <=5'd10;
242
                                                else if (PktLengthReg<256)
243
                                                        Reg_addr        <=5'd11;
244
                                                else if (PktLengthReg<512)
245
                                                        Reg_addr        <=5'd12;
246
                                                else if (PktLengthReg<1024)
247
                                                        Reg_addr        <=5'd13;
248
                                                else if (PktLengthReg<1519)
249
                                                        Reg_addr        <=5'd14;
250
                                                else
251
                                                        Reg_addr        <=5'd15;
252
                                        default:
253
                                                Reg_addr        <=5'd05;
254
                                endcase
255
                        default:
256
                                        Reg_addr        <=5'd05;
257
                endcase
258
 
259
//Reg_data
260
always @ (CurrentState or PktLengthReg)
261
        case (CurrentState)
262
                StatePktLength:
263
                        Reg_data        =PktLengthReg;
264
                StatePktNumber:
265
                        Reg_data        =1;
266
                StatePktType:
267
                        Reg_data =1;
268
                StatePktRange:
269
                        Reg_data =1;
270
                default:
271
                        Reg_data =0;
272
        endcase
273
 
274
//Reg_drop_apply
275
always @ (posedge Clk or posedge Reset)
276
        if (Reset)
277
                Reg_drop_apply  <=0;
278
        else if (CurrentState!=StateIdle&&Apply_rmon_pulse)
279
                Reg_drop_apply  <=1;
280
        else
281
                Reg_drop_apply  <=0;
282
 
283
 
284
endmodule
285
 

powered by: WebSVN 2.1.0

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