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

Subversion Repositories funbase_ip_library

[/] [funbase_ip_library/] [trunk/] [TUT/] [ip.hwp.communication/] [hibi/] [2.0/] [vhd/] [double_fifo_demux_wr.vhd] - Blame information for rev 159

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 145 lanttu
-------------------------------------------------------------------------------
2
-- Funbase IP library Copyright (C) 2011 TUT Department of Computer Systems
3
--
4
-- This source file may be used and distributed without
5
-- restriction provided that this copyright statement is not
6
-- removed from the file and that any derivative work contains
7
-- the original copyright notice and the associated disclaimer.
8
--
9
-- This source file is free software; you can redistribute it
10
-- and/or modify it under the terms of the GNU Lesser General
11
-- Public License as published by the Free Software Foundation;
12
-- either version 2.1 of the License, or (at your option) any
13
-- later version.
14
--
15
-- This source is distributed in the hope that it will be
16
-- useful, but WITHOUT ANY WARRANTY; without even the implied
17
-- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
18
-- PURPOSE.  See the GNU Lesser General Public License for more
19
-- details.
20
--
21
-- You should have received a copy of the GNU Lesser General
22
-- Public License along with this source; if not, download it
23
-- from http://www.opencores.org/lgpl.shtml
24
-------------------------------------------------------------------------------
25
-------------------------------------------------------------------------------
26
-- File        : double_fifo_demux_wr.vhd
27
-- Description : Double_Fifo_Demux_wr buffer for hibi v.2 interface
28
--               Includes two fifos and a special demultiplexer,
29
--               has 1 input and 2 output ports
30
--               so that the writer sees only one fifo. Demultiplexer
31
--               directs addr+data to correct fifo (0 = for messages)
32
--
33
--               This version includes an extra fifo at the input the to get
34
--               One_Place_Left_Out and Full_Out signals correctly timed
35
--
36
-- Author      : Erno salminen
37
-- e-mail      : erno.salminen@tut.fi
38
-- Project     : huuhaa
39
-- Design      : Do not use term design when you mean system
40
-- Date        : 08.04.2003
41
-- Modified    : 
42
-- 24.07.03     ES added extra fifo in input, changed file name. Extra fifo
43
--                      provides signals "full" and "one_p" correctly
44
--18.12.2006 AK modified to support different kinds of IF fifos
45
 
46
-------------------------------------------------------------------------------
47
library ieee;
48
use ieee.std_logic_1164.all;
49
use ieee.std_logic_arith.all;
50
use ieee.std_logic_unsigned.all;
51
 
52
 
53
 
54
entity double_fifo_demux_wr is
55
 
56
  generic (
57
    -- 0 synch multiclk, 1 basic GALS,
58
    -- 2 Gray FIFO (depth=2^n!), 3 mixed clock pausible    
59
    fifo_sel_g : integer := 0;
60
 
61
    -- needed for fifos 0 (accurate) and 3 (which is faster)    
62
    re_freq_g     : integer := 1;
63
    we_freq_g     : integer := 1;
64
    depth_0_g     : integer := 5;
65
    depth_1_g     : integer := 5;
66
    data_width_g  : integer := 32;
67
    debug_width_g : integer := 0;
68
    comm_width_g  : integer := 3
69
    );
70
  port (
71
    clk_re     : in std_logic;
72
    clk_we     : in std_logic;
73
    -- pulsed clocks. used in pausible clock scheme
74
    clk_re_pls : in std_logic;
75
    clk_we_pls : in std_logic;
76
    rst_n      : in std_logic;
77
 
78
    av_in     : in  std_logic;
79
    data_in   : in  std_logic_vector (data_width_g-1 downto 0);
80
    comm_in   : in  std_logic_vector (comm_width_g-1 downto 0);
81
    we_in     : in  std_logic;
82
    one_p_out : out std_logic;
83
    full_out  : out std_logic;
84
 
85
    re_0_in     : in  std_logic;
86
    av_0_out    : out std_logic;
87
    data_0_out  : out std_logic_vector (data_width_g-1 downto 0);
88
    comm_0_out  : out std_logic_vector (comm_width_g-1 downto 0);
89
    empty_0_out : out std_logic;
90
    one_d_0_out : out std_logic;
91
 
92
    re_1_in     : in  std_logic;
93
    av_1_out    : out std_logic;
94
    data_1_out  : out std_logic_vector (data_width_g-1 downto 0);
95
    comm_1_out  : out std_logic_vector (comm_width_g-1 downto 0);
96
    empty_1_out : out std_logic;
97
    debug_out   : out std_logic_vector(debug_width_g downto 0);
98
    one_d_1_out : out std_logic
99
    );
