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.storage/] [fifos/] [synch_fifos/] [1.0/] [vhd/] [fifo_muxes.vhd] - Blame information for rev 145

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 145 lanttu
-------------------------------------------------------------------------------
2
-- File        : fifo_muxes.vhdl
3
-- Description : Makes two fifos look like a single fifo.
4
--               Two components : one for writing and one for reading fifo.
5
--               Write_demux:
6
--               Input : data, addr valid and command 
7
--               Out   : data, addr valid and command to two fifos
8
--
9
--               Read_mux :
10
--               Input : data, addr valid and command from two fifos
11
--               Out   : data, addr valid and command
12
--
13
--              NOTE:
14
--              1)
15
--              Read_mux does not fully support One_Data_Left_Out!
16
--
17
--               It works when writing to fifo. However, when something
18
--              is written to empty fifo, One_Data_Left_Out remains 0
19
--              even if Empty goes from 1 to 0! Be careful out there.
20
--
21
--               Case when new addr is written to fifo 0 and there is a gap before
22
--              corresponding data. At the same time there is some data in fifo
23
--              #1. It is not wise to wait for data#0, because it blocks the data#1.
24
--              In such, case transfer from fifo#0 is interrupted (Empty goes high).
25
--              At the moment, One_Data_Left_Out does not work in such case.
26
--              (Probably it could be repaired with fifo_bookkeeper component?)
27
--              2) 
28
--              
29
-- Author      : Erno Salminen
30
-- Date        : 05.02.2003
31
-- Modified    : 
32
--               
33
--
34
-------------------------------------------------------------------------------
35
library ieee;
36
use ieee.std_logic_1164.all;
37
use ieee.std_logic_arith.all;
38
use ieee.std_logic_unsigned.all;
39
 
40
 
41
 
42
 
43
 
44
-- Write_Mux checks the incoming addr. Same addr is not
45
-- written to fifo more than once! Written fifo is selected
46
-- according to incoming command
47
entity fifo_demux_write is
48
 
49
  generic (
50
    Data_Width         :     integer := 0;
51
    Comm_Width         :     integer := 0
52
    );
53
  port (
54
    -- 13.04 Fully asynchronous!
55
    --Clk                : in  std_logic;
56
    --Rst_n              : in  std_logic;
57
 
58
    Data_In            : in  std_logic_vector (Data_Width-1 downto 0);
59
    Addr_Valid_In      : in  std_logic;
60
    Comm_In            : in  std_logic_vector (Comm_Width-1 downto 0);
61
    WE_In              : in  std_logic;
62
    One_Place_Left_Out : out std_logic;
63
    Full_Out           : out std_logic;
64
 
65
    -- Data/Comm/AV conencted to both fifos
66
    -- Distinction made with WE!
67
    Data_Out            : out std_logic_vector (Data_Width-1 downto 0);
68
    Comm_Out            : out std_logic_vector (Comm_Width-1 downto 0);
69
    Addr_Valid_Out      : out std_logic;
70
    WE_0_Out            : out std_logic;
71
    WE_1_Out            : out std_logic;
72
    Full_0_In           : in  std_logic;
73
    Full_1_In           : in  std_logic;
74
    One_Place_Left_0_In : in  std_logic;
75
    One_Place_Left_1_In : in  std_logic
76
    );
77
 
78
end fifo_demux_write;
79
 
80
 
81
 
82
 
83
 
84
 
85
--   constant Idle              : std_logic_vector ( Comm_Width-1 downto 0) := "000"; -- 0
86
--   constant Write_Config_Data : std_logic_vector ( Comm_Width-1 downto 0) := "001"; -- 1
87
--   constant Write_Data        : std_logic_vector ( Comm_Width-1 downto 0) := "010"; -- 2
88
--   constant Write_Message     : std_logic_vector ( Comm_Width-1 downto 0) := "011"; -- 3
89
 
