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

Subversion Repositories core1990_interlaken

[/] [core1990_interlaken/] [trunk/] [gateware/] [sources/] [interlaken/] [transmitter/] [scrambler.vhd] - Blame information for rev 11

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 11 N.Boukadid
library ieee;
2
use ieee.std_logic_1164.all;
3
 
4
entity Scrambler is
5
        port (
6
                Clk                             : in std_logic;                               -- System clock
7
                Scram_Rst               : in std_logic;                               -- Scrambler reset, use for initialization
8
 
9
                Data_In                 : in std_logic_vector (66 downto 0);  -- Data input
10
                Data_Out                : out std_logic_vector (66 downto 0); -- Data output
11
 
12
                Lane_Number             : in std_logic_vector (3 downto 0);   -- Each lane number starts with different scrambler word  
13
                Scrambler_En    : in std_logic;                                           -- Input valid
14
                --Data_Control_In : in std_logic;                       -- Indicates a control word
15
                --Data_Control_Out: out std_logic;                      -- Output control word indication
16
 
17
                Data_Valid_In   : in std_logic;                       -- Input valid
18
        Data_Valid_Out  : out std_logic;                                  -- Output valid
19
        Gearboxready    : in std_logic
20
        );
21
end Scrambler;
22
 
23
architecture Scrambling of Scrambler is
24
        signal Poly : std_logic_vector (57 downto 0);
25
        signal Shiftreg : std_logic_vector (63 downto 0);
26
            -- Constants
27
    constant SYNCHRONIZATION : std_logic_vector(63 downto 0) := X"78f6_78f6_78f6_78f6";  -- synchronization framing layer control word
28
    constant SCRAM_STATE_INIT_VALUE : std_logic_vector(63 downto 0) := X"2800_0000_0000_0000"; -- Starting value of scrambler 
29
    constant META_TYPE_SYNCHRONIZATION: std_logic_vector(4 downto 0) := "11110";
30
    constant META_TYPE_SCRAM_STATE: std_logic_vector(4 downto 0) := "01010";
31
 
32
begin
33
        shiftreg(63) <= Poly(57) xor Poly(38);
34
    shiftreg(62) <= Poly(56) xor Poly(37);
35
    shiftreg(61) <= Poly(55) xor Poly(36);
36
    shiftreg(60) <= Poly(54) xor Poly(35);
37
    shiftreg(59) <= Poly(53) xor Poly(34);
38
    shiftreg(58) <= Poly(52) xor Poly(33);
39
    shiftreg(57) <= Poly(51) xor Poly(32);
40
    shiftreg(56) <= Poly(50) xor Poly(31);
41
    shiftreg(55) <= Poly(49) xor Poly(30);
42
    shiftreg(54) <= Poly(48) xor Poly(29);
43
    shiftreg(53) <= Poly(47) xor Poly(28);
44
    shiftreg(52) <= Poly(46) xor Poly(27);
45
    shiftreg(51) <= Poly(45) xor Poly(26);
46
    shiftreg(50) <= Poly(44) xor Poly(25);
47
    shiftreg(49) <= Poly(43) xor Poly(24);
48
    shiftreg(48) <= Poly(42) xor Poly(23);
49
    shiftreg(47) <= Poly(41) xor Poly(22);
50
    shiftreg(46) <= Poly(40) xor Poly(21);
51
    shiftreg(45) <= Poly(39) xor Poly(20);
52
    shiftreg(44) <= Poly(38) xor Poly(19);
53
    shiftreg(43) <= Poly(37) xor Poly(18);
54
    shiftreg(42) <= Poly(36) xor Poly(17);
55
    shiftreg(41) <= Poly(35) xor Poly(16);
56
    shiftreg(40) <= Poly(34) xor Poly(15);
57
    shiftreg(39) <= Poly(33) xor Poly(14);
58
    shiftreg(38) <= Poly(32) xor Poly(13);
59
    shiftreg(37) <= Poly(31) xor Poly(12);
60
    shiftreg(36) <= Poly(30) xor Poly(11);
61
    shiftreg(35) <= Poly(29) xor Poly(10);
62
    shiftreg(34) <= Poly(28) xor Poly(9);
63
    shiftreg(33) <= Poly(27) xor Poly(8);
64
    shiftreg(32) <= Poly(26) xor Poly(7);
65
    shiftreg(31) <= Poly(25) xor Poly(6);
66
    shiftreg(30) <= Poly(24) xor Poly(5);
