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

Subversion Repositories core1990_interlaken

[/] [core1990_interlaken/] [trunk/] [gateware/] [sources/] [interlaken/] [receiver/] [interlaken_receiver.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
library work;
4
 
5
entity Interlaken_Receiver is
6
    generic (
7
        --channelnumber : integer;
8
        PacketLength : positive
9
    );
10
        port (
11
            fifo_read_clk       : in std_logic;
12
                clk                 : in std_logic;
13
                reset               : in std_logic;
14
 
15
                RX_Data_In      : in std_logic_vector(66 downto 0);
16
                RX_Data_Out : out std_logic_vector (63 downto 0);        -- Data ready to transmit
17
 
18
                RX_FIFO_Valid: out std_logic;
19
 
20
                --RX_Enable     : out std_logic;      --not used                   -- Enable the TX
21
                RX_SOP          : out std_logic;                         -- Start of Packet
22
                RX_EOP_Valid    : out std_logic_vector(2 downto 0);      -- Valid bytes packet contains
23
                RX_EOP          : out std_logic;                         -- End of Packet
24
                RX_FlowControl  : out std_logic_vector(15 downto 0);     -- Flow control data (yet unutilized)
25
                RX_prog_full    : out std_logic_vector(15 downto 0);     -- Indication FIFO of this channel is full
26
                RX_Channel      : out std_logic_vector(7 downto 0);      -- Select transmit channel (yet unutilized)
27
                RX_Datavalid    : in std_logic;
28
 
29
                CRC24_Error       : out std_logic;
30
                CRC32_Error       : out std_logic;
31
                Decoder_lock      : out std_logic;
32
                Descrambler_lock  : out std_logic;
33
 
34
                Data_Descrambler : out std_logic_vector(66 downto 0);
35
                Data_Decoder     : out std_logic_vector(66 downto 0);
36
 
37
                RX_FIFO_Full         : out std_logic;
38
                RX_FIFO_Empty        : out std_logic;
39
                RX_FIFO_Read         : in std_logic;
40
 
41
                RX_Link_Up      : out std_logic;
42
 
43
                Bitslip         : out std_logic
44
        );
45
end entity Interlaken_Receiver;
46
 
47
architecture Receiver of Interlaken_Receiver is
48
    type state_type is (IDLE, DATA);
49
        signal pres_state, next_state: state_type;
50
 
51
    signal FIFO_Read_Count, FIFO_Write_Count : std_logic_vector(5 downto 0);
52
    signal FIFO_prog_full, FIFO_prog_empty  : std_logic;
53
    signal FIFO_Data_Out : std_logic_vector(70 downto 0);
54
 
55
    COMPONENT RX_FIFO
56
                PORT (
57
            rst : IN STD_LOGIC;
58
            wr_clk : IN STD_LOGIC;
59
            rd_clk : IN STD_LOGIC;
60
            din : IN STD_LOGIC_VECTOR(70 DOWNTO 0);
61
            wr_en : IN STD_LOGIC;
62
            rd_en : IN STD_LOGIC;
63
            dout : OUT STD_LOGIC_VECTOR(70 DOWNTO 0);
64
            full : OUT STD_LOGIC;
65
            empty : OUT STD_LOGIC;
66
            prog_full : OUT STD_LOGIC;
67
            prog_empty : OUT STD_LOGIC;
68
            valid : OUT STD_LOGIC
69
                );
70
    END COMPONENT;
71
 
72
    signal Data_Burst_Out : std_logic_vector(68 downto 0);
73
 
74
    signal RX_FIFO_Data : std_logic_vector(70 downto 0);
75
    signal RX_FIFO_Write : std_logic;
76
    signal Data_valid_Burst_Out : std_logic;
77
    signal Flowcontrol : std_logic_vector (15 downto 0);
78
    --signal FIFO_empty : std_logic;
79
 
80
    signal Data_Meta_Out : std_logic_vector(66 downto 0);
81
    signal Data_Descrambler_Out : std_logic_vector(66 downto 0);
82
    signal Data_Control_Descrambler_Out : std_logic;
83
    signal Data_control_Meta_out : std_logic;
84
    signal Data_valid_Meta_out : std_logic;
85
 
86
    signal Data_Decoder_Out : std_logic_vector(66 downto 0);
87
    signal Data_Control_Decoder_Out, Data_valid_decoder_out : std_logic;
88
    signal Data_valid_Descrambler_out : std_logic;
89
    signal Lane_Number : std_logic_vector(3 downto 0);
90
    signal Error_BadSync : std_logic;
91
    signal Error_StateMismatch : std_logic;
92
    signal Error_NoSync : std_logic;
93
    signal Error_Decoder_Sync : std_logic;
94
    signal Descrambler_In_lock: std_logic;
95
    -- signal FIFO_dout_valid : std_logic;
96
    signal CRC24_Error_burst : std_logic ;
97
    signal CRC24_Error_fifo : std_logic := '0';
98
 
99
    signal CRC32_Error_meta : std_logic;
100
    signal CRC32_Error_fifo : std_logic := '0';
101
 
102
begin
103
 
104
    RX_prog_full(0) <= not FIFO_prog_full;
105
    RX_prog_full(15 downto 1) <= (others => '0');
106
    --RX_FlowControl       <= FlowControl; --RX_FlowControl(channelnumber) <= FIFO_prog_full;
107
 
108
    FIFO_Receiver : RX_FIFO
109
    port map (
110
        rst             => Reset,
111
        wr_clk          => clk,
112
        rd_clk          => fifo_read_clk,
113
        din             => RX_FIFO_Data,
114
        wr_en           => RX_FIFO_Write,
115
        rd_en           => RX_FIFO_Read,
116
        dout            => FIFO_Data_Out,
117
        full            => RX_FIFO_Full,
118
        empty           => RX_FIFO_Empty,
119
        prog_full       => FIFO_prog_full,
120
        prog_empty      => FIFO_prog_empty,
121
        valid           => RX_FIFO_Valid
122
    );
123
 
124
    Deframing_Burst : entity work.Burst_Deframer
125
    port map (
126
        clk         => clk,
127
        reset       => reset,
128
 
129
        Data_in          => Data_Meta_Out,
130
        Data_out         => Data_Burst_Out(63 downto 0),
131
 
132
        SOP              => Data_Burst_Out(68),--: out std_logic;
133
        EOP              => Data_Burst_Out(67),--: out std_logic;
134
        EOP_valid        => Data_Burst_Out(66 downto 64),--: out std_logic_vector(2 downto 0);
135
 
136
       -- Data_control_in  => Data_Control_Meta_Out,
137
 
138
        Flowcontrol => RX_Flowcontrol,
139
        CRC24_Error => CRC24_Error_burst,
140
 
141
        Data_valid_in   => Data_valid_Meta_Out,
142
        Data_valid_out  => Data_valid_Burst_Out
143
    );
144
    RX_FIFO_Write <= Data_valid_Burst_Out;
145
    RX_FIFO_Data <=  CRC32_Error_fifo & CRC24_Error_fifo & Data_Burst_Out;
146
 
147
    process(clk)
148
    begin
149
        if rising_edge(clk) then
150
            if CRC24_Error_burst = '1' then
151
                CRC24_Error_fifo <= '1';
152
            elsif RX_FIFO_Write = '1' then
153
                CRC24_Error_fifo <= '0';
154
            end if;
155
 
156
            if CRC32_Error_meta = '1' then
157
                CRC32_Error_fifo <= '1';
158
            elsif RX_FIFO_Write = '1' then
159
                CRC32_Error_fifo <= '0';
160
            end if;
161
 
162
        end if;
163
    end process;
164
 
165
    Deframing_Meta : entity work.Meta_Deframer
166
    port map (
167
        clk         => clk,
168
        reset       => reset,
169
 
170
        CRC32_Error => CRC32_Error_meta,
171
 
172
        Data_in          => Data_Descrambler_Out,
173
        Data_out         => Data_Meta_Out,
174
       -- Data_control_in  => Data_Control_Descrambler_Out,
175
        --Data_control_out => Data_control_Meta_out,
176
        Data_valid_in    => Data_valid_Descrambler_out,
177
        Data_valid_out   => Data_valid_Meta_out
178
    );
179
 
180
    Data_Descrambler <= Data_Descrambler_Out;
181
    Data_Decoder <= Data_Decoder_Out;
182
 
183
    Descrambler : entity work.Descrambler
184
    generic map (
185
        PacketLength => PacketLength
186
    )
187
    port map (
188
        clk     => clk,
189
        reset   => reset,
190
 
191
        Data_in          => Data_Decoder_Out,
192
        Data_out         => Data_Descrambler_Out,
193
        --Data_control_In  => Data_Control_Decoder_Out,
194
        --Data_control_Out => Data_control_Descrambler_Out,
195
        Data_valid_in    => Data_valid_decoder_out,
196
        Data_valid_out   => Data_valid_Descrambler_out,
197
        Lock             => Descrambler_In_lock,
198
 
199
        Lane_Number => "0001",
200
 
201
        Error_BadSync       => Error_BadSync,
202
        Error_StateMismatch => Error_StateMismatch,
203
        Error_NoSync        => Error_NoSync
204
    );
205
 
206
    Descrambler_Lock <= Descrambler_In_lock;
207
 
208
    sync_proc: process(fifo_read_clk)
209
    begin
210
        if rising_edge(fifo_read_clk) then
211
            RX_Link_Up <= Descrambler_In_lock;
212
        end if;
213
    end process;
214
 
215
 
216
    Decoder : entity work.Decoder
217
    port map (
218
        clk         => clk,
219
        reset       => reset,
220
        Decoder_En  => '1',
221
 
222
        Data_in       => RX_Data_In,
223
        Data_out      => Data_Decoder_Out,
224
        Data_Valid_In => RX_Datavalid,
225
        Data_Valid_Out => Data_valid_decoder_out,
226
        Data_control  => Data_control_Decoder_Out,
227
 
228
        Sync_Locked => Decoder_lock,
229
        Sync_error  => Error_Decoder_Sync,
230
        Bitslip     => Bitslip
231
    );
232
 
233
--    linkup_proc: process(clk)
234
--        variable link_up_p1: std_logic;
235
--    begin
236
--        if rising_edge(clk) then
237
--            RX_Link_Up <= Data_Valid_Descrambler_Out or link_up_p1;
238
--            link_up_p1 := Data_Valid_Descrambler_Out;
239
--        end if;
240
--    end process;
241
 
242
 
243
    CRC32_Error <= FIFO_Data_Out(70);
244
    CRC24_Error <= FIFO_Data_Out(69);
245
    RX_SOP <= FIFO_Data_Out(68);
246
    RX_EOP <= FIFO_Data_Out(67);
247
    RX_EOP_Valid <= FIFO_Data_Out(66 downto 64);
248
    RX_Data_Out <= FIFO_Data_Out(63 downto 0);
249
 
250
 
251
--    state_register : process (clk) is 
252
--    begin
253
--       if (rising_edge(clk)) then
254
--           pres_state <= next_state;
255
--       end if;
256
--    end process state_register;
257
 
258
--    state_decoder : process (pres_state, Data_Burst_Out) is
259
--    begin
260
--       case pres_state is
261
--       when IDLE =>
262
--           if  (Data_Burst_Out(65) = '1') then
263
--               next_state <= DATA;
264
--           else
265
--               next_state <= IDLE;
266
--           end if;
267
 
268
--       when DATA =>
269
--           if(Data_Burst_Out(64) = '1') then
270
--               next_state <= IDLE;
271
--           else
272
--               next_state <= DATA;
273
--           end if;
274
--       when others =>
275
--           next_state <= IDLE;
276
--       end case;
277
--    end process state_decoder;
278
 
279
--    fifo_out : process(fifo_empty) is
280
--    begin
281
--        RX_fifo_read <= '0';
282
--        if(fifo_empty = '0') then
283
--            RX_fifo_read <= '1';
284
--        end if;
285
--    end process;
286
 
287
--    output_state : process (pres_state, clk) is
288
--    begin
289
--        if rising_edge(clk) then
290
--            case pres_state is
291
--            when IDLE =>
292
--                RX_FIFO_Write <= '0';
293
--                RX_FIFO_Data <= (others => '0');
294
--                if  (Data_Burst_Out(65) = '1') then
295
--                    RX_FIFO_Write <= Data_valid_Burst_Out;
296
--                    RX_FIFO_Data <= Data_Burst_Out;                
297
--                end if;
298
 
299
--            when DATA =>
300
--                RX_FIFO_Write <= Data_valid_Burst_Out;
301
--                RX_FIFO_Data <= Data_Burst_Out;                
302
--            end case;
303
--        end if;
304
--    end process output_state;
305
 
306
end architecture Receiver;

powered by: WebSVN 2.1.0

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