90
--   constant Read_RQ           : std_logic_vector ( Comm_Width-1 downto 0) := "100"; -- 4
91
--   constant Read_Config       : std_logic_vector ( Comm_Width-1 downto 0) := "101"; -- 5
92
--   constant Multicast_Data    : std_logic_vector ( Comm_Width-1 downto 0) := "110"; -- 6
93
--   constant Multicast_Message : std_logic_vector ( Comm_Width-1 downto 0) := "111"; -- 7
94
 
95
architecture rtl of fifo_demux_write is
96
 
97
begin  -- rtl
98
 
99
 
100
  -- Concurrent assignments
101
  Data_Out       <= Data_In;
102
  Addr_Valid_Out <= Addr_Valid_In;
103
  Comm_Out       <= Comm_In;
104
 
105
 
106
  -- PROCESSES
107
  -- Fully combinational
108
  Demultiplex_data : process (Data_In, Addr_Valid_In, Comm_In, WE_In,
109
                              One_Place_Left_0_In, One_Place_Left_1_In,
110
                              Full_0_In, Full_1_In)
111
  begin  -- process Demultiplex_data
112
 
113
    if Comm_In = conv_std_logic_vector (3, Comm_Width)
114
      or Comm_In = conv_std_logic_vector (7, Comm_Width) then
115
      -- MESSAGE
116
 
117
      WE_0_Out           <= WE_In;
118
      WE_1_Out           <= '0';
119
      Full_Out           <= Full_0_In;
120
      One_Place_Left_Out <= One_Place_Left_0_In;
121
 
122
 
123
    elsif Comm_In = conv_std_logic_vector (2, Comm_Width)
124
      or Comm_In = conv_std_logic_vector (4, Comm_Width)
125
      or Comm_In = conv_std_logic_vector (6, Comm_Width) then
126
      -- DATA
127
      WE_0_Out           <= '0';
128
      WE_1_Out           <= WE_In;
129
      Full_Out           <= Full_1_In;
130
      One_Place_Left_Out <= One_Place_Left_1_In;
131
 
132
 
133
    elsif Comm_In = conv_std_logic_vector (1, Comm_Width)
134
      or Comm_In = conv_std_logic_vector (5, Comm_Width) then
135
      -- CONFIG
136
      assert false report "Config comm to fifo_demux_write" severity warning;
137
      WE_0_Out           <= '0';
138
      WE_1_Out           <= '0';
139
      Full_Out           <= '0';
140
      One_Place_Left_Out <= '0';
141
 
142
 
143
    else
144
      --IDLE
145
      WE_0_Out           <= '0';
146
      WE_1_Out           <= '0';
147
      Full_Out           <= '0';
148
      One_Place_Left_Out <= '0';
149
    end if;                             --Comm_In
150
 
151
 
152
  end process Demultiplex_data;
153
 
154
 
155
 
156
end rtl;                                --fifo_demux_write
157
 
158
 
159
 
160
 
161
 
162
 
163
-------------------------------------------------------------------------------
164
--entity fifo_mux_read kaytetaan lukemaan kahdesta fifosta osoite ja data perakkain
165
-- fifolla 0 on suurempi prioritetti. Jos ollaan lukemassa fifoa 1, ei ruveta
166
-- lukemaan fifoa 0 ennekuin on siirretty ainakin yksi data fifosta 1.
167
library ieee;
168
use ieee.std_logic_1164.all;
169
use ieee.std_logic_arith.all;
170
use ieee.std_logic_unsigned.all;
171
 
172
 
173
 
174
 
175
 
176
entity fifo_mux_read is
177
 
178
  generic (
179
    Data_Width         :     integer := 0;
180
    Comm_Width         :     integer := 0
181
    );
