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

Subversion Repositories ethmac10g

[/] [ethmac10g/] [tags/] [V10/] [rtl/] [verilog/] [rx_engine/] [rxReceiveEngine.v] - Blame information for rev 74

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

Line No. Rev Author Line
1 39 fisher5090
//////////////////////////////////////////////////////////////////////
2
////                                                                                                                                                                    ////
3
//// MODULE NAME: receive engine                                                                                        ////
4
////                                                                                                                                                                    ////
5
//// DESCRIPTION: Receive Engine Top Level for the 10 Gigabit     ////
6
////     Ethernet MAC.                                                                                                                  ////
7
////                                                                                                                                                                    ////
8
//// This file is part of the 10 Gigabit Ethernet IP core project ////
9
////  http://www.opencores.org/projects/ethmac10g/                                              ////
10
////                                                                                                                                                                    ////
11
//// AUTHOR(S):                                                                                                                                 ////
12
//// Zheng Cao                                                               ////
13
////                                                                                                    ////
14
//////////////////////////////////////////////////////////////////////
15
////                                                                                                                                                                    ////
16
//// Copyright (c) 2005 AUTHORS.  All rights reserved.                     ////
17
////                                                                                                                                                                    ////
18
//// This source file may be used and distributed without         ////
19
//// restriction provided that this copyright statement is not    ////
20
//// removed from the file and that any derivative work contains  ////
21
//// the original copyright notice and the associated disclaimer. ////
22
////                                                              ////
23
//// This source file is free software; you can redistribute it   ////
24
//// and/or modify it under the terms of the GNU Lesser General   ////
25
//// Public License as published by the Free Software Foundation; ////
26
//// either version 2.1 of the License, or (at your option) any   ////
27
//// later version.                                               ////
28
////                                                              ////
29
//// This source is distributed in the hope that it will be       ////
30
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
31
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
32
//// PURPOSE.  See the GNU Lesser General Public License for more ////
33
//// details.                                                     ////
34
////                                                              ////
35
//// You should have received a copy of the GNU Lesser General    ////
36
//// Public License along with this source; if not, download it   ////
37
//// from http://www.opencores.org/lgpl.shtml                                                   ////
38
////                                                                                                                                                                    ////
39
//////////////////////////////////////////////////////////////////////
40
//
41
// CVS REVISION HISTORY:
42
//
43
// $Log: not supported by cvs2svn $
44
// Revision 1.1  2005/12/25 16:43:10  Zheng Cao
45
// No flow control included
46
// 
47
//
48
//////////////////////////////////////////////////////////////////////
49
 
50
`include "timescale.v"
51
`include "xgiga_define.v"
52
 
53
module rxReceiveEngine(rxclk_in, reset_in, rxd_in, rxc_in, rxStatRegPlus,
54
                       cfgRxRegData_in, rx_data, rx_data_valid, rx_good_frame,
55
                       rx_bad_frame, rxCfgofRS, rxTxLinkFault);//, fcTxPauseData, fcTxPauseValid);
56
    input rxclk_in; //Input clock of receive engine
57
    input reset_in; //Globle reset of receive engine
58
    input [31:0] rxd_in; //XGMII RXD
59
    input [3:0] rxc_in;  //XGMII RXC
60
    output [17:0] rxStatRegPlus; //Signals for statistics        
61
    input [64:0] cfgRxRegData_in; //Signals for configuration
62
    output [63:0] rx_data; //Received data sent to upper layer
63
    output [7:0] rx_data_valid; //Receive data valid indicator
64
    output rx_good_frame; //Indicate that a good frame has been received
65
    output rx_bad_frame; //Indicate that a bad frame has been received
66
         output[2:0] rxCfgofRS; //
67
    output [1:0] rxTxLinkFault;
68
//       output [31:0] fcTxPauseData;
69
//       output fcTxPauseValid;
70
 
71
         parameter TP =1;
72
 
73
    wire rxclk;
74
         wire rxclk_180;
75
         wire locked;
76
         wire reset_dcm;
77
         wire reset;
78
 
79
         reg [47:0]MAC_Addr;     //MAC Address used in receiving control frame.
80
    reg      vlan_enable; //VLAN Enable
81
         reg      recv_enable; //Receiver Enable
82
         reg      inband_fcs;   //In-band FCS Enable, when this bit is '1', the MAC will pass FCS up to client
83
         reg      jumbo_enable;//Jumbo Frame Enable
84
         reg      recv_rst;             //Receiver reset
85
 
86
         wire start_da, start_lt;
87
         wire tagged_frame;
88
         wire pause_frame;
89
         wire [47:0] da_addr;