100
end double_fifo_demux_wr;
101
 
102
 
103
 
104
architecture structural of double_fifo_demux_wr is
105
 
106
  constant re_faster_c : integer := re_freq_g/we_freq_g;
107
 
108
  component mixed_clk_fifo
109
    generic (
110
--      re_freq_g    : integer := 0;      -- integer multiple of clk_we
111
--      we_freq_g    : integer := 0;      -- or vice versa
112
      re_faster_g  : integer := 0;
113
      data_width_g : integer := 0;
114
      depth_g      : integer := 0
115
      );
116
    port (
117
      clk_re    : in std_logic;
118
      clk_we    : in std_logic;
119
      clk_ps_re : in std_logic;         -- phase shifted pulse      
120
      clk_ps_we : in std_logic;         -- phase shifted pulse      
121
      rst_n     : in std_logic;
122
 
123
      data_in   : in  std_logic_vector (data_width_g-1 downto 0);
124
      we_in     : in  std_logic;
125
      full_out  : out std_logic;
126
      one_p_out : out std_logic;
127
 
128
      re_in     : in  std_logic;
129
      data_out  : out std_logic_vector (data_width_g-1 downto 0);
130
      empty_out : out std_logic;
131
      one_d_out : out std_logic
132
      );
133
  end component;  --fifo;
134
 
135
 
136
  component multiclk_fifo
137
    generic (
138
      re_freq_g    : integer;
139
      we_freq_g    : integer;
140
      depth_g      : integer;
141
      data_width_g : integer);
142
    port (
143
      clk_re    : in  std_logic;
144
      clk_we    : in  std_logic;
145
      rst_n     : in  std_logic;
146
      data_in   : in  std_logic_vector (data_width_g-1 downto 0);
147
      we_in     : in  std_logic;
148
      full_out  : out std_logic;
149
      one_p_out : out std_logic;
150
      re_in     : in  std_logic;
151
      data_out  : out std_logic_vector (data_width_g-1 downto 0);
152
      empty_out : out std_logic;
153
      one_d_out : out std_logic);
154
  end component;
155
 
156
  component cdc_fifo
157
    generic (
158
      READ_AHEAD_g  : integer;
159
      SYNC_CLOCKS_g : integer;
160
      depth_log2_g  : integer;
161
      dataw_g       : integer);
162
    port (
163
      rst_n        : in  std_logic;
164
      rd_clk       : in  std_logic;
165
      rd_en_in     : in  std_logic;
166
      rd_one_d_out : out std_logic;
167
      rd_empty_out : out std_logic;
168
      rd_data_out  : out std_logic_vector(dataw_g-1 downto 0);
169
      wr_clk       : in  std_logic;
170
      wr_en_in     : in  std_logic;
171
      wr_full_out  : out std_logic;
172
      wr_one_p_out  : out std_logic;
173
      wr_data_in   : in  std_logic_vector(dataw_g-1 downto 0));
174
  end component;
175
 
176
  component fifo
177
    generic (
178
      data_width_g : integer := 0;
179
      depth_g      : integer := 0
180
      );
181
    port (
182
      clk   : in std_logic;
183
      rst_n : in std_logic;
184
 
185
      data_in   : in  std_logic_vector (data_width_g-1 downto 0);
186
      we_in     : in  std_logic;
187
      full_out  : out std_logic;
188
      one_p_out : out std_logic;
189
 
190
      re_in     : in  std_logic;
191
      data_out  : out std_logic_vector (data_width_g-1 downto 0);
192
      empty_out : out std_logic;
193
      one_d_out : out std_logic
194
      );
195
  end component;  --fifo;
196
 
197
 
198
  component fifo_demux_wr
199
    generic (
200
      data_width_g : integer := 0;
201
      comm_width_g : integer := 0
202
      );
