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

Subversion Repositories core1990_interlaken

[/] [core1990_interlaken/] [trunk/] [gateware/] [sources/] [interlaken_wrapper_vc709.vhd] - Blame information for rev 11

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 11 N.Boukadid
library ieee, UNISIM, work;
2
use ieee.numeric_std.all;
3
use UNISIM.VCOMPONENTS.all;
4
use ieee.std_logic_unsigned.all;
5
use ieee.std_logic_1164.all;
6
use work.interlaken_pkg.all;
7
 
8
entity interlaken_wrapper is
9
  port (
10
    SYSCLK_P       : in     std_logic;--200 MHz clock at H19/G18
11
    SYSCLK_N       : in     std_logic;
12
 
13
    GTREFCLK_IN_P  : in     std_logic; -- Transceiver SFP clock
14
    GTREFCLK_IN_N  : in     std_logic;
15
 
16
    REC_CLOCK_C_P  : out    std_logic; -- Input clock signal for SI5324 (Clock cleaner)
17
    REC_CLOCK_C_N  : out    std_logic;
18
 
19
    USER_CLK_IN_P  : in     std_logic; -- 156.25 MHZ cristal output 
20
    USER_CLK_IN_N  : in     std_logic;
21
 
22
    TX_Out_P       : out    std_logic;
23
    TX_Out_N       : out    std_logic;
24
 
25
    RX_In_P        : in     std_logic;
26
    RX_In_N        : in     std_logic;
27
 
28
    SFP_RX_LOS     : in     std_logic_vector(3 downto 0)
29
  );
30
end entity interlaken_wrapper;
31
 
32
architecture rtl of interlaken_wrapper is
33
 
34
  signal reset                    : std_logic;
35
 
36
  ---- Interlaken instance signals
37
  signal RX_FlowControl_s     : std_logic_vector(15 downto 0);
38
  signal RX_Channel_s         : std_logic_vector(7 downto 0) := "00000001";
39
  signal TX_Channel_s         : std_logic_vector(7 downto 0);
40
 
41
  signal TX_FIFO_progfull_s   : std_logic;
42
 
43
  signal TX_Data_s            : std_logic_vector(63 downto 0);
44
  signal TX_FIFO_Full_s       : std_logic;
45
  signal TX_FIFO_Write_s      : std_logic;
46
  signal TX_SOP_s             : std_logic;
47
  signal TX_SOP_s_p1          : std_logic;
48
  signal TX_EOP_s             : std_logic;
49
  signal TX_EOP_Valid_s       : std_logic_vector(2 downto 0);
50
  --signal  TX_FIFO_Valid        : std_logic;
51
 
52
  signal RX_Data_s            : std_logic_vector(63 downto 0);
53
  signal RX_FIFO_Read_s       : std_logic;
54
  signal RX_FIFO_Empty_s      : std_logic;
55
  signal RX_FIFO_FULL_s       : std_logic;
56
  signal RX_SOP_s             : std_logic;
57
  signal RX_EOP_s             : std_logic;
58
  signal RX_EOP_Valid_s       : std_logic_vector(2 downto 0);
59
  signal RX_FIFO_Valid        : std_logic;
60
  signal RX_FIFO_Valid_p1     : std_logic;
61
  signal RX_FIFO_Read_s_p1    : std_logic;
62
  signal RX_Info              : std_logic_vector(4 downto 0);
63
 
64
  signal CRC24_Error_s        : std_logic := '0';
65
  signal CRC24_occured        : std_logic := '0';
66
  signal CRC32_Error_s        : std_logic := '0';
67
  signal CRC32_occured        : std_logic := '0';
68
  signal send_sync_word       : std_logic;
69
  signal send_sync_word_p1    : std_logic;
70
  signal send_sync_word_p2    : std_logic;
71
  signal RX_EOP_s_p1          : std_logic;
72
 
73
  signal Decoder_lock_s       : std_logic; --interlaken_monitor_type;
74
  signal Descrambler_lock_s   : std_logic;
