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

Subversion Repositories core1990_interlaken

[/] [core1990_interlaken/] [trunk/] [gateware/] [sources/] [interlaken/] [receiver/] [deframing_burst.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
use ieee.numeric_std.all;
4
 
5
entity Burst_Deframer is
6
    port(
7
        Clk              : in std_logic;                     -- Clock input
8
        Reset                : in std_logic;                                     -- Reset decoder
9
 
10
        Data_In          : in std_logic_vector(66 downto 0); -- Data input
11
        Data_Out         : out std_logic_vector(63 downto 0); --Data output
12
 
13
        SOP              : out std_logic;
14
        EOP              : out std_logic;
15
        EOP_valid        : out std_logic_vector(2 downto 0);
16
 
17
        Data_Valid_In    : in std_logic;
18
        Data_Valid_Out   : out std_logic;                    -- Indicated valid data and enables the fifo write pin
19
 
20
        CRC24_Error      : out std_logic;
21
        Flowcontrol      : out std_logic_vector(15 downto 0)
22
    );
23
end entity Burst_Deframer;
24
 
25
architecture Deframing of Burst_Deframer is
26
    type state_type is (IDLE, CRC);
27
    signal pres_state, next_state : state_type;
28
 
29
    signal Packet_Counter : integer range 0 to 60;
30
    signal Data_P1 : std_logic_vector(66 downto 0);
31
    signal Data_valid_P1, Data_valid_P2, Data_valid_P3: std_logic;
32
    --signal Data_Temp : std_logic_vector(65 downto 0);
33
    --signal data_word_reg, data_word_reg_p1 : std_logic_vector(65 downto 0);
34
    --signal control_word_reg : std_logic_vector(1 downto 0);
35
    signal packet_ready, packet_busy : std_logic;
36
 
37
    signal CRC24_Value_P1, CRC24_Value_P2, CRC24_Value_P3 : std_logic_vector(23 downto 0) := (others => '0'); -- CRC-24 value received
38
    signal SOP_signal, SOP_p1 : std_logic;
39
    signal EOP_signal : std_logic;
40
    signal EOP_signal_p1 : std_logic;
41
    signal EOP_Valid_signal : std_logic_vector(2 downto 0);
42
    --signal FlowControl : std_logic_vector(15 downto 0);
43
    signal Channel : std_logic_vector(7 downto 0);
44
 
45
    -- CRC-24 related
46
    signal CRC24_In  : std_logic_vector(63 downto 0);   -- Data transmitted to CRC-24
47
    signal CRC24_Out : std_logic_vector(23 downto 0);   -- Calculated CRC-24 which returns
48
    signal CRC24_En  : std_logic;                       -- Indicate the CRC-24 the data is valid
49
    signal CRC24_Rst : std_logic;                       -- CRC-24 reset
50
    signal CRC_Check_P1, CRC_Check_P2, CRC_Check_P3 : std_logic;
51
    signal CRC24_Good : std_logic;
52
begin
53
 
54
    CRC_24_Encoding : entity work.CRC_24 -- Define the connections of the CRC-24 component to the Burst component and generics
55
    --generic map
56
    --(
57
    --    Nbits       => 64,
58
    --    CRC_Width   => 24,
59
    --    G_Poly      => X"32_8B63", --Test with CRC-32 (Interlaken-32 : X"1EDC_6F41") -- leo: changed 04C1_1DB7 to 328B63
60
    --    G_InitVal   => X"FF_FFFF"
61
    --)
62
    port map
63
    (
64
        Clk     => Clk,
65
        DIn     => CRC24_In,
66
        CRC     => CRC24_Out,
67
        Calc    => CRC24_En,
68
        Reset   => CRC24_Rst
69
    );
70
 
71
 
72
    Burst_Deframing : process (clk, reset) is
73
    begin
74
        if reset = '1' then
75
            Data_Out <= (others => '0');
76
            --Data_Temp <= (others => '0');
77
            SOP_signal <= '0';
78
            EOP_signal <= '0';
79
            EOP_Valid_signal <= (others => '0');
80
            FlowControl <= (others => '0');
81
            Channel <= (others => '0');
82
            Data_P1 <= (others => '0');
83
            --Data_P2 <= (others => '0');
84
            --Data_P3 <= (others => '0');
85
            Data_valid_P3 <= '0';
86
            Data_valid_P2 <= '0';
87
            Data_valid_P1 <= '0';
88
        elsif rising_edge(clk) then
89
 
90
            Data_P1 <= Data_In;
91
            Data_valid_P1 <= Data_valid_in;
92
 
93
 
94
            Data_Valid_Out <= '0';
95
            if(data_valid_in = '1' and data_in(65 downto 64) = "10") then
96
                Data_valid_P1 <= '0';
97
                --data_word_reg <= data_in;
98
                --data_word_reg_p1 <= data_word_reg;
99
                --SOP_p1 <= SOP;
100
                ----EOP_signal <= '0';
101
            end if;
102
            if (Data_in(65 downto 64) = "10" and Data_valid_in = '1') then
103
                --SOP_signal <= Data_In(61);
104
 
105
                if(Data_in(60) = '1') then
106
                    EOP_signal <= '1';
107
                    EOP_Valid_signal <= Data_In(59 downto 57);
108
                end if;
109
                if (Data_in(61) = '1') then
110
                    SOP_signal <= '1';
111
                end if;
112
                FlowControl <= Data_In(55 downto 40);
113
                Channel <= Data_In(39 downto 32);
114
            end if;
115
 
116
            if EOP_Signal = '1' then
117
                EOP_Signal <= '0';
118
                EOP_Valid <= (others=>'0');
119
            end if;
120
 
121
 
122
            data_out <= data_P1(63 downto 0);
123
            --EOP <= EOP_signal;
124
            EOP_valid <= EOP_valid_signal;
125
            EOP_signal_p1 <= EOP_signal;
126
 
127
 
128
            if data_valid_P1 = '1' then
129
                SOP <= SOP_signal;
130
                SOP_signal <= '0';
131
 
132
            end if;
133
 
134
            data_valid_out <= data_valid_P1;
135
 
136
        end if;
137
    end process Burst_Deframing;
138
    ---------------------------------------------- Control header = "10"                  EOP                  not valid, force end of packet on this output.
139
    EOP <= (EOP_signal and not EOP_signal_p1) or ((Data_in(65) and (not Data_in(64))) and Data_in(60)  and not data_valid_P1);
140
 
141
        state_register : process (clk) is
142
    begin
143
        if (rising_edge(clk)) then
144
            pres_state <= next_state;
145
        end if;
146
    end process state_register;
147
 
148
    state_decoder : process (pres_state, Data_In) is
149
    begin
150
        case pres_state is
151
        when IDLE =>
152
            if ( Data_In(65 downto 60) = "101110") then --SOP set and EOP not set
153
                next_state <= CRC;
154
            else
155
                next_state <= IDLE;
156
            end if;
157
        when CRC =>
158
            if(Data_In(65 downto 64) = "10" and Data_In(61) = '0' and Data_In(60) = '1') then -- End of packet (EOP)
159
                next_state <= IDLE;
160
            elsif(Data_In(65 downto 64) = "10" and Data_In(61) = '1') then -- Repeating start condition (SOP) -> Error
161
                next_state <= IDLE;
162
            else
163
                next_state <= CRC;
164
            end if;
165
        when others =>
166
            next_state <= IDLE;
167
        end case;
168
    end process state_decoder;
169
 
170
    output : process (pres_state, clk) is
171
    begin
172
        if rising_edge(clk) then
173
            CRC24_En <= '0';
174
            CRC24_RST <= '0';
175
            CRC24_Good <= '0';
176
            CRC24_Error <= '0';
177
            CRC_Check_P1 <= '0'; ---
178
            CRC_Check_P2 <= CRC_Check_P1;
179
            CRC_Check_P3 <= CRC_Check_P2;
180
            CRC24_Value_P2 <= CRC24_Value_P1;
181
            CRC24_Value_P3 <= CRC24_Value_P2;
182
 
183
            if CRC_Check_P3 = '1' then
184
                if(CRC24_Out /= CRC24_Value_P3) then
185
                    CRC24_Error <= '1';
186
                else
187
                    CRC24_Good <= '1';
188
                end if;
189
            end if;
190
            if Data_Valid_In = '1' then
191
                CRC24_En <= '1';
192
                --CRC_Check_P1 <= '0'; 
193
                CRC24_RST <= CRC_Check_P1;
194
 
195
 
196
                --case pres_state is
197
                --when IDLE =>
198
                --    CRC24_In <= (others => '0');
199
                --    if (Data_In(65 downto 60) = "101110") then --SOP set and EOP not set
200
                --        CRC24_In <= Data_In(63 downto 0); 
201
                --    end if;
202
                --when CRC =>
203
                    CRC24_In <= Data_In(63 downto 0);
204
                    if(Data_In(65 downto 63) = "101"  and Data_In(61 downto 60) = "01") then -- Only start CRC check on EOP
205
                        CRC_Check_P1 <= '1';
206
                        CRC24_Value_P1 <= Data_In(23 downto 0); -- Copy received CRC-24 value
207
                        CRC24_In(63 downto 32) <= Data_In(63 downto 32); --Change to CRC-length
208
                        CRC24_In(31 downto 0)  <= (others => '0');
209
                    end if;
210
 
211
                --end case;
212
            else
213
                CRC_Check_P1 <= CRC_Check_P1;
214
            end if;
215
        end if;
216
    end process output;
217
 
218
end architecture Deframing;

powered by: WebSVN 2.1.0

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