203
    port (
204
      -- 13.04 clk                : in  std_logic;
205
      -- 13.04 rst_n              : in  std_logic;
206
      av_in     : in  std_logic;
207
      data_in   : in  std_logic_vector (data_width_g-1 downto 0);
208
      comm_in   : in  std_logic_vector (comm_width_g-1 downto 0);
209
      we_in     : in  std_logic;
210
      full_out  : out std_logic;
211
      one_p_out : out std_logic;
212
 
213
      -- data/comm/AV conencted to both fifos
214
      -- Distinction made with WE!
215
      av_out     : out std_logic;
216
      data_out   : out std_logic_vector (data_width_g-1 downto 0);
217
      comm_out   : out std_logic_vector (comm_width_g-1 downto 0);
218
      we_0_out   : out std_logic;
219
      we_1_out   : out std_logic;
220
      full_0_in  : in  std_logic;
221
      full_1_in  : in  std_logic;
222
      one_p_0_in : in  std_logic;
223
      one_p_1_in : in  std_logic
224
      );
225
  end component;
226
 
227
  -- inputs to extra fifo (xf)
228
  signal a_c_d_input_xf : std_logic_vector (1 + comm_width_g + data_width_g-1 downto 0);
229
 
230
 
231
  -- from extra fifo to demux, 24.07 es
232
  signal a_c_d_xf_demux : std_logic_vector (1 + comm_width_g + data_width_g-1 downto 0);
233
  signal data_xf_demux  : std_logic_vector (data_width_g-1 downto 0);
234
  signal comm_xf_demux  : std_logic_vector (comm_width_g-1 downto 0);
235
  signal av_xf_demux    : std_logic;
236
  signal empty_xf_demux : std_logic;
237
  signal we_xf_demux    : std_logic;
238
 
239
  signal re_demux_xf   : std_logic;
240
  signal full_demux_xf : std_logic;
241
  -- signal one_p_demux_xf : std_logic; ei tarvi
242
 
243
 
244
  -- signals to fifos (either from inputs or from demux)
245
  signal a_c_d_to_f01 : std_logic_vector (1 + comm_width_g + data_width_g-1 downto 0);
246
 
247
  signal we_to_f0      : std_logic;
248
  signal full_from_f0  : std_logic;
249
  signal one_p_from_f0 : std_logic;
250
 
251
  signal we_to_f1      : std_logic;
252
  signal full_from_f1  : std_logic;
253
  signal one_p_from_f1 : std_logic;
254
 
255
 
256
  -- from fifos to output
257
  signal a_c_d_f0_output : std_logic_vector (1 + comm_width_g + data_width_g-1 downto 0);
258
  signal a_c_d_f1_output : std_logic_vector (1 + comm_width_g + data_width_g-1 downto 0);
259
 
260
  -- logical zero and one
261
  signal Tie_High : std_logic;
262
  signal Tie_Low  : std_logic;
263
 
264
  component aif_read_top
265
    generic (
266
      data_width_g : integer);
267
    port (
268
      tx_clk       : in  std_logic;
269
      tx_rst_n     : in  std_logic;
270
      tx_data_in   : in  std_logic_vector(data_width_g-1 downto 0);
271
      tx_empty_in  : in  std_logic;
272
      tx_re_out    : out std_logic;
273
      rx_clk       : in  std_logic;
274
      rx_rst_n     : in  std_logic;
275
      rx_empty_out : out std_logic;
276
      rx_re_in     : in  std_logic;
277
      rx_data_out  : out std_logic_vector(data_width_g-1 downto 0));
278
  end component;
279
 
280
  signal tx_data_to_aif  : std_logic_vector(1+comm_width_g+data_width_g-1 downto 0);
281
  signal tx_empty_to_aif : std_logic;
282
  signal tx_re_from_aif  : std_logic;
283
 
284
  signal rx_empty_from_aif : std_logic;
285
  signal rx_re_to_aif      : std_logic;
286
  signal rx_data_from_aif  : std_logic_vector(1+comm_width_g+data_width_g-1 downto 0);
287
 
288
  signal tx_msg_data_to_aif  : std_logic_vector(1+comm_width_g+data_width_g-1 downto 0);
289
  signal tx_msg_empty_to_aif : std_logic;
290
  signal tx_msg_re_from_aif  : std_logic;
291
 