67
    shiftreg(29) <= Poly(23) xor Poly(4);
68
    shiftreg(28) <= Poly(22) xor Poly(3);
69
    shiftreg(27) <= Poly(21) xor Poly(2);
70
    shiftreg(26) <= Poly(20) xor Poly(1);
71
    shiftreg(25) <= Poly(19) xor Poly(0);
72
    shiftreg(24) <= Poly(57) xor Poly(38) xor Poly(18);
73
    shiftreg(23) <= Poly(56) xor Poly(37) xor Poly(17);
74
    shiftreg(22) <= Poly(55) xor Poly(36) xor Poly(16);
75
    shiftreg(21) <= Poly(54) xor Poly(35) xor Poly(15);
76
    shiftreg(20) <= Poly(53) xor Poly(34) xor Poly(14);
77
    shiftreg(19) <= Poly(52) xor Poly(33) xor Poly(13);
78
    shiftreg(18) <= Poly(51) xor Poly(32) xor Poly(12);
79
    shiftreg(17) <= Poly(50) xor Poly(31) xor Poly(11);
80
    shiftreg(16) <= Poly(49) xor Poly(30) xor Poly(10);
81
    shiftreg(15) <= Poly(48) xor Poly(29) xor Poly(9);
82
    shiftreg(14) <= Poly(47) xor Poly(28) xor Poly(8);
83
    shiftreg(13) <= Poly(46) xor Poly(27) xor Poly(7);
84
    shiftreg(12) <= Poly(45) xor Poly(26) xor Poly(6);
85
    shiftreg(11) <= Poly(44) xor Poly(25) xor Poly(5);
86
    shiftreg(10) <= Poly(43) xor Poly(24) xor Poly(4);
87
    shiftreg(9) <= Poly(42) xor Poly(23) xor Poly(3);
88
    shiftreg(8) <= Poly(41) xor Poly(22) xor Poly(2);
89
    shiftreg(7) <= Poly(40) xor Poly(21) xor Poly(1);
90
    shiftreg(6) <= Poly(39) xor Poly(20) xor Poly(0);
91
    shiftreg(5) <= Poly(57) xor Poly(19);
92
    shiftreg(4) <= Poly(56) xor Poly(18);
93
    shiftreg(3) <= Poly(55) xor Poly(17);
94
    shiftreg(2) <= Poly(54) xor Poly(16);
95
    shiftreg(1) <= Poly(53) xor Poly(15);
96
    shiftreg(0) <= Poly(52) xor Poly(14);
97
 
98
        Scramble : process (Clk, Scram_Rst, lane_number)
99
        begin
100
        if(Scram_Rst = '1') then
101
            Poly                <= (others => '1');
102
            Poly(57 downto 54)  <= Lane_Number(3 downto 0);
103
            Data_Out            <= (others => '0');
104
            --Data_Control_Out    <= '0';
105
            Data_Valid_Out      <= '0';
106
                elsif (rising_edge(clk)) then
107
            --if (Data_Valid_In = '1' and Gearboxready = '1') then
108
            if (Gearboxready = '1') then
109
                if (Data_In(65 downto 63) = "100") then                     --Checks if incoming data is control word
110
                    if(Data_In(62 downto 58)= META_TYPE_SYNCHRONIZATION) then       -- Sync words are not scrambled  
111
                        Data_Out <= Data_In;
112
                    elsif (Data_In(62 downto 58) = META_TYPE_SCRAM_STATE) then   -- Scrambler state words are not scrambled
113
                        Data_Out(63 downto 0) <= Data_In(63 downto 58) & Poly;
114
                    else
115
                        Poly <= shiftreg(57 downto 0);              -- All other control words are scrambled
116
                        Data_Out(63 downto 0) <= Data_In(63 downto 0) xor (Poly(57 downto 0) & Shiftreg(63 downto 58));
117
                    end if;
118
                else
119
                    Poly <= shiftreg(57 downto 0);                  -- All data words are scrambled
120
                    Data_Out(63 downto 0) <= Data_In(63 downto 0) xor (Poly(57 downto 0) & Shiftreg(63 downto 58));  -- correct 
121
 
122
                end if;
123
                Data_Out(65 downto 64) <= Data_In(65 downto 64);  -- Data word header
124
                Data_Valid_Out <= Data_Valid_In;
125
            end if;
126
        end if;
127
        end process;
128
 
129
end architecture Scrambling;

powered by: WebSVN 2.1.0

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