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

Subversion Repositories tosnet

[/] [tosnet/] [trunk/] [gateware/] [MicroBlaze_Peripheral_rev3_2/] [pcores/] [tosnet_v3_20_a/] [hdl/] [vhdl/] [dec_8b10b.vhd] - Blame information for rev 5

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 5 sonicwave
----------------------------------------------------------------------------------
2
-- Company:             University of Southern Denmark
3
-- Engineer:            Simon Falsig
4
-- 
5
-- Create Date:         11/5/2010 
6
-- Design Name          8b/10b decoder
7
-- Module Name:         dec_8b10b - Behavioral 
8
-- File Name:           dec_8b10b.vhd
9
-- Project Name:        TosNet
10
-- Target Devices:      Spartan3/6
11
-- Tool versions:       Xilinx ISE 12.2
12
-- Description:         An 8b/10b decoder. Like the encoder module, only the
13
--                                      functionality that is actually used in the TosNet physical
14
--                                      layer is implemented. That means that there is no support for
15
--                                      disparity checking, and the code error detection will not
16
--                                      detect all code errors (in particular in the case of the 
17
--                                      primary/alternate encoding of HGF symbol "111"). The datalink
18
--                                      layer does CRC checking though, so any errors are very likely
19
--                                      to be picked up there instead.
20
--
21
-- Revision: 
22
-- Revision 3.2 -       Initial release
23
--
24
-- Copyright 2010
25
--
26
-- This module is free software: you can redistribute it and/or modify
27
-- it under the terms of the GNU Lesser General Public License as published by
28
-- the Free Software Foundation, either version 3 of the License, or
29
-- (at your option) any later version.
30
--
31
-- This module is distributed in the hope that it will be useful,
32
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
33
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
34
-- GNU Lesser General Public License for more details.
35
--
36
-- You should have received a copy of the GNU Lesser General Public License
37
-- along with this module.  If not, see <http://www.gnu.org/licenses/>.
38
----------------------------------------------------------------------------------
39
library IEEE;
40
use IEEE.STD_LOGIC_1164.ALL;
41
use IEEE.STD_LOGIC_ARITH.ALL;
42
use IEEE.STD_LOGIC_UNSIGNED.ALL;
43
 
44
---- Uncomment the following library declaration if instantiating
45
---- any Xilinx primitives in this code.
46
--library UNISIM;
47
--use UNISIM.VComponents.all;
48
 
49
entity dec_8b10b is
50
port (  clk                                     : in    STD_LOGIC;
51
                ce                                      : in    STD_LOGIC;
52
                din                                     : in    STD_LOGIC_VECTOR(9 downto 0);
53
                dout                            : out   STD_LOGIC_VECTOR(7 downto 0);
54
                kout                            : out   STD_LOGIC;
55
                code_err                        : out   STD_LOGIC);
56
end dec_8b10b;
57
 
58
architecture Behavioral of dec_8b10b is
59
 
60
        signal EDCBA                    : STD_LOGIC_VECTOR(4 downto 0) := (others => '0');
61
        signal HGF                              : STD_LOGIC_VECTOR(2 downto 0) := (others => '0');
62
        signal iedcba                   : STD_LOGIC_VECTOR(5 downto 0) := (others => '0');
63
        signal jhgf                             : STD_LOGIC_VECTOR(3 downto 0) := (others => '0');
64
        signal jhgfiedcba               : STD_LOGIC_VECTOR(9 downto 0) := (others => '0');
65
        signal code_err_s1              : STD_LOGIC;
66
        signal code_err_s2              : STD_LOGIC;
67
 
68
begin
69
 
70
        process(jhgfiedcba, EDCBA, HGF, code_err_s1, code_err_s2)
71
        begin
72
                case jhgfiedcba is
73
                        when "1001111100" =>
74
                                dout <= "00111100";
75
                                kout <= '1';
76
                                code_err <= '0';
77
                        when "0110000011" =>
78
                                dout <= "00111100";
79
                                kout <= '1';
80
                                code_err <= '0';
81
                        when "0101111100" =>
82
                                dout <= "10111100";
83
                                kout <= '1';
84
                                code_err <= '0';
85
                        when "1010000011" =>
86
                                dout <= "10111100";
87
                                kout <= '1';
88
                                code_err <= '0';
89
                        when others =>
90
                                dout <= HGF & EDCBA;
91
                                kout <= '0';
92
                                code_err <= code_err_s1 or code_err_s2;
93
                end case;
94
        end process;
95
 
96
        jhgfiedcba <= jhgf & iedcba;
97
 
98
        process(clk)
99
        begin