292
  signal rx_msg_empty_from_aif : std_logic;
293
  signal rx_msg_re_to_aif      : std_logic;
294
  signal rx_msg_data_from_aif  : std_logic_vector(1+comm_width_g+data_width_g-1 downto 0);
295
 
296
  function log2 (
297
    constant value : integer)
298
    return integer is
299
    variable temp    : integer := 1;
300
    variable counter : integer := 0;
301
  begin  -- log2
302
    while temp < value loop
303
      temp    := temp*2;
304
      counter := counter+1;
305
    end loop;
306
 
307
    return counter;
308
  end log2;
309
 
310
begin  -- structural
311
  -- Check generics
312
  assert (depth_0_g + depth_1_g > 0) report "Both fifo depths zero!" severity warning;
313
 
314
  -- Concurrent assignments
315
  Tie_High <= '1';
316
  Tie_Low  <= '0';
317
 
318
 
319
  -- Splitting the data from fifo outputs
320
  av_0_out   <= a_c_d_f0_output (1 + comm_width_g + data_width_g -1);
321
  comm_0_out <= a_c_d_f0_output (comm_width_g + data_width_g -1 downto data_width_g);
322
  data_0_out <= a_c_d_f0_output (data_width_g -1 downto 0);
323
 
324
  av_1_out   <= a_c_d_f1_output (1+ comm_width_g + data_width_g -1);
325
  comm_1_out <= a_c_d_f1_output (comm_width_g + data_width_g -1 downto data_width_g);
326
  data_1_out <= a_c_d_f1_output (data_width_g -1 downto 0);
327
 
328
  multi : if fifo_sel_g = 0 generate
329
    -- synch multiclk
330
 
331
    Map_Fifo_0 : if depth_0_g > 0 generate
332
      Multiclk_Fifo_0 : multiclk_fifo
333
        generic map(
334
          re_freq_g    => re_freq_g,
335
          we_freq_g    => we_freq_g,
336
          data_width_g => 1 + comm_width_g + data_width_g,
337
          depth_g      => depth_0_g
338
          )
339
        port map(
340
          clk_re    => clk_re,
341
          clk_we    => clk_we,
342
          rst_n     => rst_n,
343
          data_in   => a_c_d_to_f01,
344
          we_in     => we_to_f0,
345
          full_out  => full_from_f0,
346
          one_p_out => one_p_from_f0,
347
 
348
          re_in     => re_0_in,
349
          data_out  => a_c_d_f0_output,
350
          empty_out => empty_0_out,
351
          one_d_out => one_d_0_out
352
          );
353
    end generate Map_Fifo_0;
354
 
355
    Map_Fifo_1 : if depth_1_g > 0 generate
356
      Multiclk_Fifo_1 : multiclk_fifo
357
        generic map(
358
          re_freq_g    => re_freq_g,
359
          we_freq_g    => we_freq_g,
360
          data_width_g => 1 + comm_width_g + data_width_g,
361
          depth_g      => depth_1_g
362
          )
363
        port map(
364
          clk_re => clk_re,
365
          clk_we => clk_we,
366
          rst_n  => rst_n,
367
 
368
          data_in   => a_c_d_to_f01,
369
          we_in     => we_to_f1,
370
          one_p_out => one_p_from_f1,
371
          full_out  => full_from_f1,
372
 
373
          re_in     => re_1_in,
374
          data_out  => a_c_d_f1_output,
375
          empty_out => empty_1_out,
376
          one_d_out => one_d_1_out
377
          );
378
    end generate Map_Fifo_1;
379
 
380
  end generate multi;
381
 
382
 
383
  gals : if fifo_sel_g = 1 generate
384
    -- GALS, may be used with fast synch
385
 
386
    Map_Fifo_0 : if depth_0_g > 0 generate
387
 
388
      aif_read_top_0 : aif_read_top
389
        generic map (
390
          data_width_g => 1 + comm_width_g + data_width_g
391
          )
392
        port map (
393
          tx_clk      => clk_we_pls,
394
          tx_rst_n    => rst_n,
395
          tx_data_in  => tx_data_to_aif,
396
          tx_empty_in => tx_empty_to_aif,
397
          tx_re_out   => tx_re_from_aif,
398
 
399
          rx_clk       => clk_re,       -- should be the agent clock...
400
          rx_rst_n     => rst_n,
401
          rx_empty_out => empty_0_out,
402
          rx_re_in     => re_0_in,
403
          rx_data_out  => a_c_d_f0_output
404
          );
