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

Subversion Repositories ethmac10g

[/] [ethmac10g/] [trunk/] [rtl/] [verilog/] [rx_engine/] [rxLinkFaultState.v] - Blame information for rev 72

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 39 fisher5090
//////////////////////////////////////////////////////////////////////
2 69 fisher5090
////                                                              ////
3
//// MODULE NAME:  rxLinkFaultState                               ////
4
////                                                              ////
5 39 fisher5090
//// DESCRIPTION: State machine for Link Fault Signalling.        ////
6
////                                                              ////
7 69 fisher5090
////                                                              ////
8 39 fisher5090
//// This file is part of the 10 Gigabit Ethernet IP core project ////
9 69 fisher5090
////  http://www.opencores.org/projects/ethmac10g/                ////
10
////                                                              ////
11
//// AUTHOR(S):                                                   ////
12
//// Zheng Cao                                                    ////
13
////                                                              ////
14 39 fisher5090
//////////////////////////////////////////////////////////////////////
15 69 fisher5090
////                                                              ////
16
//// Copyright (c) 2005 AUTHORS.  All rights reserved.            ////
17
////                                                              ////
18 39 fisher5090
//// 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 69 fisher5090
//// from http://www.opencores.org/lgpl.shtml                     ////
38
////                                                              ////
39 39 fisher5090
//////////////////////////////////////////////////////////////////////
40
//
41
// CVS REVISION HISTORY:
42
//
43
// $Log: not supported by cvs2svn $
44 69 fisher5090
// Revision 1.1.1.1  2006/05/31 05:59:42  fisher5090
45
// first version
46
//
47 39 fisher5090
// Revision 1.1  2005/12/25 16:43:10  Zheng Cao
48
// 
49
// 
50
//
51
//////////////////////////////////////////////////////////////////////
52
 
53
`include "timescale.v"
54
`include "xgiga_define.v"
55
 
56
module rxLinkFaultState(rxclk, reset, local_fault, remote_fault, link_fault);
57
    input rxclk;
58
    input reset;
59
    input local_fault;
60
    input remote_fault;
61
    output[1:0] link_fault;
62 69 fisher5090
 
63
    parameter TP =1;
64
    parameter IDLE = 0, LinkFaultDetect = 1, NewFaultType = 2, GetFault = 3;
65 39 fisher5090
 
66 69 fisher5090
    //------------------------------------------------
67
    // Link     Fault Signalling Statemachine
68
    //------------------------------------------------
69
    wire  fault_type;
70
    wire  get_one_fault;
71
    wire  no_new_type;
72 39 fisher5090
 
73 69 fisher5090
    reg[2:0] linkstate, linkstate_next;
74
    reg[5:0] col_cnt;
75
    reg      seq_cnt;
76
    reg[1:0] seq_type;
77
    reg[1:0] last_seq_type;
78
    reg[1:0] link_fault;
79
    reg      reset_col_cnt;
80
    wire     seq_cnt_3;
81
    wire     col_cnt_64;
82 39 fisher5090
 
83 69 fisher5090
    assign fault_type = {local_fault, remote_fault};
84
    assign get_one_fault = local_fault | remote_fault;
85
    assign no_new_type = (seq_type == last_seq_type);
86
    assign col_cnt_64 = & col_cnt;
87
 
88
    always@(posedge rxclk or posedge reset)begin
89
         if (reset) begin
90
           seq_type <=#TP 0;
91
           seq_cnt <=#TP 0;
92
           last_seq_type <=#TP 0;
93
           reset_col_cnt<= #TP 1;
94
           link_fault <=#TP 2'b00;
95
           linkstate<= #TP IDLE;
96
         end
97
         else begin
98
           seq_type <= #TP fault_type;
99
           last_seq_type <=#TP seq_type;
100
           case (linkstate)
101
               IDLE: begin
102
                   linkstate <=#TP IDLE;
103
                   reset_col_cnt <= #TP 1;
104
                   seq_cnt <= #TP 0;
105
                   link_fault <= #TP 2'b00;
106
                   if (get_one_fault)
107
                      linkstate<=#TP LinkFaultDetect;
108
               end
109
 
110
               LinkFaultDetect: begin
111
                   linkstate <=#TP LinkFaultDetect;
112
                   reset_col_cnt <=#TP 1;
113
                   if (get_one_fault & no_new_type) begin
114
                     if (seq_cnt) begin
115
                        linkstate <=#TP IDLE;
116
                        link_fault <=#TP seq_type;  //final fault indeed(equals to GetFault status)
117
                     end
118
                     else
119
                        seq_cnt <=#TP seq_cnt + 1;
120
                   end
121
                   else if(~get_one_fault) begin
122
                        reset_col_cnt <=#TP 0;
123
                        if (col_cnt_64)
124
                           linkstate <=#TP IDLE;
125
                   end
126
                   else if(get_one_fault & ~no_new_type)
127
                        linkstate <=#TP NewFaultType;
128
                   end
129 39 fisher5090
 
130 69 fisher5090
                NewFaultType: begin
131
                    seq_cnt <=#TP 0;
132
                    linkstate <=#TP LinkFaultDetect;
133
                    reset_col_cnt<=#TP 1;
134
                end
135 39 fisher5090
 
136 69 fisher5090
//              GetFault: begin
137
//                  linkstate <=#TP IDLE;
138
//                  reset_col_cnt <=#TP 1;
139
//                  link_fault <=#TP seq_type;
140
//                  if (get_one_fault & no_new_type) 
141
//                    link_fault <=#TP seq_type;        
142
//                  else if (~get_one_fault)    begin
143
//                    reset_col_cnt<=#TP 0;
144
//                    if(col_cnt_128)
145
//                      linkstate <=#TP IDLE;
146
//                  end
147
//                  else if (get_one_fault &    ~no_new_type)
148
//                    linkstate <=#TP NewFaultType;
149
//              end
150
           endcase
151
       end
152
    end
153 39 fisher5090
 
154 69 fisher5090
    always@(posedge rxclk or posedge reset) begin
155
          if (reset)
156
            col_cnt <=#TP 0;
157 39 fisher5090
          else if (reset_col_cnt)
158 69 fisher5090
            col_cnt <=#TP 0;
159 39 fisher5090
          else
160 69 fisher5090
            col_cnt <=#TP col_cnt + 1;
161 39 fisher5090
    end
162
 
163
endmodule

powered by: WebSVN 2.1.0

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