182
  port (
183
    Clk                : in  std_logic;
184
    Rst_n              : in  std_logic;
185
 
186
    Data_0_In          : in  std_logic_vector (Data_Width-1 downto 0);
187
    Comm_0_In          : in  std_logic_vector (Comm_Width-1 downto 0);
188
    Addr_Valid_0_In    : in  std_logic;
189
    One_Data_Left_0_In : in  std_logic;
190
    Empty_0_In         : in  std_logic;
191
    RE_0_Out           : out std_logic;
192
 
193
    Data_1_In          : in  std_logic_vector (Data_Width-1 downto 0);
194
    Comm_1_In          : in  std_logic_vector (Comm_Width-1 downto 0);
195
    Addr_Valid_1_In    : in  std_logic;
196
    One_Data_Left_1_In : in  std_logic;
197
    Empty_1_In         : in  std_logic;
198
    RE_1_Out           : out std_logic;
199
 
200
    Read_Enable_In    : in  std_logic;
201
    Data_Out          : out std_logic_vector (Data_Width-1 downto 0);
202
    Comm_Out          : out std_logic_vector (Comm_Width-1 downto 0);
203
    Addr_Valid_Out    : out std_logic;
204
    One_Data_Left_Out : out std_logic;
205
    Empty_Out         : out std_logic
206
    );
207
 
208
end fifo_mux_read;
209
 
210
 
211
architecture rtl of fifo_mux_read is
212
  signal Last_Addr_Reg_0   : std_logic_vector ( Comm_Width+Data_Width-1 downto 0);
213
  signal Last_Addr_Reg_1   : std_logic_vector ( Comm_Width+Data_Width-1 downto 0);
214
 
215
  signal State_Reg : integer range 0 to 5;
216
  -- Transferred_Reg - siirron tila
217
  -- 00) Ei ole siirretty viela mitaan
218
  -- 01) Osoite fifossa 0
219
  -- 02) Data fifossa 0
220
  -- 03) Osoite fifosta 1
221
  -- 04) Data fifosta 1
222
  -- 05) mol tyhjia
223
 
224
  -- Tilasiirtymat
225
  -- 00 -> 01, 03
226
  -- 01 -> 02
227
  -- 02 -> 01, 02, 03
228
  -- 03 -> 04
229
  -- 04 -> 01, 04, 05
230
  -- 05 -> 01, 03
231
 
232
begin  -- rtl
233
 
234
 
235
 
236
  -- PROC
237
  Assign_Outputs : process (State_Reg, Data_1_In, Data_0_In, Addr_Valid_1_In, Addr_Valid_0_In,
238
                            Comm_0_In, Comm_1_In, Empty_0_In, Empty_1_In,
239
                            One_Data_Left_0_In, One_Data_Left_1_In,
240
                            Last_Addr_Reg_0, Last_Addr_Reg_1, Read_Enable_In)
241
  begin  -- process Assign_Outputs
242
 
243
      case State_Reg is
244
 
245
        when 0                         =>
246
          -- Ei ole tehty mitaan
247
          Data_Out          <= (others => '0'); --  'Z'); -- '0');
248
          Comm_Out          <= (others => '0'); -- 'Z'); -- '0');
249
          Addr_Valid_Out    <= '0';
250
          Empty_Out         <= '1';
251
          RE_0_Out          <= '0';
252
          RE_1_Out          <= '0';
253
 
254
 
255
 
256
        when 1 =>
257
          -- Siirretaan osoite 0
258
 
259
          -- joko rekisterista (sama osoite kuin viimeksikin)
260
          -- tai suoraan fifosta (uusi osoite, otetaan se myos talteen)
261
          if Addr_Valid_0_In = '1' then
262
            -- Uusi osoite
263
            Data_Out        <= Data_0_In;
264
            Comm_Out        <= Comm_0_In;
265
            RE_0_Out        <= Read_Enable_In;
266
          else
267
            Data_Out        <= Last_Addr_Reg_0 (Data_Width-1 downto 0);
268
            Comm_Out        <= Last_Addr_Reg_0 ( Comm_Width+Data_Width-1 downto Data_Width);
269
            RE_0_Out        <= '0';
270
 
271
          end if;
272
          Addr_Valid_Out    <= '1';
