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 33

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

powered by: WebSVN 2.1.0

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