100
                if(clk = '1' and clk'event) then
101
                        if(ce = '1') then
102
                                iedcba <= din(5 downto 0);
103
                                jhgf <= din(9 downto 6);
104
                        end if;
105
                end if;
106
        end process;
107
 
108
        process(iedcba)
109
        begin
110
                code_err_s1 <= '0';
111
                case iedcba is
112
--                      when "000000" =>
113
--                      when "000001" =>
114
--                      when "000010" =>
115
--                      when "000011" =>
116
--                      when "000100" =>
117
                        when "000101" =>
118
                                EDCBA <= "01111";
119
                        when "000110" =>
120
                                EDCBA <= "00000";
121
                        when "000111" =>
122
                                EDCBA <= "00111";
123
--                      when "001000" =>
124
                        when "001001" =>
125
                                EDCBA <= "10000";
126
                        when "001010" =>
127
                                EDCBA <= "11111";
128
                        when "001011" =>
129
                                EDCBA <= "01011";
130
                        when "001100" =>
131
                                EDCBA <= "11000";
132
                        when "001101" =>
133
                                EDCBA <= "01101";
134
                        when "001110" =>
135
                                EDCBA <= "01110";
136
--                      when "001111" =>
137
--                      when "010000" =>
138
                        when "010001" =>
139
                                EDCBA <= "00001";
140
                        when "010010" =>
141
                                EDCBA <= "00010";
142
                        when "010011" =>
143
                                EDCBA <= "10011";
144
                        when "010100" =>
145
                                EDCBA <= "00100";
146
                        when "010101" =>
147
                                EDCBA <= "10101";
148
                        when "010110" =>
149
                                EDCBA <= "10110";
150
                        when "010111" =>
151
                                EDCBA <= "10111";
152
                        when "011000" =>
153
                                EDCBA <= "01000";
154
                        when "011001" =>
155
                                EDCBA <= "11001";
156
                        when "011010" =>
157
                                EDCBA <= "11010";
158
                        when "011011" =>
159
                                EDCBA <= "11011";
160
                        when "011100" =>
161
                                EDCBA <= "11100";
162
                        when "011101" =>
163
                                EDCBA <= "11101";
164
                        when "011110" =>
165
                                EDCBA <= "11110";
166
--                      when "011111" =>
167
--                      when "100000" =>
168
                        when "100001" =>
169
                                EDCBA <= "11110";
170
                        when "100010" =>
171
                                EDCBA <= "11101";
172
                        when "100011" =>
173
                                EDCBA <= "00011";
174
                        when "100100" =>
175
                                EDCBA <= "11011";
176
                        when "100101" =>
177
                                EDCBA <= "00101";
178
                        when "100110" =>
179
                                EDCBA <= "00110";
180
                        when "100111" =>
181
                                EDCBA <= "01000";
182
                        when "101000" =>
183
                                EDCBA <= "10111";
184
                        when "101001" =>
185
                                EDCBA <= "01001";
186
                        when "101010" =>
187
                                EDCBA <= "01010";
188
                        when "101011" =>
189
                                EDCBA <= "00100";
190
                        when "101100" =>
191
                                EDCBA <= "01100";
192
                        when "101101" =>
193
                                EDCBA <= "00010";
194
                        when "101110" =>
195
                                EDCBA <= "00001";
196
--                      when "101111" =>
197
--                      when "110000" =>
198
                        when "110001" =>
199
                                EDCBA <= "10001";
200
                        when "110010" =>
201
                                EDCBA <= "10010";
202
                        when "110011" =>
203
                                EDCBA <= "11000";
204
                        when "110100" =>
205
                                EDCBA <= "10100";
206
                        when "110101" =>
207
                                EDCBA <= "11111";
208
                        when "110110" =>
209
                                EDCBA <= "10000";
210
--                      when "110111" =>
211
                        when "111000" =>
212
                                EDCBA <= "00111";
213
                        when "111001" =>
214
                                EDCBA <= "00000";
215
                        when "111010" =>
216
                                EDCBA <= "01111";
217
--                      when "111011" =>
218
--                      when "111100" =>
219
--                      when "111101" =>
220
--                      when "111110" =>
221
--                      when "111111" =>
222
                        when others =>
223
                                code_err_s1 <= '1';
224
                                EDCBA <= "00000";
225
                end case;
226
        end process;
227
 
228
        process(jhgf)
229
        begin
230
                code_err_s2 <= '0';
231
                case jhgf is
232
--                      when "0000" =>
233
                        when "0001" =>
234
                                HGF <= "111";
235
                        when "0010" =>
236
                                HGF <= "000";
237
                        when "0011" =>
238
                                HGF <= "011";
239
                        when "0100" =>
240
                                HGF <= "100";
241
                        when "0101" =>
242
                                HGF <= "101";
243
                        when "0110" =>
244
                                HGF <= "110";
245
                        when "0111" =>
246
                                HGF <= "111";
247
                        when "1000" =>
248
                                HGF <= "111";
249
                        when "1001" =>
250
                                HGF <= "001";
251
                        when "1010" =>
252
                                HGF <= "010";
253
                        when "1011" =>
254
                                HGF <= "100";
255
                        when "1100" =>
256
                                HGF <= "011";
257
                        when "1101" =>
258
                                HGF <= "000";
259
                        when "1110" =>
260
                                HGF <= "111";
261
--                      when "1111" =>
262
                        when others =>
263
                                code_err_s2 <= '1';
264
                                HGF <= "000";
265
                end case;
266
        end process;
267
 
268
 
269
end Behavioral;
270
 

powered by: WebSVN 2.1.0

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