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

Subversion Repositories qaz_libs

[/] [qaz_libs/] [trunk/] [basal/] [src/] [8b10b/] [decode_8b10b.v] - Blame information for rev 34

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 34 qaztronic
// Chuck Benz, Hollis, NH   Copyright (c)2002
2
//
3
// The information and description contained herein is the
4
// property of Chuck Benz.
5
//
6
// Permission is granted for any reuse of this information
7
// and description as long as this copyright notice is
8
// preserved.  Modifications may be made as long as this
9
// notice is preserved.
10
 
11
// per Widmer and Franaszek
12
 
13
module decode_8b10b (datain, dispin, dataout, dispout, code_err, disp_err) ;
14
  input [9:0]   datain ;
15
  input         dispin ;
16
  output [8:0]   dataout ;
17
  output        dispout ;
18
  output        code_err ;
19
  output        disp_err ;
20
 
21
  wire ai = datain[0] ;
22
  wire bi = datain[1] ;
23
  wire ci = datain[2] ;
24
  wire di = datain[3] ;
25
  wire ei = datain[4] ;
26
  wire ii = datain[5] ;
27
  wire fi = datain[6] ;
28
  wire gi = datain[7] ;
29
  wire hi = datain[8] ;
30
  wire ji = datain[9] ;
31
 
32
  wire aeqb = (ai & bi) | (!ai & !bi) ;
33
  wire ceqd = (ci & di) | (!ci & !di) ;
34
  wire p22 = (ai & bi & !ci & !di) |
35
             (ci & di & !ai & !bi) |
36
             ( !aeqb & !ceqd) ;
37
  wire p13 = ( !aeqb & !ci & !di) |
38
             ( !ceqd & !ai & !bi) ;
39
  wire p31 = ( !aeqb & ci & di) |
40
             ( !ceqd & ai & bi) ;
41
 
42
  wire p40 = ai & bi & ci & di ;
43
  wire p04 = !ai & !bi & !ci & !di ;
44
 
45
  wire disp6a = p31 | (p22 & dispin) ; // pos disp if p22 and was pos, or p31.
46
   wire disp6a2 = p31 & dispin ;  // disp is ++ after 4 bits
47
   wire disp6a0 = p13 & ! dispin ; // -- disp after 4 bits
48
 
49
  wire disp6b = (((ei & ii & ! disp6a0) | (disp6a & (ei | ii)) | disp6a2 |
50
                  (ei & ii & di)) & (ei | ii | di)) ;
51
 
52
  // The 5B/6B decoding special cases where ABCDE != abcde
53
 
54
  wire p22bceeqi = p22 & bi & ci & (ei == ii) ;
55
  wire p22bncneeqi = p22 & !bi & !ci & (ei == ii) ;
56
  wire p13in = p13 & !ii ;
57
  wire p31i = p31 & ii ;
58
  wire p13dei = p13 & di & ei & ii ;
59
  wire p22aceeqi = p22 & ai & ci & (ei == ii) ;
60
  wire p22ancneeqi = p22 & !ai & !ci & (ei == ii) ;
61
  wire p13en = p13 & !ei ;
62
  wire anbnenin = !ai & !bi & !ei & !ii ;
63
  wire abei = ai & bi & ei & ii ;
64
  wire cdei = ci & di & ei & ii ;
65
  wire cndnenin = !ci & !di & !ei & !ii ;
66
 
67
  // non-zero disparity cases:
68
  wire p22enin = p22 & !ei & !ii ;
69
  wire p22ei = p22 & ei & ii ;
70
  //wire p13in = p12 & !ii ;
71
  //wire p31i = p31 & ii ;
72
  wire p31dnenin = p31 & !di & !ei & !ii ;
73
  //wire p13dei = p13 & di & ei & ii ;
74
  wire p31e = p31 & ei ;
75
 
76
  wire compa = p22bncneeqi | p31i | p13dei | p22ancneeqi |
77
                p13en | abei | cndnenin ;
78
  wire compb = p22bceeqi | p31i | p13dei | p22aceeqi |
79
                p13en | abei | cndnenin ;
80
  wire compc = p22bceeqi | p31i | p13dei | p22ancneeqi |
81
                p13en | anbnenin | cndnenin ;
82
  wire compd = p22bncneeqi | p31i | p13dei | p22aceeqi |
83
                p13en | abei | cndnenin ;
84
  wire compe = p22bncneeqi | p13in | p13dei | p22ancneeqi |
85
                p13en | anbnenin | cndnenin ;
86
 
87
  wire ao = ai ^ compa ;
88
  wire bo = bi ^ compb ;
89
  wire co = ci ^ compc ;
90
  wire do = di ^ compd ;
91
  wire eo = ei ^ compe ;
92
 
93
  wire feqg = (fi & gi) | (!fi & !gi) ;
94
  wire heqj = (hi & ji) | (!hi & !ji) ;