405
 
406
 
407
      Multiclk_Fifo_0 : multiclk_fifo
408
        generic map(
409
          re_freq_g    => re_freq_g,
410
          we_freq_g    => we_freq_g,
411
          data_width_g => 1 + comm_width_g + data_width_g,
412
          depth_g      => depth_0_g
413
          )
414
        port map(
415
          clk_re    => clk_we_pls,
416
          clk_we    => clk_we,
417
          rst_n     => rst_n,
418
          data_in   => a_c_d_to_f01,
419
          we_in     => we_to_f0,
420
          full_out  => full_from_f0,
421
          one_p_out => one_p_from_f0,   --- ???
422
 
423
          re_in     => tx_re_from_aif,
424
          data_out  => tx_data_to_aif,
425
          empty_out => tx_empty_to_aif,
426
          one_d_out => one_d_0_out      -- ???
427
          );
428
    end generate Map_Fifo_0;
429
 
430
    Map_Fifo_1 : if depth_1_g > 0 generate
431
 
432
      aif_read_top_1 : aif_read_top
433
        generic map (
434
          data_width_g => 1 + comm_width_g + data_width_g
435
          )
436
        port map (
437
          tx_clk      => clk_we_pls,
438
          tx_rst_n    => rst_n,
439
          tx_data_in  => tx_msg_data_to_aif,
440
          tx_empty_in => tx_msg_empty_to_aif,
441
          tx_re_out   => tx_msg_re_from_aif,
442
 
443
          rx_clk       => clk_re,       -- should be the agent clock...
444
          rx_rst_n     => rst_n,
445
          rx_empty_out => empty_1_out,
446
          rx_re_in     => re_1_in,
447
          rx_data_out  => a_c_d_f1_output
448
          );
449
 
450
      Multiclk_Fifo_1 : multiclk_fifo
451
        generic map(
452
          re_freq_g    => re_freq_g,
453
          we_freq_g    => we_freq_g,
454
          data_width_g => 1 + comm_width_g + data_width_g,
455
          depth_g      => depth_1_g
456
          )
457
        port map(
458
          clk_re    => clk_we_pls,
459
          clk_we    => clk_we,
460
          rst_n     => rst_n,
461
          data_in   => a_c_d_to_f01,
462
          we_in     => we_to_f1,
463
          full_out  => full_from_f1,
464
          one_p_out => one_p_from_f1,   --- ???
465
 
466
          re_in     => tx_msg_re_from_aif,
467
          data_out  => tx_msg_data_to_aif,
468
          empty_out => tx_msg_empty_to_aif,
469
          one_d_out => one_d_1_out      -- ???
470
          );
471
    end generate Map_Fifo_1;
472
 
473
  end generate gals;
474
 
475
 
476
  gray : if fifo_sel_g = 2 generate
477
    -- Gray FIFO
478
 
479
    Map_Fifo_0 : if depth_0_g > 0 generate
480
      cdc_fifo_0 : cdc_fifo
481
        generic map (
482
          READ_AHEAD_g  => 1,           -- this is the hibi style, look-ahead
483
          SYNC_CLOCKS_g => 0,           -- we use two flops
484
          depth_log2_g  => log2(depth_0_g),
485
          dataw_g       => 1 + comm_width_g + data_width_g)
486
        port map (
487
          rst_n        => rst_n,
488
          rd_clk       => clk_re,
489
          rd_en_in     => re_0_in,
490
          rd_empty_out => empty_0_out,
491
          rd_one_d_out => one_d_0_out,
492
          rd_data_out  => a_c_d_f0_output,
493
 
494
          wr_clk      => clk_we,
495
          wr_en_in    => we_to_f0,
496
          wr_full_out => full_from_f0,
497
          wr_one_p_out => one_p_from_f0,
498
          wr_data_in  => a_c_d_to_f01
499
          );
500
 
501
    end generate Map_Fifo_0;
502
 
503
 
504
    Map_Fifo_1 : if depth_1_g > 0 generate
505
      cdc_fifo_1 : cdc_fifo