273
          Empty_Out         <= '0';
274
          RE_1_Out          <= '0';
275
 
276
 
277
 
278
        when 2 =>
279
          -- Siirretaan data fifosta 0
280
 
281
          if Addr_Valid_0_In = '1' and One_Data_Left_0_In = '1' then
282
            -- Fifossa 0 pelkka osoite
283
 
284
            if Empty_1_In = '1'
285
              or (Addr_Valid_1_In = '1' and One_Data_Left_1_In = '1') then
286
              -- Fifo 1 tyhja tai siella pelkka osoite
287
              RE_0_Out          <= '0';
288
              RE_1_Out          <= '0';
289
              Data_Out          <= (others => '0'); -- 'X');
290
              Comm_Out          <= (others => '0'); -- 'X');
291
              Addr_Valid_Out    <= '0';
292
              Empty_Out         <= '1';
293
            else
294
              -- Fifossa 1 olisi jotain, otetaan varman paalle
295
              RE_0_Out          <= '0';
296
              RE_1_Out          <= '0';
297
              Data_Out          <= (others => '0'); -- '-');
298
              Comm_Out          <= (others => '0'); -- '-');
299
              Addr_Valid_Out    <= '0';
300
              Empty_Out         <= '1';
301
            end if;                     --e_1 || (av1&1left1)            
302
          else
303
            -- Fifossa 0 osoite+jotain tai dataa
304
            RE_0_Out          <= Read_Enable_In;
305
            RE_1_Out          <= '0';
306
 
307
            Data_Out          <= Data_0_In;
308
            Comm_Out          <= Comm_0_In;
309
            Addr_Valid_Out    <= Addr_Valid_0_In;
310
            Empty_Out         <= Empty_0_In;
311
          end if;                       --av_1
312
 
313
 
314
 
315
 
316
        when 3                      =>
317
          -- Siirretaan osoite 1
318
 
319
          if Addr_Valid_1_In = '1' then
320
            -- Uusi osoite
321
            Data_Out        <= Data_1_In;
322
            Comm_Out        <= Comm_1_In;
323
            RE_1_Out        <= Read_Enable_In;
324
          else
325
            Data_Out        <= Last_Addr_Reg_1 (Data_Width-1 downto 0);
326
            Comm_Out        <= Last_Addr_Reg_1 ( Comm_Width+Data_Width-1 downto Data_Width);
327
            RE_1_Out        <= '0';
328
          end if;
329
          RE_0_Out          <= '0';
330
          Addr_Valid_Out    <= '1';
331
          Empty_Out         <= '0';
332
 
333
 
334
 
335
 
336
        when 4 =>
337
          -- Siirretaan fifosta 1
338
 
339
 
340
          if Addr_Valid_1_In = '1' and One_Data_Left_1_In = '1' then
341
            -- Fifossa 1 pelkka osoite
342
 
343
            if Empty_0_In = '1'
344
              or (Addr_Valid_0_In = '1' and One_Data_Left_0_In = '1') then
345
              -- Fifo 0 tyhja tai siella pelkka osoite
346
              RE_0_Out          <= '0';
347
              RE_1_Out          <= '0';
348
              Data_Out          <= (others => '0'); -- 'X');
349
              Comm_Out          <= (others => '0'); -- 'X');
350
              Addr_Valid_Out    <= '0';
351
              Empty_Out         <= '1';
352
            else
353
              -- Fifossa 0 olisi jotain, otetaan varman paalle
354
              RE_0_Out          <= '0';
355
              RE_1_Out          <= '0';
356
              Data_Out          <= (others => '0'); -- '-');
357
              Comm_Out          <= (others => '0'); -- '-');
358
              Addr_Valid_Out    <= '0';
359
              Empty_Out         <= '1';
360
            end if;                     --e_0 || (av0&1left0)            
361
          else
362
            -- Fifossa 1 osoite+jotain tai dataa
363
            RE_0_Out          <= '0';