95
  wire fghj22 = (fi & gi & !hi & !ji) |
96
                (!fi & !gi & hi & ji) |
97
                ( !feqg & !heqj) ;
98
  wire fghjp13 = ( !feqg & !hi & !ji) |
99
                 ( !heqj & !fi & !gi) ;
100
  wire fghjp31 = ( (!feqg) & hi & ji) |
101
                 ( !heqj & fi & gi) ;
102
 
103
  wire dispout = (fghjp31 | (disp6b & fghj22) | (hi & ji)) & (hi | ji) ;
104
 
105
  wire ko = ( (ci & di & ei & ii) | ( !ci & !di & !ei & !ii) |
106
                (p13 & !ei & ii & gi & hi & ji) |
107
                (p31 & ei & !ii & !gi & !hi & !ji)) ;
108
 
109
  wire alt7 =   (fi & !gi & !hi & // 1000 cases, where disp6b is 1
110
                 ((dispin & ci & di & !ei & !ii) | ko |
111
                  (dispin & !ci & di & !ei & !ii))) |
112
                (!fi & gi & hi & // 0111 cases, where disp6b is 0
113
                 (( !dispin & !ci & !di & ei & ii) | ko |
114
                  ( !dispin & ci & !di & ei & ii))) ;
115
 
116
  wire k28 = (ci & di & ei & ii) | ! (ci | di | ei | ii) ;
117
  // k28 with positive disp into fghi - .1, .2, .5, and .6 special cases
118
  wire k28p = ! (ci | di | ei | ii) ;
119
  wire fo = (ji & !fi & (hi | !gi | k28p)) |
120
            (fi & !ji & (!hi | gi | !k28p)) |
121
            (k28p & gi & hi) |
122
            (!k28p & !gi & !hi) ;
123
  wire go = (ji & !fi & (hi | !gi | !k28p)) |
124
            (fi & !ji & (!hi | gi |k28p)) |
125
            (!k28p & gi & hi) |
126
            (k28p & !gi & !hi) ;
127
  wire ho = ((ji ^ hi) & ! ((!fi & gi & !hi & ji & !k28p) | (!fi & gi & hi & !ji & k28p) |
128
                            (fi & !gi & !hi & ji & !k28p) | (fi & !gi & hi & !ji & k28p))) |
129
            (!fi & gi & hi & ji) | (fi & !gi & !hi & !ji) ;
130
 
131
  wire disp6p = (p31 & (ei | ii)) | (p22 & ei & ii) ;
132
  wire disp6n = (p13 & ! (ei & ii)) | (p22 & !ei & !ii) ;
133
  wire disp4p = fghjp31 ;
134
  wire disp4n = fghjp13 ;
135
 
136
  assign code_err = p40 | p04 | (fi & gi & hi & ji) | (!fi & !gi & !hi & !ji) |
137
                    (p13 & !ei & !ii) | (p31 & ei & ii) |
138
                    (ei & ii & fi & gi & hi) | (!ei & !ii & !fi & !gi & !hi) |
139
                    (ei & !ii & gi & hi & ji) | (!ei & ii & !gi & !hi & !ji) |
140
                    (!p31 & ei & !ii & !gi & !hi & !ji) |
141
                    (!p13 & !ei & ii & gi & hi & ji) |
142
                    (((ei & ii & !gi & !hi & !ji) |
143
                      (!ei & !ii & gi & hi & ji)) &
144
                     ! ((ci & di & ei) | (!ci & !di & !ei))) |
145
                    (disp6p & disp4p) | (disp6n & disp4n) |
146
                    (ai & bi & ci & !ei & !ii & ((!fi & !gi) | fghjp13)) |
147
                    (!ai & !bi & !ci & ei & ii & ((fi & gi) | fghjp31)) |
148
                    (fi & gi & !hi & !ji & disp6p) |
149
                    (!fi & !gi & hi & ji & disp6n) |
150
                    (ci & di & ei & ii & !fi & !gi & !hi) |
151
                    (!ci & !di & !ei & !ii & fi & gi & hi) ;
152
 
153
  assign dataout = {ko, ho, go, fo, eo, do, co, bo, ao} ;
154
 
155
  // my disp err fires for any legal codes that violate disparity, may fire for illegal codes
156
   assign disp_err = ((dispin & disp6p) | (disp6n & !dispin) |
157
                      (dispin & !disp6n & fi & gi) |
158
                      (dispin & ai & bi & ci) |
159
                      (dispin & !disp6n & disp4p) |
160
                      (!dispin & !disp6p & !fi & !gi) |
161
                      (!dispin & !ai & !bi & !ci) |
162
                      (!dispin & !disp6p & disp4n) |
163
                      (disp6p & disp4p) | (disp6n & disp4n)) ;
164
 
165
endmodule

powered by: WebSVN 2.1.0

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