75
  signal PacketLength         : std_logic_vector(15 downto 0) := X"0010";
76
 
77
  signal clk40                : std_logic;
78
  signal clk150               : std_logic;
79
  signal locked               : std_logic;
80
  signal reset_hard_soft      : std_logic; --hard and soft reset coming from wupper, input to clk_40MHz reset. locked output is used to reset the application.
81
  signal loopback_in          : std_logic_vector(2 downto 0);
82
 
83
  ---- signals related to test data generation -----------
84
  signal pipeline_length   : std_logic_vector(6 downto 0);
85
  signal TX_Info_Pipelined : std_logic_vector(4 downto 0);
86
  signal TX_Data_Pipelined : std_logic_vector(63 downto 0);
87
  signal System_Clock      : std_logic;
88
 
89
  signal Lock_Out              : std_logic; -- used to be ext status led
90
  signal valid_out             : std_logic; -- used to be ext status led
91
  signal valid_probe, RX_Valid : std_logic_vector(0 downto 0);
92
  signal packet_length         : std_logic_vector(6 downto 0);
93
  signal RX_in                 : std_logic_vector(63 downto 0);
94
  signal TX_out                : std_logic_vector(63 downto 0);
95
  signal Data_Descrambler      : std_logic_vector(63 downto 0);
96
  signal Data_Decoder          : std_logic_vector(63 downto 0);
97
  signal probe5_data           : std_logic_vector(2 downto 0);
98
     -------------------------- Generate System Clock ---------------------------
99
  component clk_40MHz
100
  port (
101
    --Clock in- and output signals
102
    clk_in1_p  : in     std_logic;
103
    clk_in1_n  : in     std_logic;
104
    clk_out1   : out    std_logic;
105
    clk_out2   : out    std_logic;
106
 
107
    -- Status and control signals
108
    locked     : out    std_logic;
109
    reset      : in     std_logic
110
  );
111
  end component;
112
 
113
  component ILA_Data
114
  port (
115
    clk : in std_logic;
116
    probe0 : in std_logic_vector(63 downto 0);
117
    probe1 : in std_logic_vector(4 downto 0);
118
    probe2 : in std_logic_vector(63 downto 0);
119
    probe3 : in std_logic_vector(4 downto 0);
120
    probe4 : in std_logic_vector(0 downto 0);
121
    probe5 : in std_logic_vector(2 downto 0);
122
    probe6 : in std_logic_vector(0 downto 0);
123
    probe7 : in std_logic_vector(63 downto 0);
124
    probe8 : in std_logic_vector(63 downto 0);
125
    probe9 : in std_logic_vector(63 downto 0);
126
    probe10: in std_logic_vector(63 downto 0)
127
  );
128
  end component;
129
 
130
  component vio_0
131
  port (
132
      clk : in std_logic;
133
      probe_out0 : out std_logic_vector(6 downto 0);
134
      probe_out1 : out std_logic_vector(6 downto 0)
135
  );
136
  end component;
137
 
138
begin
139
 
140
  ------------------------ Generating stable clock --------------------------
141
  -- Block to internally connect the 156.25 MHz clock to the SI5324 
142
  clock_buffer: block
143
   signal IB_Buf_ds_out  : std_logic;
144
   signal Buf_G_out      : std_logic;
145
  begin
146
 
147
    IBUFDS_inst:IBUFDS
148
    generic map (
149
      DIFF_TERM => TRUE,
150
      IBUF_LOW_PWR => FALSE,
151
      IOSTANDARD => "LVDS")
152
    port map  (
153
      O  => IB_Buf_ds_out,
154
      I  => USER_CLK_IN_P,
155
      IB => USER_CLK_IN_N
156
    );
157
 
158
    BUFG_inst : BUFG
159
    port map (
160
      O => Buf_G_out,
161
      I => IB_Buf_ds_out
162
    );
163
 
164
    OBUFDS_inst: OBUFDS
165
    generic map (
166
      IOSTANDARD => "LVDS",
167
      SLEW => "SLOW" )
