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

Subversion Repositories srdydrdy_lib

[/] [srdydrdy_lib/] [trunk/] [external/] [ethernet_tri_mode/] [RMON/] [RMON_ctrl.v] - Blame information for rev 23

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 23 ghutchis
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  RMON_CTRL.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
// $Log: RMON_ctrl.v,v $
42
// Revision 1.4  2006/06/25 04:58:57  maverickist
43
// no message
44
//
45
// Revision 1.3  2006/01/19 14:07:55  maverickist
46
// verification is complete.
47
//
48
// Revision 1.2  2005/12/16 06:44:19  Administrator
49
// replaced tab with space.
50
// passed 9.6k length frame test.
51
//
52
// Revision 1.1.1.1  2005/12/13 01:51:45  Administrator
53
// no message
54
//  
55
module RMON_CTRL (
56
Clk             ,
57
Reset           ,
58
//RMON_CTRL        
59
Reg_apply_0     ,
60
Reg_addr_0      ,
61
Reg_data_0      ,
62
Reg_next_0      ,
63
Reg_apply_1     ,
64
Reg_addr_1      ,
65
Reg_data_1      ,
66
Reg_next_1      ,
67
//dual-port ram
68
Addra               ,
69
Dina                ,
70
Douta               ,
71
Wea                 ,
72
//CPU                  
73
CPU_rd_addr     ,
74
CPU_rd_apply        ,
75
CPU_rd_grant        ,
76
CPU_rd_dout
77
 
78
);
79
input           Clk             ;
80
input           Reset           ;
81
                //RMON_CTRL
82
input           Reg_apply_0     ;
83
input   [4:0]   Reg_addr_0      ;
84
input   [15:0]  Reg_data_0      ;
85
output          Reg_next_0      ;
86
input           Reg_apply_1     ;
87
input   [4:0]   Reg_addr_1      ;
88
input   [15:0]  Reg_data_1      ;
89
output          Reg_next_1      ;
90
                //dual-port ram 
91
                //port-a for Rmon  
92
output  [5:0]   Addra               ;
93
output  [31:0]  Dina                ;
94
input   [31:0]  Douta               ;
95
output          Wea                 ;
96
                //CPU
97
input   [5:0]   CPU_rd_addr         ;
98
input           CPU_rd_apply        ;
99
output          CPU_rd_grant        ;
100
output  [31:0]  CPU_rd_dout         ;
101
 
102
 
103
 
104
 
105
//******************************************************************************
106
//internal signals                                                              
107
//******************************************************************************
108
 
109
parameter       StateCPU        =4'd00;
110
parameter       StateMAC0       =4'd01;
111
parameter       StateMAC1       =4'd02;
112
 
113
 
114
reg [3:0]       CurrentState /* synthesys syn_keep=1 */;
115
reg [3:0]       NextState;
116
reg [3:0]       CurrentState_reg;
117
 
118
reg [4:0]       StepCounter;
119
reg [31:0]      DoutaReg;
120
reg [5:0]       Addra               ;
121
reg [31:0]      Dina;
122
reg             Reg_next_0      ;
123
reg             Reg_next_1      ;
124
reg             Write;
125
reg             Read;
126
reg             Pipeline;
127
reg [31:0]      CPU_rd_dout         ;
128
reg             CPU_rd_apply_reg    ;
129
//******************************************************************************
130
//State Machine                                                            
131
//******************************************************************************
132
 
133
always @(posedge Clk or posedge Reset)
134
    if (Reset)
135
        CurrentState    <=StateMAC0;
136
    else
137
        CurrentState    <=NextState;
138
 
139
always @(posedge Clk or posedge Reset)
140
    if (Reset)
141
        CurrentState_reg    <=StateMAC0;
142
    else if(CurrentState!=StateCPU)
143
        CurrentState_reg    <=CurrentState;
144
 
145
always @(CurrentState or CPU_rd_apply_reg or Reg_apply_0 or CurrentState_reg
146
                                       or Reg_apply_1
147
                                       or StepCounter
148
                                       )
149
    case(CurrentState)
150
        StateMAC0:
151
            if(!Reg_apply_0&&CPU_rd_apply_reg)
152
                NextState   =StateCPU;
153
            else if(!Reg_apply_0)
154
                NextState   =StateMAC1;
155
            else
156
                NextState   =CurrentState;
157
        StateMAC1:
158
            if(!Reg_apply_1&&CPU_rd_apply_reg)
159
                NextState   =StateCPU;
160
            else if(!Reg_apply_1)
