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

Subversion Repositories sgmii

[/] [sgmii/] [trunk/] [build/] [OpenCore_MAC/] [flow_ctrl.v] - Blame information for rev 26

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 26 jefflieu
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  flow_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: not supported by cvs2svn $
42
// Revision 1.2  2005/12/16 06:44:19  Administrator
43
// replaced tab with space.
44
// passed 9.6k length frame test.
45
//
46
// Revision 1.1.1.1  2005/12/13 01:51:45  Administrator
47
// no message
48
//                                           
49
 
50
module flow_ctrl
51
(
52
Reset               ,
53
Clk                 ,
54
//host processor    ,
55
tx_pause_en         ,
56
xoff_cpu            ,
57
xon_cpu             ,
58
//MAC_rx_flow       ,
59
pause_quanta        ,
60
pause_quanta_val    ,
61
//MAC_tx_ctrl       ,
62
pause_apply         ,
63
pause_quanta_sub    ,
64
xoff_gen            ,
65
xoff_gen_complete   ,
66
xon_gen             ,
67
xon_gen_complete
68
 
69
);
70
 
71
input           Reset               ;
72
input           Clk                 ;
73
                //host processor    ;
74
input           tx_pause_en         ;
75
input           xoff_cpu            ;
76
input           xon_cpu             ;
77
                //MAC_rx_flow       ;
78
input   [15:0]  pause_quanta        ;
79
input           pause_quanta_val    ;
80
                //MAC_tx_ctrl       ;
81
output          pause_apply         ;
82
input           pause_quanta_sub    ;
83
output          xoff_gen            ;
84
input           xoff_gen_complete   ;
85
output          xon_gen             ;
86
input           xon_gen_complete    ;
87
 
88
//******************************************************************************
89
//internal signals                                                              
90
//******************************************************************************  
91
reg             xoff_cpu_dl1            ;
92
reg             xoff_cpu_dl2            ;
93
reg             xon_cpu_dl1             ;
94
reg             xon_cpu_dl2             ;
95
reg [15:0]      pause_quanta_dl1        ;
96
reg             pause_quanta_val_dl1    ;
97
reg             pause_quanta_val_dl2    ;
98
reg             pause_apply             ;
99
reg             xoff_gen                ;
100
reg             xon_gen                 ;
101
reg [15:0]      pause_quanta_counter    ;
102
reg             tx_pause_en_dl1         ;
103
reg             tx_pause_en_dl2         ;
104
//******************************************************************************  
105
//boundery signal processing                                                               
106
//******************************************************************************
107
always @ (posedge Clk or posedge Reset)
108
    if (Reset)
109
        begin
110
        xoff_cpu_dl1        <=0;
111
        xoff_cpu_dl2        <=0;
112
        end
113
    else
114
        begin
115
        xoff_cpu_dl1        <=xoff_cpu;
116
        xoff_cpu_dl2        <=xoff_cpu_dl1;
117
        end
118
 
119
always @ (posedge Clk or posedge Reset)
120
    if (Reset)
121
        begin
122
        xon_cpu_dl1     <=0;
123
        xon_cpu_dl2     <=0;
124
        end
125
    else
126
        begin
127
        xon_cpu_dl1     <=xon_cpu;
128
        xon_cpu_dl2     <=xon_cpu_dl1;
129
        end
130
 
131
always @ (posedge Clk or posedge Reset)
132
    if (Reset)
133
        begin
134
        pause_quanta_dl1        <=0;
135
        end
136
    else
137
        begin
138
        pause_quanta_dl1        <=pause_quanta;
139
        end
140
 
141
always @ (posedge Clk or posedge Reset)
142
    if (Reset)
143
        begin
144
        pause_quanta_val_dl1    <=0;
145
        pause_quanta_val_dl2    <=0;
146
        end
147
    else
148
        begin
149
        pause_quanta_val_dl1    <=pause_quanta_val;
150
        pause_quanta_val_dl2    <=pause_quanta_val_dl1;
151
        end
152
 
153
always @ (posedge Clk or posedge Reset)
154
    if (Reset)
155
        begin
156
        tx_pause_en_dl1     <=0;
157
        tx_pause_en_dl2     <=0;
158
        end
159
    else
160
        begin
161
        tx_pause_en_dl1     <=tx_pause_en;
162
        tx_pause_en_dl2     <=tx_pause_en_dl1;
163
        end
164
 
165
//******************************************************************************        
166
//gen output signals                                                            
167
//******************************************************************************
168
always @ (posedge Clk or posedge Reset)
169
    if (Reset)
170
        xoff_gen        <=0;
171
    else if (xoff_gen_complete)
172
        xoff_gen        <=0;
173
    else if (xoff_cpu_dl1&&!xoff_cpu_dl2)
174
        xoff_gen        <=1;
175
 
176
always @ (posedge Clk or posedge Reset)
177
    if (Reset)
178
        xon_gen     <=0;
179
    else if (xon_gen_complete)
180
        xon_gen     <=0;
181
    else if (xon_cpu_dl1&&!xon_cpu_dl2)
182
        xon_gen     <=1;
183
 
184
always @ (posedge Clk or posedge Reset)
185
    if (Reset)
186
        pause_quanta_counter    <=0;
187
    else if(pause_quanta_val_dl1&&!pause_quanta_val_dl2)
188
        pause_quanta_counter    <=pause_quanta_dl1;
189
    else if(pause_quanta_sub&&pause_quanta_counter!=0)
190
        pause_quanta_counter    <=pause_quanta_counter-1;
191
 
192
always @ (posedge Clk or posedge Reset)
193
    if (Reset)
194
        pause_apply     <=0;
195
    else if(pause_quanta_counter==0)
196
        pause_apply     <=0;
197
    else if (tx_pause_en_dl2)
198
        pause_apply     <=1;
199
 
200
endmodule

powered by: WebSVN 2.1.0

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