506
        generic map (
507
          READ_AHEAD_g  => 1,           -- this is the hibi style, look-ahead
508
          SYNC_CLOCKS_g => 0,           -- we use two flops
509
          depth_log2_g  => log2(depth_1_g),
510
          dataw_g       => 1 + comm_width_g + data_width_g
511
          )
512
        port map (
513
          rst_n        => rst_n,
514
          rd_clk       => clk_re,
515
          rd_en_in     => re_1_in,
516
          rd_empty_out => empty_1_out,
517
          rd_one_d_out => one_d_1_out,
518
          rd_data_out  => a_c_d_f1_output,
519
 
520
          wr_clk      => clk_we,
521
          wr_en_in    => we_to_f1,
522
          wr_full_out => full_from_f1,
523
          wr_one_p_out => one_p_from_f1,
524
          wr_data_in  => a_c_d_to_f01
525
          );
526
    end generate Map_Fifo_1;
527
 
528
  end generate gray;
529
 
530
  mixed : if fifo_sel_g = 3 generate
531
 
532
    Map_Fifo_0 : if depth_0_g > 0 generate
533
      Mixed_clk_Fifo_0 : mixed_clk_fifo
534
        generic map(
535
          re_faster_g  => re_faster_c,
536
          data_width_g => 1 + comm_width_g + data_width_g,
537
          depth_g      => depth_0_g
538
          )
539
        port map(
540
          clk_re    => clk_re,
541
          clk_we    => clk_we,
542
          clk_ps_we => clk_we_pls,
543
          clk_ps_re => clk_re_pls,
544
          rst_n     => rst_n,
545
 
546
          data_in   => a_c_d_to_f01,
547
          we_in     => we_to_f0,
548
          full_out  => full_from_f0,
549
          one_p_out => one_p_from_f0,
550
 
551
          re_in     => re_0_in,
552
          data_out  => a_c_d_f0_output,
553
          empty_out => empty_0_out,
554
          one_d_out => one_d_0_out
555
          );
556
    end generate Map_Fifo_0;
557
 
558
    Map_Fifo_1 : if depth_1_g > 0 generate
559
      Mixed_clk_Fifo_1 : mixed_clk_fifo
560
        generic map(
561
          re_faster_g  => re_faster_c,
562
          data_width_g => 1 + comm_width_g + data_width_g,
563
          depth_g      => depth_1_g
564
          )
565
        port map(
566
          clk_re    => clk_re,
567
          clk_we    => clk_we,
568
          clk_ps_we => clk_we_pls,
569
          clk_ps_re => clk_re_pls,
570
          rst_n     => rst_n,
571
 
572
          data_in   => a_c_d_to_f01,
573
          we_in     => we_to_f1,
574
          one_p_out => one_p_from_f1,
575
          full_out  => full_from_f1,
576
 
577
          re_in     => re_1_in,
578
          data_out  => a_c_d_f1_output,
579
          empty_out => empty_1_out,
580
          one_d_out => one_d_1_out
581
          );
582
    end generate Map_Fifo_1;
583
 
584
  end generate mixed;
585
 
586
 
587
  Not_Map_Fifo_0 : if depth_0_g = 0 generate
588
 
589
    assert false report "Do not map fifo 0 (depth=0)" severity note;
590
 
591
    -- Fifo #0 and demux does not exist!
592
    a_c_d_f0_output <= (others => '0');
593
    empty_0_out     <= Tie_High;
594
    one_d_0_out     <= Tie_Low;
595
    full_from_f0    <= Tie_High;
596
    one_p_from_f0   <= Tie_Low;
597
    we_to_f0        <= Tie_Low;
598
 