161
                NextState   =StateMAC0;
162
            else
163
                NextState   =CurrentState;
164
        StateCPU:
165
            if (StepCounter==3)
166
                case (CurrentState_reg)
167
                    StateMAC0   :NextState  =StateMAC0 ;
168
                    StateMAC1   :NextState  =StateMAC1 ;
169
                    default     :NextState  =StateMAC0;
170
                endcase
171
            else
172
                NextState   =CurrentState;
173
 
174
        default:
175
                NextState   =StateMAC0;
176
    endcase
177
 
178
 
179
 
180
always @(posedge Clk or posedge Reset)
181
    if (Reset)
182
        StepCounter     <=0;
183
    else if(NextState!=CurrentState)
184
        StepCounter     <=0;
185
    else if (StepCounter!=4'hf)
186
        StepCounter     <=StepCounter + 1;
187
 
188
//******************************************************************************
189
//temp signals                                                            
190
//******************************************************************************
191
always @(StepCounter)
192
    if( StepCounter==1||StepCounter==4||
193
        StepCounter==7||StepCounter==10)
194
        Read    =1;
195
    else
196
        Read    =0;
197
 
198
always @(StepCounter or CurrentState)
199
    if( StepCounter==2||StepCounter==5||
200
        StepCounter==8||StepCounter==11)
201
        Pipeline    =1;
202
    else
203
        Pipeline    =0;
204
 
205
always @(StepCounter or CurrentState)
206
    if( StepCounter==3||StepCounter==6||
207
        StepCounter==9||StepCounter==12)
208
        Write   =1;
209
    else
210
        Write   =0;
211
 
212
always @(posedge Clk or posedge Reset)
213
    if (Reset)
214
        DoutaReg        <=0;
215
    else if (Read)
216
        DoutaReg        <=Douta;
217
 
218
 
219
//******************************************************************************
220
//gen output signals                                                        
221
//******************************************************************************    
222
//Addra 
223
always @(*)
224
    case(CurrentState)
225
        StateMAC0 :     Addra={1'd0 ,Reg_addr_0 };
226
        StateMAC1 :     Addra={1'd1 ,Reg_addr_1 };
227
        StateCPU:       Addra=CPU_rd_addr;
228
        default:        Addra=0;
229
        endcase
230
 
231
//Dina
232
always @(posedge Clk or posedge Reset)
233
    if (Reset)
234
        Dina    <=0;
235
    else
236
        case(CurrentState)
237
            StateMAC0 :     Dina<=Douta+Reg_data_0 ;
238
            StateMAC1 :     Dina<=Douta+Reg_data_1 ;
239
            StateCPU:       Dina<=0;
240
            default:        Dina<=0;
241
        endcase
242
 
243
assign  Wea     =Write;
244
//Reg_next
245
always @(CurrentState or Pipeline)
246
    if(CurrentState==StateMAC0)
247
        Reg_next_0  =Pipeline;
248
    else
249
        Reg_next_0  =0;
250
 
251
always @(CurrentState or Pipeline)
252
    if(CurrentState==StateMAC1)
253
        Reg_next_1  =Pipeline;
254
    else
255
        Reg_next_1  =0;
256
 
257
 
258
//CPU_rd_grant   
259
reg     CPU_rd_apply_dl1;
260
reg     CPU_rd_apply_dl2;
261
//rising edge
262
always @ (posedge Clk or posedge Reset)
263
    if (Reset)
264
        begin
265
        CPU_rd_apply_dl1        <=0;
266
        CPU_rd_apply_dl2        <=0;
267
        end
268
    else
269
        begin
270
        CPU_rd_apply_dl1        <=CPU_rd_apply;
271
        CPU_rd_apply_dl2        <=CPU_rd_apply_dl1;
272
        end
273
 
274
always @ (posedge Clk or posedge Reset)
275
    if (Reset)
276
        CPU_rd_apply_reg    <=0;
277
    else if (CPU_rd_apply_dl1&!CPU_rd_apply_dl2)
278
        CPU_rd_apply_reg    <=1;
279
    else if (CurrentState==StateCPU&&Write)
280
        CPU_rd_apply_reg    <=0;
281
 
282
assign CPU_rd_grant =!CPU_rd_apply_reg;
283
 
284
always @ (posedge Clk or posedge Reset)
285
    if (Reset)
286
        CPU_rd_dout     <=0;
287
    else if (Pipeline&&CurrentState==StateCPU)
288
        CPU_rd_dout     <=Douta;
289
 
290
endmodule

powered by: WebSVN 2.1.0

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