364
            RE_1_Out          <= Read_Enable_In;
365
 
366
            Data_Out          <= Data_1_In;
367
            Comm_Out          <= Comm_1_In;
368
            Addr_Valid_Out    <= Addr_Valid_1_In;
369
            Empty_Out         <= Empty_1_In;
370
          end if;                       --av_1
371
 
372
 
373
 
374
        when 5                         =>
375
          -- Molemmat fifot tyhjia
376
          RE_0_Out          <= '0';
377
          RE_1_Out          <= '0';
378
          Data_Out          <= (others => '0'); -- 'Z');  -- '0');
379
          Comm_Out          <= (others => '0'); -- 'Z');  -- '0');
380
          Addr_Valid_Out    <= '0';
381
          Empty_Out         <= '1';
382
 
383
        when others                    =>
384
          RE_0_Out          <= '0';
385
          RE_1_Out          <= '0';
386
          Data_Out          <= (others => '0'); -- 'Z');  -- '0');
387
          Comm_Out          <= (others => '0'); -- 'Z');  -- '0');
388
          Addr_Valid_Out    <= '0';
389
          Empty_Out         <= '1';
390
          assert false report "Illegal state in fifo_mux_read" severity warning;
391
      end case;
392
 
393
  end process Assign_Outputs;
394
 
395
 
396
 
397
 
398
  -- PROC
399
  Reg_proc : process (Clk, Rst_n)
400
  begin  -- process Reg_proc
401
    if Rst_n = '0' then                 -- asynchronous reset (active low)
402
      State_Reg       <= 5;
403
      Last_Addr_Reg_0 <= (others => '0'); -- '0');
404
      Last_Addr_Reg_1 <= (others => '0'); -- 'Z'); -- '0');
405
 
406
    elsif Clk'event and Clk = '1' then  -- rising clock edge
407
      case State_Reg is
408
 
409
        when 0 =>
410
--           -- Ei ole tehty mitaan
411
 
412
 
413
 
414
 
415
        when 1 =>
416
          -- Siirretaan osoite 0
417
          -- joko rekisterista (sama osoite kuin viimeksikin)
418
          -- tai suoraan fifosta (uusi osoite, otetaan se myos talteen)
419
          if Read_Enable_In = '1' then
420
            State_Reg <= 2;
421
          else
422
            State_Reg <= 1;
423
          end if;
424
 
425
          if Addr_Valid_0_In = '1' then
426
            -- Uusi osoite
427
            Last_Addr_Reg_0 <= Comm_0_In & Data_0_In;
428
          else
429
            Last_Addr_Reg_0 <= Last_Addr_Reg_0;
430
          end if;
431
 
432
 
433
 
434
        when 2 =>
435
          -- Siirretaan fifosta 0
436
 
437
          if Read_Enable_In = '1' then
438
            -- Luetaan fifosta 0
439
 
440
            if One_Data_Left_0_In = '1' then
441
              -- Oli viim data fifossa 0
442
              if Empty_1_In = '1'
443
              or (Addr_Valid_1_In = '1' and One_Data_Left_1_In = '1') then
444
                -- Myos fifo 1 tyhja tai siella pelkka osoite
445
                State_Reg <= 5;
446
              else
447
                -- Siirretaan osoite 1 (fifosta tai rekisterista)
448
                State_Reg <= 3;
449
              end if;                   --Empty_1_In
450
              Last_Addr_Reg_0 <= Last_Addr_Reg_0;
451
              Last_Addr_Reg_1 <= Last_Addr_Reg_1;
452
 
453
            else
454
              -- Fifossa 0 lukemisen jalkeenkin viela jotain
455
              State_Reg       <= 2;
456
              Last_Addr_Reg_1 <= Last_Addr_Reg_1;
457
 
458
              if Addr_Valid_0_In = '1' then
459
                -- fifosta 0 luettiin osoite
460
                Last_Addr_Reg_0 <= Comm_0_In & Data_0_In;
461
              else
