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

Subversion Repositories xge_ll_mac

[/] [xge_ll_mac/] [trunk/] [rtl/] [rx_control.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 cleberCAG
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  This file is part of the "10GE LL MAC" project              ////
4
////  http://www.opencores.org/cores/xge_ll_mac/                  ////
5
////                                                              ////
6
////  This project is derived from the "10GE MAC" project of      ////
7
////  A. Tanguay (antanguay@opencores.org) by Andreas Peters      ////
8
////  for his Diploma Thesis at the University of Heidelberg.     ////
9
////  The Thesis was supervised by Christian Leber                ////
10
////                                                              ////
11
////  Author(s):                                                  ////
12
////      - Andreas Peters                                        ////
13
////                                                              ////
14
//////////////////////////////////////////////////////////////////////
15
////                                                              ////
16
//// Copyright (C) 2008-2012 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
`include "oc_mac.h"
42
 
43
//`include "technology.h"
44
 
45
`default_nettype none
46
 
47
module rx_control(
48
                // Inputs
49
                input wire              clk,
50
                input wire              res_n,
51
                input wire [63:0]        rx_inc_data,
52
                input wire [7:0] rx_inc_status,
53
                // Outputs
54
 
55
                output reg [63:0]        rx_data,
56
                output reg [7:0] rx_data_valid,
57
                output reg              rx_good_frame,
58
                output reg              rx_bad_frame);
59
 
60
 
61
reg     error;
62
 
63
 
64
`ifdef ASYNC_RES
65
always @(posedge clk or negedge res_n) `else
66
always @(posedge clk) `endif
67
begin
68
        if (res_n == 1'b0) begin
69
 
70
                rx_data <= 64'b0;
71
                rx_data_valid <= 8'b0;
72
                rx_good_frame <= 1'b0;
73
                rx_bad_frame <= 1'b0;
74
                error <= 1'b0;
75
        end
76
        else begin
77
 
78
        rx_data <= rx_inc_data;
79
 
80
        case ({rx_inc_status[`RXSTATUS_SOP], rx_inc_status[`RXSTATUS_EOP], rx_inc_status[`RXSTATUS_VALID], rx_inc_status[`RXSTATUS_ERR]})
81
                4'b1010: begin  // normal start
82
                                rx_data_valid <= 8'hff;
83
                                error <= 1'b0;
84
                                rx_bad_frame <= 1'b0;
85
                                rx_good_frame <= 1'b0;
86
                        end
87
                4'b0110: begin // normal end
88
                                if (error) begin
89
                                        rx_bad_frame <= 1'b1;
90
                                        rx_good_frame <= 1'b0;
91
                                end
92
                                else begin
93
                                        rx_bad_frame <= 1'b0;
94
                                        rx_good_frame <= 1'b1;
95
                                end
96
                                case(rx_inc_status[2:0])
97
                                        3'b000:  rx_data_valid  <= 8'b11111111;
98
                                        3'b001:  rx_data_valid  <= 8'b00000001;
99
                                        3'b010:  rx_data_valid  <= 8'b00000011;
100
                                        3'b011:  rx_data_valid  <= 8'b00000111;
101
                                        3'b100:  rx_data_valid  <= 8'b00001111;
102
                                        3'b101:  rx_data_valid  <= 8'b00011111;
103
                                        3'b110:  rx_data_valid  <= 8'b00111111;
104
                                        default: rx_data_valid  <= 8'b01111111;
105
                                endcase
106
                        end
107
                4'b0111: begin // end of frame bad
108
                                rx_bad_frame <= 1'b1;
109
                                rx_good_frame <= 1'b0;
110
                                case(rx_inc_status[2:0])
111
                                        3'b000:  rx_data_valid  <= 8'b11111111;
112
                                        3'b001:  rx_data_valid  <= 8'b00000001;
113
                                        3'b010:  rx_data_valid  <= 8'b00000011;
114
                                        3'b011:  rx_data_valid  <= 8'b00000111;
115
                                        3'b100:  rx_data_valid  <= 8'b00001111;
116
                                        3'b101:  rx_data_valid  <= 8'b00011111;
117
                                        3'b110:  rx_data_valid  <= 8'b00111111;
118
                                        default: rx_data_valid  <= 8'b01111111;
119
                                endcase
120
                        end
121
                4'b0010: begin // ongoing transmission
122
                                rx_data_valid <= 8'hff;
123
                                rx_bad_frame <= 1'b0;
124
                                rx_good_frame <= 1'b0;
125
                        end
126
                4'b0011: begin
127
                                rx_data_valid <= 8'hff;
128
                                error <= 1'b1;
129
                                rx_bad_frame <= 1'b0;
130
                                rx_good_frame <= 1'b0;
131
                        end
132
 
133
                default: begin
134
                                rx_data_valid <= 8'h00;
135
                                error <= 1'b1;
136
                                rx_bad_frame <= 1'b0;
137
                                rx_good_frame <= 1'b0;
138
                        end
139
        endcase
140
        end
141
 
142
 
143
end
144
 
145
endmodule
146
`default_nettype wire

powered by: WebSVN 2.1.0

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