90
//       wire [15:0] lt_data;
91
         wire [`COUNTER_WIDTH-1:0] frame_cnt;
92
         wire [2:0]  terminator_location;
93
         wire get_sfd,get_error_code,get_terminator, get_terminator_d1;
94
         wire receiving;
95
         wire receiving_d1,receiving_d2;
96
 
97
 
98
         wire length_error;
99
         wire large_error;
100
         wire small_error;
101
         wire padded_frame;
102
         wire length_65_127;
103
         wire length_128_255;
104
         wire length_256_511;
105
         wire length_512_1023;
106
         wire length_1024_max;
107
         wire jumbo_frame;
108
 
109
         wire local_invalid;
110
         wire broad_valid;
111
         wire multi_valid;
112
 
113
         wire good_frame_get, bad_frame_get;
114
         wire wait_crc_check;
115
 
116
         wire crc_check_valid;
117
         wire crc_check_invalid;
118
         wire check_reset;
119
 
120
         wire [1:0]link_fault;
121
 
122
         //////////////////////////////////////////
123
         // Input Registers
124
         //////////////////////////////////////////
125
 
126
         wire [63:0] rxd64;
127
         wire [63:0] CRC_DATA;
128
         wire [7:0] rxc8;
129
 
130
         assign rxTxLinkFault = link_fault;
131
//       assign fcTxPauseValid = pause_frame;
132
 
133
 
134
         //////////////////////////////////////////
135
         // Read Receiver Configuration Word
136
         //////////////////////////////////////////
137
 
138
         reg[52:0] cfgRxRegData;
139
         always@(posedge rxclk or posedge reset)begin
140
                if(reset)
141
                             cfgRxRegData <=#TP 0;
142
                          else
143
                             cfgRxRegData<=#TP cfgRxRegData_in;
144
         end
145
 
146
         always@(posedge rxclk or posedge reset)begin
147
                if(reset) begin
148
                             MAC_Addr <= 0;
149
                   vlan_enable <= 0;
150
                   recv_enable <= 0;
151
                   inband_fcs  <= 0;
152
                   jumbo_enable <= 0;
153
                   recv_rst <= 0;
154
                          end
155
                          else begin
156
                             MAC_Addr <= cfgRxRegData[47:0];
157
                   vlan_enable <= cfgRxRegData[48];
158
                   recv_enable <= cfgRxRegData[49];
159
                   inband_fcs  <= cfgRxRegData[50];
160
                   jumbo_enable <= cfgRxRegData[51];
161
                   recv_rst <= cfgRxRegData[52];
162
                          end
163
    end
164
     //////////////////////////////////////////////////
165
         // Used to count number of received frames(G&B)
166
         //////////////////////////////////////////////////
167
         reg[7:0] cnt;
168
         reg cnt_en;
169
         always@(posedge rxclk or posedge reset) begin
170
               if (reset)
171
                            cnt_en <=0;
172
                         else if(get_sfd)
173
                  cnt_en <=1;
174
          else if(rx_bad_frame|rx_good_frame)
175
             cnt_en <=0;
176
          else
177
             cnt_en <=cnt_en;
178
    end
179
 
180
    always@(posedge rxclk or posedge reset) begin
181
          if (reset)
182
             cnt <=0;
183
          else if(cnt_en)
184
             cnt<=cnt + 1;
185
          else
186
             cnt <=0;
187
    end
188
 
189
         /////////////////////////////////////////
190
         // Reset signals
191
         /////////////////////////////////////////
192
         assign  reset_dcm = reset_in | recv_rst;
193
         assign  reset = ~locked;
194
 
195
         /////////////////////////////////////////
196
         // Write Configuration Words   of RS 
197
         /////////////////////////////////////////
198
 
199
         assign rxCfgofRS[0] = ~link_fault[0] & link_fault[1]; //get local fault
200
         assign rxCfgofRS[1] = link_fault[0] & link_fault[1];  //get remote fault
201
         assign rxCfgofRS[2] = locked;  //Receive DCM locked
202
 
203
         ////////////////////////////////////////
204
         // Signals for Pause Operation
205
         ////////////////////////////////////////
206
         assign fcTxPauseValid = pause_frame;
207
//       assign fcTxPauseData = {16{1'b0},rxd64[15:0]};
208
 
209
         ////////////////////////////////////////
210
         // Receive Clock Generator
211
         //////////////////////////////////////// 
212
 
213
         rxClkgen rxclk_gen(.rxclk_in(rxclk_in),
214
                            .reset(reset_dcm),
215
                                                          .rxclk(rxclk),    // system clock
216
                                                          .rxclk_180(rxclk_180), //reversed clock
217
                                                          .locked(locked)
218
                                                          );
219
 
220
         //////////////////////////////////////
221
    // Rx Engine DataPath
222
         //////////////////////////////////////
223
         rxDataPath datapath_main(.rxclk(rxclk), .reset(reset), .rxd64(rxd64), .rxc8(rxc8), .inband_fcs(inband_fcs), .receiving(receiving),
224
                                  .start_da(start_da), .start_lt(start_lt), .wait_crc_check(wait_crc_check), .get_sfd(get_sfd),
225
                             .get_terminator(get_terminator), .get_error_code(get_error_code), .tagged_frame(tagged_frame), .pause_frame(pause_frame),
226
                                                                          .da_addr(da_addr), .terminator_location(terminator_location), .CRC_DATA(CRC_DATA), .rx_data_valid(rx_data_valid),
227
                                                                          .rx_data(rx_data), .get_terminator_d1(get_terminator_d1),.bad_frame_get(bad_frame_get),.good_frame_get(good_frame_get),
228
                                                                          .check_reset(check_reset),.rx_good_frame(rx_good_frame),.rx_bad_frame(rx_bad_frame));//,.fcTxPauseData(fcTxPauseData));
229
 
230
         //////////////////////////////////////
231
         // Destination Address Checker
232
         //////////////////////////////////////
233
 
234
         rxDAchecker  dachecker(.rxclk(rxclk), .reset(reset), .local_invalid(local_invalid), .broad_valid(broad_valid), .multi_valid(multi_valid), .MAC_Addr(MAC_Addr),
235
                                .da_addr(da_addr));
236
 
237
    /////////////////////////////////////
238
         // Length/Type field checker
239
         /////////////////////////////////////
240
 
241
         rxLenTypChecker lenchecker(.rxclk(rxclk), .reset(reset), .get_terminator(get_terminator), .terminator_location(terminator_location),
242
                                    .jumbo_enable(jumbo_enable), .tagged_frame(tagged_frame), .frame_cnt(frame_cnt), .vlan_enable(vlan_enable),
243
                                                                                 .length_error(length_error), .large_error(large_error),.small_error(small_error), .padded_frame(padded_frame),
244
                                                        .length_65_127(length_65_127), .length_128_255(length_128_255), .length_256_511(length_256_511), .length_512_1023(length_512_1023),
245
                                                        .length_1024_max(length_1024_max), .jumbo_frame(jumbo_frame)
246
                                                                                 );
247
 
248
         /////////////////////////////////////
249
         // Counters used in Receive Engine
250
         /////////////////////////////////////
251
 
252
    rxNumCounter counters(.rxclk(rxclk), .reset(reset), .receiving(receiving), .frame_cnt(frame_cnt));
253
 
254
         /////////////////////////////////////
255
         // State Machine in Receive Process
256
         /////////////////////////////////////
257
 
258
    rxStateMachine statemachine(.rxclk(rxclk), .reset(reset), .recv_enable(recv_enable), .get_sfd(get_sfd), .local_invalid(local_invalid),
259
                                     .length_error(length_error), .crc_check_valid(crc_check_valid), .crc_check_invalid(crc_check_invalid),
260
                                .start_da(start_da), .start_lt(start_lt), .receiving(receiving),.good_frame_get(good_frame_get),
261
                                                                                  .bad_frame_get(bad_frame_get), .get_error_code(get_error_code), .wait_crc_check(wait_crc_check), .get_terminator(get_terminator),
262
                                                                                  .receiving_d1(receiving_d1),.check_reset(check_reset));
263
 
264
         /////////////////////////////////////
265
         // CRC Check module
266
         /////////////////////////////////////
267
         rxCRC crcmodule(.rxclk(rxclk), .reset(reset), .CRC_DATA(CRC_DATA), .get_terminator(get_terminator), .terminator_location(terminator_location),
268
                         .crc_check_invalid(crc_check_invalid), .crc_check_valid(crc_check_valid),.receiving(receiving),.receiving_d1(receiving_d1),
269
                                                  .get_terminator_d1(get_terminator_d1), .wait_crc_check(wait_crc_check),.get_error_code(get_error_code));
270
    /////////////////////////////////////
271
         // RS Layer
272
         /////////////////////////////////////
273
    rxRSLayer rx_rs(.rxclk(rxclk), .rxclk_180(rxclk_180), .reset(reset), .link_fault(link_fault), .rxd64(rxd64), .rxc8(rxc8), .rxd_in(rxd_in), .rxc_in(rxc_in));
274
 
275
         /////////////////////////////////////
276
         // Statistic module
277
         /////////////////////////////////////
278
         rxStatModule rx_stat(.rxclk(rxclk),.reset(reset),.good_frame_get(good_frame_get), .large_error(large_error),.small_error(small_error), .crc_check_invalid(crc_check_invalid),
279
                 .receiving(receiving), .padded_frame(padded_frame), .pause_frame(pause_frame), .broad_valid(broad_valid), .multi_valid(multi_valid),
280
                                          .length_65_127(length_65_127), .length_128_255(length_128_255), .length_256_511(length_256_511), .length_512_1023(length_512_1023),
281
                                          .length_1024_max(length_1024_max), .jumbo_frame(jumbo_frame),.get_error_code(get_error_code), .rxStatRegPlus(rxStatRegPlus));
282
endmodule

powered by: WebSVN 2.1.0

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