462
                -- Fifosta 0 luettiin dataa
463
                Last_Addr_Reg_0 <= Last_Addr_Reg_0;
464
              end if;  --Addr_Valid_0_In
465
            end if;  --Empty_0_In
466
 
467
 
468
 
469
 
470
          else
471
            -- Odotellaan etta data luetaan
472
            State_Reg       <= 2;
473
            Last_Addr_Reg_0 <= Last_Addr_Reg_0;
474
            Last_Addr_Reg_1 <= Last_Addr_Reg_1;
475
          end if;  --Read_Enable_In
476
 
477
 
478
 
479
 
480
 
481
 
482
 
483
        when 3 =>
484
          -- Siirretaan osoite 1
485
          if Read_Enable_In = '1' then
486
              State_Reg <= 4;
487
          else
488
            -- Odotellaan lukua
489
            State_Reg <= 3;
490
          end if;
491
 
492
          if Addr_Valid_1_In = '1' then
493
            -- Uusi osoite
494
            Last_Addr_Reg_1 <= Comm_1_In & Data_1_In;
495
          else
496
            Last_Addr_Reg_1 <= Last_Addr_Reg_1;
497
          end if;
498
 
499
 
500
 
501
        when 4 =>
502
          -- Siirretaan fifosta 1
503
 
504
          if Read_Enable_In = '1' then
505
            -- Luetaan fifoa 1
506
 
507
            if Addr_Valid_1_In = '1' then
508
              -- Luetaan osoite fifosta 1
509
              Last_Addr_Reg_0 <= Last_Addr_Reg_0;
510
              Last_Addr_Reg_1 <= Comm_1_In & Data_1_In;
511
 
512
              if One_Data_Left_1_In = '1' then
513
                -- fifossa oli pelkka osoite
514
                -- puolittainen VIRHE?
515
                assert false report "Was? 1" severity note;
516
                State_Reg <= 5;
517
              else
518
                -- Fifossa 1 on myos dataa, luetaan se 
519
                -- ennen (mahdollista) siirtymista
520
                -- fifon 1 lukemiseen
521
                State_Reg <= 4;
522
              end if;  --One_Data_Left_1_In
523
 
524
            else
525
              -- Luetaan data fifosta 1
526
 
527
              if Empty_0_In = '1'
528
                or (Addr_Valid_0_In = '1' and One_Data_Left_0_In = '1') then
529
                -- Fifo 0 tyhja tai siella pelkka osoite
530
 
531
                if One_Data_Left_1_In = '0' then
532
                  -- Onneksi fifossa 1 on viela jotain
533
                  State_Reg <= 4;
534
                else
535
                  -- Ei ole siis kummassakaan fifossa mit'n
536
                  State_Reg <= 5;
537
                end if;  -- One_Data_Left_1_In
538
 
539
 
540
              else
541
                -- fifossa 0 luettavaa
542
                -- siirretann siis osoite 1 seuraavaksi (fifosta/rekisterista)
543
                State_Reg       <= 1;
544
                Last_Addr_Reg_0 <= Last_Addr_Reg_0;
545
                Last_Addr_Reg_1 <= Last_Addr_Reg_1;
546
              end if;  --Empty_0_In or (av0 & 1left_0)
547
            end if;  --Addr_Valid_0_In
548
 
549
 
550
          else
551
            -- Odotetaan etta luetaan fifoa 1
552
            --State_Reg       <= 4;
553
            Last_Addr_Reg_0 <= Last_Addr_Reg_0;
554
            Last_Addr_Reg_1 <= Last_Addr_Reg_1;
555
 
556
            if Addr_Valid_1_In = '1' and One_Data_Left_1_In ='1' then
557
              -- Ei olekaan kuin pelkka osoite fifossa #1!
558
              if Empty_0_In = '1'
559
                or (Addr_Valid_0_In = '1' and One_Data_Left_0_In ='1') then
560
                -- Ei ole fifossa 0 :kaan mitaan jarkevaa