168
    port map (
169
      O => REC_CLOCK_C_P,
170
      OB => REC_CLOCK_C_N,
171
      I => Buf_G_out
172
    );
173
  end block;
174
 
175
  -------------------------- Generating 40/150 clk  --------------------------
176
  system_clock_proc : clk_40MHz
177
  port map (
178
    clk_in1_p => SYSCLK_P, --200 MHz clock at H19/G18
179
    clk_in1_n => SYSCLK_N,
180
    clk_out1 => clk40,
181
    clk_out2 => clk150,
182
    locked   => locked,
183
    reset    => '0'
184
  );
185
 system_clock <= clk150;
186
 reset <= not locked;
187
 
188
  ---------------------------- Interlaken core ------------------------------
189
  il0: entity work.interlaken_interface
190
    generic map(
191
      BurstMax     => 256,      -- Configurable value of BurstMax
192
      BurstShort   => 64,       -- Configurable value of BurstShort
193
      PacketLength => 2024)     -- Configurable value of PacketLength -- 24 packets * 8  = 192 B
194
    port map(
195
      ----40 MHz input, from clock generator------------
196
      clk40  => clk40,
197
      clk150 => clk150,
198
      reset  => reset,
199
 
200
      ----125 MHz input, to transceiver (SGMII clock)--
201
      GTREFCLK_IN_P => GTREFCLK_IN_P,
202
      GTREFCLK_IN_N => GTREFCLK_IN_N,
203
 
204
      ----Data signals---------------------------------
205
      TX_Data     => tx_data_s, --fromHostFifo_dout,     
206
      RX_Data     => rx_data_s, -- toHostFifo_din,       
207
 
208
      ----Transceiver related transmission-------------
209
      TX_Out_P  => TX_Out_P,
210
      TX_Out_N  => TX_Out_N,
211
      RX_In_P   => RX_In_P,
212
      RX_In_N   => RX_In_N,
213
 
214
      ----Transmitter input/ready signals--------------
215
      TX_SOP            => TX_SOP_s,
216
      TX_EOP            => TX_EOP_s,
217
      TX_EOP_Valid      => TX_EOP_Valid_s,
218
      TX_FlowControl    => RX_FlowControl_s,
219
      TX_Channel        => TX_Channel_s,
220
 
221
 
222
      ----Receiver output signals-------------    
223
      RX_SOP            => RX_SOP_s,
224
      RX_EOP            => RX_EOP_s,
225
      RX_EOP_Valid      => RX_EOP_Valid_s,
226
      RX_FlowControl    => RX_FlowControl_s,
227
      RX_Channel        => RX_Channel_s,
228
      RX_FIFO_Valid     => RX_FIFO_Valid,
229
      RX_FIFO_Read      => RX_FIFO_Read_s,
230
 
231
      ----Transmitter status signals----------   
232
      TX_FIFO_Full      => TX_FIFO_Full_s,
233
      TX_FIFO_Write     => TX_FIFO_Write_s,
234
      TX_FIFO_progfull  => TX_FIFO_progfull_s,
235
 
236
 
237
      ----Receiver status signals-------------
238
      RX_FIFO_Full      => RX_FIFO_FULL_s,
239
      RX_FIFO_Empty     => RX_FIFO_Empty_s,
240
      Decoder_lock      => Decoder_lock_s ,
241
      Descrambler_lock  => Descrambler_lock_s ,--interlaken_monitor.INTERLAKEN_CONTROL_STATUS.DESCRAMBLER_LOCK(0),              
242
      CRC24_Error       => CRC24_Error_s,
243
      CRC32_Error       => CRC32_Error_s,
244
      loopback_in       => loopback_in
245
    );
246
 
247
    -------- Register variables --------------------
