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

Subversion Repositories ethmac10g

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

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

Line No. Rev Author Line
1 39 fisher5090
//////////////////////////////////////////////////////////////////////
2
////                                                                                                                                                                    ////
3
//// MODULE NAME:  rxLinkFaultState                                                                                     ////
4
////                                                                                                                                                                    ////
5
//// DESCRIPTION: State machine for Link Fault Signalling.        ////
6
////                                                              ////
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
// 
46
// 
47
//
48
//////////////////////////////////////////////////////////////////////
49
 
50
`include "timescale.v"
51
`include "xgiga_define.v"
52
 
53
module rxLinkFaultState(rxclk, reset, local_fault, remote_fault, link_fault);
54
    input rxclk;
55
    input reset;
56
    input local_fault;
57
    input remote_fault;
58
    output[1:0] link_fault;
59
 
60
         parameter TP =1;
61
         parameter IDLE = 0, LinkFaultDetect = 1, NewFaultType = 2, GetFault = 3;
62
 
63
         //------------------------------------------------
64
         // Link        Fault Signalling Statemachine
65
         //------------------------------------------------
66
         wire  fault_type;
67
         wire  get_one_fault;
68
         wire  no_new_type;
69
 
70
         reg[2:0] linkstate, linkstate_next;
71
         reg[5:0] col_cnt;
72
         reg      seq_cnt;
73
         reg[1:0] seq_type;
74
         reg[1:0] last_seq_type;
75
         reg[1:0] link_fault;
76
         reg      reset_col_cnt;
77
         wire     seq_cnt_3;
78
         wire            col_cnt_64;
79
 
80
         assign fault_type = {local_fault, remote_fault};
81
         assign get_one_fault = local_fault | remote_fault;
82
         assign no_new_type = (seq_type == last_seq_type);
83
         assign col_cnt_64 = & col_cnt;
84
 
85
         always@(posedge rxclk or posedge reset)begin
86
             if (reset) begin
87
                           seq_type <=#TP 0;
88
                                seq_cnt <=#TP 0;
89
                                last_seq_type <=#TP 0;
90
                                reset_col_cnt<= #TP 1;
91
                                link_fault <=#TP 2'b00;
92
                                linkstate<= #TP IDLE;
93
                  end
94
                  else begin
95
                           seq_type <= #TP fault_type;
96
                           last_seq_type <=#TP seq_type;
97
                           case (linkstate)
98
                              IDLE: begin
99
                                             linkstate <=#TP IDLE;
100
                                             reset_col_cnt <= #TP 1;
101
                                                  seq_cnt <= #TP 0;
102
                                                  link_fault <= #TP 2'b00;
103
                                             if (get_one_fault)
104
                                                                linkstate<=#TP LinkFaultDetect;
105
                                        end
106
 
107
                   LinkFaultDetect: begin
108
                                             linkstate <=#TP LinkFaultDetect;
109
                                                  reset_col_cnt <=#TP 1;
110
                                             if (get_one_fault & no_new_type) begin
111
                                                     if (seq_cnt) begin
112
                                                             linkstate <=#TP IDLE;
113
                                                                  link_fault <=#TP seq_type;  //final fault indeed(equals to GetFault status)
114
                                                          end
115
                                                          else
116
                                                                  seq_cnt <=#TP seq_cnt + 1;
117
                                                  end
118
                                                  else if(~get_one_fault) begin
119
                                                                    reset_col_cnt <=#TP 0;
120
                                                                    if (col_cnt_64)
121
                                                                       linkstate <=#TP IDLE;
122
                                                  end
123
                                                  else if(get_one_fault & ~no_new_type)
124
                                                        linkstate <=#TP NewFaultType;
125
                                        end
126
 
127
                NewFaultType: begin
128
                                  seq_cnt <=#TP 0;
129
                                                  linkstate <=#TP LinkFaultDetect;
130
                                                  reset_col_cnt<=#TP 1;
131
                end
132
 
133
//                                      GetFault: begin
134
//                                                linkstate <=#TP IDLE;
135
//                                                reset_col_cnt <=#TP 1;
136
//                                                link_fault <=#TP seq_type;
137
//                    if (get_one_fault & no_new_type) 
138
//                                                              link_fault <=#TP seq_type;      
139
//                                      else if (~get_one_fault)        begin
140
//                                                       reset_col_cnt<=#TP 0;
141
//                                                                      if(col_cnt_128)
142
//                                                              linkstate <=#TP IDLE;
143
//                                                end
144
//                    else if (get_one_fault &  ~no_new_type)
145
//                                                    linkstate <=#TP NewFaultType;
146
//                                      end             
147
                           endcase
148
            end
149
         end
150
 
151
         always@(posedge rxclk or posedge reset) begin
152
                    if (reset)
153
                            col_cnt <=#TP 0;
154
          else if (reset_col_cnt)
155
                            col_cnt <=#TP 0;
156
          else
157
                            col_cnt <=#TP col_cnt + 1;
158
    end
159
 
160
endmodule

powered by: WebSVN 2.1.0

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