561
                State_Reg <= 5;
562
              else
563
                -- Voidaan siirtaa osoite 0 seuraavaksi
564
                State_Reg <= 1;
565
              end if;
566
            else
567
              -- fifossa 1 on myos dataa, odotellaan lukemista
568
              State_Reg <= 4;
569
            end if;
570
 
571
 
572
 
573
          end if;  --Read_Enable_In
574
 
575
 
576
 
577
 
578
        when 5 =>
579
          -- Ei voitu lukea kummastakaan fifosta
580
 
581
          Last_Addr_Reg_0 <= Last_Addr_Reg_0;
582
          Last_Addr_Reg_1 <= Last_Addr_Reg_1;
583
 
584
 
585
          if Empty_0_In = '1' or ( Addr_Valid_0_In = '1' and One_Data_Left_0_In ='1') then
586
            -- Fifo 0 tyhja tai siella pelkka osoite
587
            if Empty_1_In = '1' or ( Addr_Valid_1_In = '1' and One_Data_Left_1_In ='1') then
588
              -- Fifo 1 tyhja tai siella pelkka osoite
589
              -- => KUmmastakaan ei voi lukea
590
              State_Reg       <= 5;
591
            else
592
              -- Fifossa 1 jotain
593
              -- siirretann siis osoite 1 seuraavaksi (fifosta/rekisterista)
594
              State_Reg <= 3;
595
            end if;--Empty_0_In or (av0 & 1left_0)
596
 
597
          else
598
            -- Fifossa 0 jotain
599
            -- siirretann siis osoite 0 seuraavaksi (fifosta/rekisterista)
600
            State_Reg <= 1;
601
          end if; --Empty_0_In or (av0 & 1left_0)
602
 
603
 
604
 
605
 
606
 
607
 
608
 
609
        when others =>
610
          assert false report "Illegal state in fifo_mux_read" severity warning;
611
      end case;
612
 
613
 
614
    end if;
615
  end process Reg_proc;
616
 
617
 
618
  -- One_Data_Left_Out on sen verta vaikea, etta tehdaan se omassa prosessissaan
619
  Assign_1_D_Left_Out : process (State_Reg,
620
                                 Data_0_In,         Data_1_In,
621
                                 Comm_0_In,         Comm_1_In,
622
                                 Empty_0_In,        Empty_1_In,
623
                                 Addr_Valid_0_In,   Addr_Valid_1_In,
624
                                 One_Data_Left_0_In,One_Data_Left_1_In,
625
                                 Last_Addr_Reg_0,   Last_Addr_Reg_1,
626
                                 Read_Enable_In)
627
  begin  -- process Assign_1_D_Left_Out
628
      case State_Reg is
629
 
630
        when 0                         =>
631
          -- Ei ole tehty mitaan
632
          One_Data_Left_Out <= '0';
633
 
634
        when 1 =>
635
          -- Siirretaan osoite 0
636
          -- ellei ihmeita tapahdu, One_Data_Left_Out pitaisi olla 0!
637
 
638
          if Addr_Valid_0_In = '1' then
639
            --Olisi syyta olla dataakin fifossa 0, toivotaan
640
            One_Data_Left_Out <= '0';
641
          else
642
            -- Sama osoite kuin viimeksi (rekisterista)
643
            if Empty_0_In = '1' then
644
              -- Fifossa 0 tyhja
645
              assert false report
646
                "Retrsnferring addr#0, but fifo#0 is empty. ERROR?" severity warning;
647
 
648
 
649
              if Empty_1_In = '1'
650
              or (Addr_Valid_1_In = '1' and One_Data_Left_1_In = '1') then
651
                -- ja fifo 1:kin on tyhja, tai siina on pelkka osoite
652
                One_Data_Left_Out <= '1';
653
              else
654
                -- Voidaan siirtya lukemaan fifoa 1
655
                One_Data_Left_Out <= '0';
656
              end if;  -- Empty_1_In || (av1 &1d_Left1)