248
--    PacketLength <= register_map_control.INTERLAKEN_PACKET_LENGTH;
249
--    interlaken_monitor.TRANSCEIVER.RX_LOS <= SFP_RX_LOS; --Loss Of Signal register
250
--    loopback_in <= '0' & register_map_control.TRANSCEIVER.LOOPBACK & '0' ;  -- Assign register loopback value.
251
--    interlaken_monitor.INTERLAKEN_CONTROL_STATUS.DECODER_LOCK(1)  <= Decoder_lock_s ;
252
--    interlaken_monitor.INTERLAKEN_CONTROL_STATUS.DESCRAMBLER_LOCK(0) <= Descrambler_lock_s;
253
 
254
    send_sync_word <= RX_EOP_s AND (NOT send_sync_word_p1) and RX_FIFO_valid;
255
 
256
    ---- Generates input data and interface signals ----
257
    generate_data : entity work.data_generator
258
    port map (
259
                clk => System_Clock,
260
            Packet_length => packet_length,
261
            --link_up => Link_up,
262
            TX_FIFO_Full => TX_FIFO_progfull_s,
263
 
264
            write_enable => TX_FIFO_Write_s,
265
            data_out => TX_Data_s,
266
        sop      => TX_SOP_s,
267
        eop              => TX_EOP_s,
268
        eop_valid=> TX_EOP_Valid_s,
269
        channel  => TX_Channel_s
270
    );
271
 
272
    ---- Pipelines input data for alignment with output data ----
273
    pipeline_data : entity work.pipe
274
    generic map (
275
                Nmax => 128
276
        )
277
        port map (
278
            N => pipeline_length,
279
        clk => System_Clock,
280
        pipe_in(68 downto 66) => TX_EOP_Valid_s,
281
        pipe_in(65) => TX_EOP_s,
282
        pipe_in(64) => TX_SOP_s,
283
            pipe_in(63 downto 0) => TX_Data_s,
284
 
285
            pipe_out(68 downto 64) => TX_Info_Pipelined,
286
            pipe_out(63 downto 0) => TX_Data_Pipelined
287
        );
288
        RX_Info <= RX_EOP_valid_s & RX_EOP_s & RX_SOP_s;
289
 
290
        -------- Integrated Logic Analyzer --------
291
        probe_data : ila_data
292
        PORT MAP (
293
                clk => System_Clock,
294
                probe0 => TX_Data_Pipelined,
295
                probe1 => TX_Info_Pipelined,
296
                probe2 => RX_Data_s,
297
                probe3 => RX_Info,
298
                probe4 => valid_probe,
299
                probe5 => probe5_data,
300
                probe6 => RX_Valid,
301
                probe7 => RX_in,
302
                probe8 => TX_out,
303
                probe9 => Data_Descrambler,
304
                probe10 => Data_Decoder
305
        );
306
 
307
        probe5_data <= TX_FIFO_progfull_s & Decoder_Lock_s & Descrambler_Lock_s;
308
        RX_Valid(0) <= RX_FIFO_Valid;
309
 
310
        -------- Validates the data integrity ---------
311
        valid : process (TX_data_pipelined, RX_data_s, TX_info_pipelined, RX_info)
312
        begin
313
           if(TX_Data_Pipelined = RX_Data_s and TX_info_pipelined = RX_info) then
314
               valid_out <= '1';
315
               valid_probe <= "1";
316
       else
317
           valid_out <= '0';
318
           valid_probe <= "0";
319
       end if;
320
    end process;
321
    RX_FIFO_Read_s <= not TX_FIFO_progfull_s;
322
 
323
    ------------- Virtual input/output -------------
324
    VIO : vio_0
325
    PORT MAP (
326
        clk => System_Clock,
327
        probe_out0 => packet_length,
328
        probe_out1 => pipeline_length
329
    );
330
 
331
    --------------- Lock detection ---------------
332
    lock : process (Descrambler_Lock_s)
333
    begin
334
        if (Descrambler_Lock_s = '1') then
335
            Lock_Out <= '1';
336
        else
337
            Lock_Out <= '0';
338
        end if;
339
    end process;
340
 
341
end architecture rtl ; -- of application
342
 

powered by: WebSVN 2.1.0

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