599
    -- Connect the other fifo (#1) straight to the outputs/inputs
600
    one_p_out <= one_p_from_f1;
601
    full_out  <= full_from_f1;
602
 
603
    -- replace with concatenation?
604
    a_c_d_to_f01(comm_width_g + data_width_g)                       <= av_in;
605
    a_c_d_to_f01(comm_width_g + data_width_g-1 downto data_width_g) <= comm_in;
606
    a_c_d_to_f01(data_width_g-1 downto 0)                           <= data_in;
607
 
608
    we_to_f1 <= we_in;
609
  end generate Not_Map_Fifo_0;
610
 
611
  Not_Map_Fifo_1 : if depth_1_g = 0 generate
612
    assert false report "Do not map fifo 1 (depth_g = 0)" severity note;
613
    -- Fifo #1 and demux does not exist!
614
    a_c_d_f1_output <= (others => '0');
615
    empty_1_out     <= Tie_High;
616
    one_d_1_out     <= Tie_Low;
617
    full_from_f1    <= Tie_High;
618
    one_p_from_f1   <= Tie_Low;
619
    we_to_f1        <= Tie_Low;
620
 
621
    -- Connect the other fifo (#0) straight to the outputs/inputs
622
    one_p_out <= one_p_from_f0;
623
    full_out  <= full_from_f0;
624
 
625
    -- replace with concatenation?
626
    a_c_d_to_f01(1 + comm_width_g + data_width_g -1)                 <= av_in;
627
    a_c_d_to_f01(comm_width_g + data_width_g -1 downto data_width_g) <= comm_in;
628
    a_c_d_to_f01(data_width_g -1 downto 0)                           <= data_in;
629
 
630
 
631
 
632
    we_to_f0 <= we_in;
633
 
634
  end generate Not_Map_Fifo_1;
635
 
636
 
637
  Map_Demux : if depth_0_g > 0 and depth_1_g > 0 generate
638
    -- Demultiplexer is needed only if two fifos are used
639
    DEMUX_01 : fifo_demux_wr
640
      generic map(
641
        data_width_g => data_width_g,
642
        comm_width_g => comm_width_g
643
        )
644
      port map(
645
 
646
        data_in  => data_xf_demux,
647
        comm_in  => comm_xf_demux,
648
        av_in    => av_xf_demux,
649
        we_in    => we_xf_demux,
650
        full_out => full_demux_xf,
651
        --one_p_out => one_p_demux_xf,
652
 
653
 
654
        av_out   => a_c_d_to_f01 (1 + comm_width_g + data_width_g -1),
655
        comm_out => a_c_d_to_f01 (comm_width_g + data_width_g -1 downto data_width_g),
656
        data_out => a_c_d_to_f01 (data_width_g -1 downto 0),
657
 
658
        we_0_out   => we_to_f0,
659
        we_1_out   => we_to_f1,
660
        full_0_in  => full_from_f0,
661
        full_1_in  => full_from_f1,
662
        one_p_0_in => one_p_from_f0,
663
        one_p_1_in => one_p_from_f1
664
        );
665
  end generate Map_Demux;
666
 
667
 
668
  Map_xtrafifo : if depth_0_g > 0 and depth_1_g > 0 generate
669
    -- Xtra fifo is needed only if two fifos (and demux) are used
670
--    xtra_in_fifo : multiclk_fifo
671
    xtra_in_fifo : fifo
672
      -- regular FIFO
673
      generic map (
674
        data_width_g => 1+ comm_width_g + data_width_g,
675
        depth_g      => 3
676
        )
677
      port map(
678
        clk   => clk_we,
679
        rst_n => rst_n,
680
 
681
        data_in   => a_c_d_input_xf,
682
        we_in     => we_in,
683
        one_p_out => one_p_out,
684
        full_out  => full_out,
685
 
686
        re_in     => re_demux_xf,
687
        data_out  => a_c_d_xf_demux,
688
        empty_out => empty_xf_demux     --,
689
        --one_d_out => one_d_1_out
690
        );
691
 
692
    -- Handshaking between xtra fifo and demux
693
    we_xf_demux <= not empty_xf_demux;
694
    re_demux_xf <= not full_demux_xf;
695
 
696
    -- Split extra fifo output before feeding it to demux
697
    av_xf_demux   <= a_c_d_xf_demux (1 + comm_width_g + data_width_g -1);
698
    comm_xf_demux <= a_c_d_xf_demux (comm_width_g + data_width_g -1 downto data_width_g);
699
    data_xf_demux <= a_c_d_xf_demux (data_width_g -1 downto 0);
700
 
701
    -- Join inputs for xtra fifo
702
    a_c_d_input_xf <= av_in & comm_in & data_in;
703
 
704
  end generate Map_xtrafifo;
705
 
706
end structural;
707
 
708
 
709
 
710
 

powered by: WebSVN 2.1.0

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