657
            else
658
              One_Data_Left_Out <= '0';
659
            end if;  -- Empty_0_In
660
 
661
          end if;  -- Addr_Valid_0 
662
 
663
 
664
 
665
 
666
        when 2 =>
667
          -- Siirretaan data fifosta 0
668
 
669
          if One_Data_Left_0_In = '1' then
670
            -- Fifo 0 tyhjenee
671
 
672
            if Empty_1_In = '1' then
673
              -- ja fifo 1:kin on tyhja
674
              One_Data_Left_Out <= '1';
675
            else
676
              if Addr_Valid_1_In = '1' and One_Data_Left_1_In = '1' then
677
                -- Fifossa 1 pelkka osoite
678
                One_Data_Left_Out <= '1';
679
              else
680
                -- Voidaan siirtya lukemaan fifoa 1
681
                One_Data_Left_Out <= '0';
682
              end if;  --AV1 & 1D_Left1
683
            end if;  -- Empty_1_In            
684
          else
685
            -- Fifoon 0 jaa jotain
686
            One_Data_Left_Out <= '0';
687
          end if;                       --One_Data_Left_0_In
688
 
689
 
690
 
691
        when 3                      =>
692
          -- Siirretaan osoite 1
693
          -- ellei ihmeita tapahdu, One_Data_Left_Out pitaisi olla 0!
694
 
695
          if Addr_Valid_1_In = '1' then
696
            --Olisi syyta olla dataakin fifossa 1, toivotaan
697
            One_Data_Left_Out <= '0';
698
          else
699
            -- Sama osoite kuin viimeksi (rekisterista)
700
 
701
            if Empty_1_In = '1' then
702
              -- Fifo 1 on tyhja
703
              assert false report
704
                "Retrsnferring addr#1, but fifo#1 is empty. ERROR?" severity warning;
705
 
706
              if Empty_0_In = '1'
707
                or (Addr_Valid_0_In = '1' and One_Data_Left_0_In = '1' )then
708
                -- ja fifo 0:kin on tyhja
709
                One_Data_Left_Out <= '1';
710
              else
711
                -- Voidaan siirtya lukemaan fifoa 0
712
                One_Data_Left_Out <= '0';
713
              end if;  -- Empty_1_In & (AV1 & 1D_Left1)
714
                       -- 
715
            else
716
              One_Data_Left_Out <= '0';
717
            end if;  --Empty_Left_1_In
718
          end if;  -- Addr_Valid_1
719
 
720
 
721
 
722
 
723
 
724
 
725
        when 4 =>
726
          -- Siirretaan data 1
727
 
728
          if One_Data_Left_1_In = '1' then
729
            -- fifo 1 tyhjenee
730
 
731
            if Empty_0_In = '1'
732
              or (Addr_Valid_0_In = '1' and One_Data_Left_0_In = '1') then
733
              -- Fifo 0:kin on tyhja tai siella pelkka osoite
734
              One_Data_Left_Out <= '1';
735
            else
736
              -- Voidaan siirtya lukemaan fifoa 0
737
              One_Data_Left_Out <= '0';
738
            end if;                     --Empty_0_In & (av0 & 1_D_Left0)
739
 
740
          else
741
            -- Fifoon 1 jaa jotain
742
            One_Data_Left_Out <= '0';
743
          end if;                       --One_Data_Left_1_In
744
 
745
 
746
 
747
        when 5                         =>
748
          -- Molemmat fifot tyhjia
749
          One_Data_Left_Out <= '0';
750
 
751
 
752
        when others                    =>
753
          One_Data_Left_Out <= '0';
754
          assert false report "Illegal state in fifo_mux_read" severity warning;
755
      end case;
756
  end process Assign_1_D_Left_Out;
757
 
758
 
759
 
760
 
761
 
762
 
763
end rtl;
764
 
765
 
766
 
767
 
768
 
769
 
770
 
771
 

powered by: WebSVN 2.1.0

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