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/] [fifo_muxes.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        : fifo_muxes.vhdl
27
-- Description : Makes two fifos look like a single fifo.
28
--               Two components : one for writing and one for reading fifo.
29
--
30
--               Write_demux:
31
--               Input : data, addr valid and command 
32
--               Out   : data, addr valid and command to two fifos
33
--
34
--               Read_mux :
35
--               Input : data, addr valid and command from two fifos
36
--               Out   : data, addr valid and command
37
--
38
--              NOTE:
39
--              1) Fifo_mux_read does not fully support One_Data_Left_Out!
40
--
41
--              It works when writing to fifo. However, when something
42
--              is written to empty fifo, One_Data_Left_Out remains 0
43
--              even if Empty goes from 1 to 0! Be careful out there.
44
--
45
--              Case when new addr is written to fifo 0 and there is a gap before
46
--              corresponding data. At the same time there is some data in fifo
47
--              #1. It is not wise to wait for data#0, because it blocks the data#1.
48
--              In such case, transfer from fifo#0 is interrupted (Empty goes high).
49
--              At the moment, One_Data_Left_Out does not work in such case.
50
--              (Probably it could be repaired with fifo_bookkeeper component?)
51
--
52
--              2) Fifo_demux_write does not fully support One_Place_Left_Out!
53
--
54
--              When nothing is written to fifo, demux does not know which one-place
55
--              to select for output. When writing begins, it is possible that
56
--              target fifo becomes immediately full. The writer has no warning
57
--              of this event because one_place_left was zero before writing.
58
--              Same may happen when target fifo changes, e.g. data to msg
59
--              without interruption
60
--              Try-out : OR one-place_left signals together when command is IDLE
61
--              Caution : May prevent writing to one fifo if the other fifo is
62
--              is geting full.
63
--
64
--              
65
-- Author      : Erno Salminen
66
-- e-mail      : erno.salminen@tut.fi
67
-- Project     : Mikälie
68
-- Design      : Do not use term design when you mean system
69
-- Date        : 05.02.2003
70
-- Modified    : 
71
-- 18.09.03     ES generic Comb_delayG added to avoid zero delay oscillation in
72
--                 simulation
73
--
74
--              AK When no comm, full-signal is OR-red in write-demux
75
-------------------------------------------------------------------------------
76
library ieee;
77
use ieee.std_logic_1164.all;
78
use ieee.std_logic_arith.all;
79
use ieee.std_logic_unsigned.all;
80
use work.hibiv2_pkg.all;
81
 
82
 
83
 
84
 
85
 
86
-- Write_Mux checks the incoming addr. Same addr is not
87
-- written to fifo more than once! Written fifo is selected
88
-- according to incoming command
89
-- 13.04 Fully asynchronous!
90
entity fifo_demux_wr is
91
 
92
  generic (
93
--    comb_delay_g :     time    := 1 ns;  -- 18.09.03
94
    data_width_g :     integer := 0;
95
    comm_width_g :     integer := 0
96
    );
97
  port (
98
    data_in      : in  std_logic_vector (data_width_g-1 downto 0);
99
    av_in        : in  std_logic;
100
    comm_in      : in  std_logic_vector (comm_width_g-1 downto 0);
101
    we_in        : in  std_logic;
102
    full_out     : out std_logic;
103
    one_p_out    : out std_logic;
104
 
105
    -- Data/Comm/AV conencted to both fifos
106
    -- Distinction made with WE!
107
    data_out   : out std_logic_vector ( data_width_g-1 downto 0);
108
    comm_out   : out std_logic_vector ( comm_width_g-1 downto 0);
109
    av_out     : out std_logic;
110
    we_0_out   : out std_logic;
111
    we_1_out   : out std_logic;
112
    full_0_in  : in  std_logic;
113
    full_1_in  : in  std_logic;
114
    one_p_0_in : in  std_logic;
115
    one_p_1_in : in  std_logic
116
    );
117
 
118
end fifo_demux_wr;
119
 
120
 
121
 
122
 
123
 
124
architecture rtl of fifo_demux_wr is
125
 
126
  -- Selects if debug prints are used (1-3) or not ('0')
127
  constant dbg_level : integer range 0 to 3 := 0;  -- 0= no debug, use 0 for synthesis
128
 
129
  -- Registers may be reset to 'Z' to 'X' so that reset state is clearly
130
  -- distinguished from active state. Using value of rst_value_arr array(dbg_level),
131
  -- the rst value may be easily set to '0' for synthesis.
132
  constant rst_value_arr : std_logic_vector ( 6 downto 0) := 'X' & 'Z' & 'X' & 'Z' & 'X' & 'Z' & '0';
133
 
134
 
135
begin  -- rtl
136
 
137
 
138
  -- Concurrent assignments
139
  av_out   <= av_in;
140
  data_out <= data_in;
141
  comm_out <= comm_in;
142
 
143
 
144
  -- COMB PROC
145
  -- Fully combinational
146
  Demultiplex_data : process (-- data_in,
147
                              -- av_in,
148
                              comm_in, we_in,
149
                              one_p_0_in, one_p_1_in,
150
                              full_0_in, full_1_in)
151
  begin  -- process Demultiplex_data
152
 
153
 
154
 
155
    if comm_in = conv_std_logic_vector (3, comm_width_g)
156
      or comm_in = conv_std_logic_vector (7, comm_width_g) then
157
      -- MESSAGE
158
      we_0_out  <= we_in;--     after comb_delay_g;
159
      we_1_out  <= '0';
160
      full_out  <= full_0_in;-- after comb_delay_g;
161
      one_p_out <= one_p_0_in;
162
 
163
    elsif comm_in = conv_std_logic_vector (2, comm_width_g)
164
      or comm_in = conv_std_logic_vector (4, comm_width_g)
165
      or comm_in = conv_std_logic_vector (6, comm_width_g) then
166
      -- DATA
167
      we_0_out  <= '0';
168
      we_1_out  <= we_in;--     after comb_delay_g;
169
      full_out  <= full_1_in;-- after comb_delay_g;
170
      one_p_out <= one_p_1_in;
171
 
172
    elsif comm_in = conv_std_logic_vector (1, comm_width_g)
173
      or comm_in = conv_std_logic_vector (5, comm_width_g) then
174
      -- CONFIG
175
      assert false report "Config comm to fifo_demux_wr" severity warning;
176
      we_0_out  <= '0';
177
      we_1_out  <= '0';
178
      full_out  <= '0';
179
      one_p_out <= '0';
180
 
181
    else
182
      --IDLE
183
      we_0_out  <= '0';
184
      we_1_out  <= '0';
185
      full_out  <= full_1_in or full_0_in; -- 18.03.05 0'
186
      one_p_out <= one_p_0_in or one_p_1_in;  -- 24.07 '0';
187
    end if;
188
  end process Demultiplex_data;
189
 
190
 
191
 
192
end rtl;                                --fifo_demux_wr
193
 
194
 
195
 
196
 
197
 
198
 
199
-------------------------------------------------------------------------------
200
--entity fifo_mux_read kaytetaan lukemaan kahdesta fifosta osoite ja data perakkain
201
-- fifolla 0 on suurempi prioritetti. Jos ollaan lukemassa fifoa 1, ei ruveta
202
-- lukemaan fifoa 0 ennekuin on siirretty ainakin yksi data fifosta 1.
203
-- File        : fifo_muxes.vhdl
204
-- Description : Makes two fifos look like a single fifo for the reader
205
-- Author      : Erno Salminen
206
-- e-mail      : erno.salminen@tut.fi
207
-- Project     : Mikälie
208
-- Project     : Mikälie
209
-- Date        : 05.02.2003
210
-- Modified    : 
211
library ieee;
212
use ieee.std_logic_1164.all;
213
use ieee.std_logic_arith.all;
214
use ieee.std_logic_unsigned.all;
215
 
216
 
217
 
218
 
219
 
220
entity fifo_mux_rd is
221
 
222
  generic (
223
    data_width_g :     integer := 0;
224
    comm_width_g :     integer := 0
225
    );
226
  port (
227
    clk          : in  std_logic;
228
    rst_n        : in  std_logic;
229
 
230
    data_0_in    : in  std_logic_vector ( data_width_g-1 downto 0);
231
    comm_0_in    : in  std_logic_vector ( comm_width_g-1 downto 0);
232
    av_0_in      : in  std_logic;
233
    one_d_0_in   : in  std_logic;
234
    empty_0_in   : in  std_logic;
235
    re_0_Out     : out std_logic;
236
 
237
    data_1_in    : in  std_logic_vector ( data_width_g-1 downto 0);
238
    comm_1_in    : in  std_logic_vector ( comm_width_g-1 downto 0);
239
    av_1_in      : in  std_logic;
240
    one_d_1_in   : in  std_logic;
241
    empty_1_in   : in  std_logic;
242
    re_1_Out     : out std_logic;
243
 
244
    re_in        : in  std_logic;
245
    data_out     : out std_logic_vector ( data_width_g-1 downto 0);
246
    comm_out     : out std_logic_vector ( comm_width_g-1 downto 0);
247
    av_out       : out std_logic;
248
    one_d_Out    : out std_logic;
249
    empty_Out    : out std_logic
250
    );
251
 
252
end fifo_mux_rd;
253
 
254
 
255
architecture rtl of fifo_mux_rd is
256
 
257
 
258
  -- Selects if debug prints are used (1-3) or not ('0')
259
  constant dbg_level : integer range 0 to 3 := 0;  -- 0= no debug, use 0 for synthesis
260
 
261
  -- Registers may be reset to 'Z' to 'X' so that reset state is clearly
262
  -- distinguished from active state. Using dbg_level+rst_value_arr array, the rst value may
263
  -- be easily set to '0' for synthesis.
264
  constant rst_value_arr : std_logic_vector ( 6 downto 0) := 'X' & 'Z' & 'X' & 'Z' & 'X' & 'Z' & '0';
265
 
266
  type addr_comm_type is record
267
                           addr : std_logic_vector ( data_width_g -1 downto 0);
268
                           comm : std_logic_vector ( comm_width_g -1 downto 0);
269
                         end record;
270
 
271
  signal last_addr_0_r : addr_comm_type;
272
  signal last_addr_1_r : addr_comm_type;
273
 
274
 
275
  signal curr_state_r : integer range 0 to 5;
276
  -- Transferred_Reg - siirron tila
277
  -- 00) Ei ole siirretty viela mitaan, saman tien pois. Alkutila ilman resettia.
278
  -- 01) Osoite fifossa 0
279
  -- 02) data   fifossa 0
280
  -- 03) Osoite fifosta 1
281
  -- 04) data   fifosta 1
282
  -- 05) molemmat fifot tyhjia. Alkutila resetissa.
283
 
284
  -- Tilasiirtymat
285
  -- 00 -> 05
286
  -- 01 -> 02
287
  -- 02 -> 01, 02, 03
288
  -- 03 -> 04
289
  -- 04 -> 01, 04, 05
290
  -- 05 -> 01, 03
291
 
292
begin  -- rtl
293
 
294
 
295
 
296
  -- COMB PROC
297
  Assign_Outputs : process (curr_state_r,
298
                            av_1_in, av_0_in,
299
                            data_1_in, data_0_in,
300
                            comm_1_in, comm_0_in,
301
                            empty_1_in, empty_0_in,
302
                            one_d_1_in, one_d_0_in,
303
                            Last_Addr_0_r, Last_Addr_1_r,
304
                            re_in
305
                            )
306
  begin  -- process Assign_Outputs
307
 
308
      case curr_state_r is
309
 
310
        when 0                 =>
311
          -- Ei ole tehty mitaan
312
          data_out  <= (others => rst_value_arr (dbg_level *1));
313
          comm_out  <= (others => rst_value_arr (dbg_level *1));
314
          av_out    <= '0';
315
          empty_Out <= '1';
316
          re_0_Out  <= '0';
317
          re_1_Out  <= '0';
318
 
319
 
320
 
321
        when 1 =>
322
          -- Osoite fifossa 0
323
          -- Siirretaan osoite 0
324
 
325
          -- joko rekisterista (sama osoite kuin viimeksikin)
326
          -- tai suoraan fifosta (uusi osoite, otetaan se myos talteen)
327
          if av_0_in = '1' then
328
            -- Uusi osoite
329
            data_out <= data_0_in;
330
            comm_out <= comm_0_in;
331
            re_0_Out <= re_in;
332
          else
333
            data_out <= Last_Addr_0_r.addr;
334
            comm_out <= Last_Addr_0_r.comm;
335
            re_0_Out <= '0';
336
 
337
          end if;
338
          av_out    <= '1';
339
          empty_Out         <= '0';
340
          re_1_Out          <= '0';
341
 
342
 
343
 
344
        when 2 =>
345
          -- data fifossa 0
346
          -- Siirretaan data fifosta 0
347
 
348
          if av_0_in = '1' and one_d_0_in = '1' then
349
            -- Fifossa 0 pelkka osoite
350
 
351
            if empty_1_in = '1'
352
              or (av_1_in = '1' and one_d_1_in = '1') then
353
              -- Fifo 1 tyhja tai siella pelkka osoite
354
              re_0_Out  <= '0';
355
              re_1_Out  <= '0';
356
              data_out  <= (others => rst_value_arr (dbg_level *2));
357
              comm_out  <= (others => rst_value_arr (dbg_level *2));
358
              av_out    <= '0';
359
              empty_Out <= '1';
360
            else
361
              -- Fifossa 1 olisi jotain, otetaan varman paalle
362
              re_0_Out  <= '0';
363
              re_1_Out  <= '0';
364
              data_out  <= (others => rst_value_arr (dbg_level *2));
365
              comm_out  <= (others => rst_value_arr (dbg_level *2));
366
              av_out    <= '0';
367
              empty_Out <= '1';
368
            end if;  --e_1 || (av1&1left1)            
369
          else
370
            -- Fifossa 0 osoite+jotain tai dataa
371
            re_0_Out    <= re_in;
372
            re_1_Out    <= '0';
373
 
374
            data_out  <= data_0_in;
375
            comm_out  <= comm_0_in;
376
            av_out    <= av_0_in;
377
            empty_Out <= empty_0_in;
378
          end if;  --av_1
379
 
380
 
381
 
382
 
383
        when 3                      =>
384
          -- Osoite fifossa 1
385
          -- Siirretaan osoite 1
386
 
387
          if av_1_in = '1' then
388
            -- Uusi osoite
389
            data_out <= data_1_in;
390
            comm_out <= comm_1_in;
391
            re_1_Out <= re_in;
392
          else
393
            data_out <= Last_Addr_1_r.addr;
394
            comm_out <= Last_Addr_1_r.comm;
395
            re_1_Out <= '0';
396
          end if;
397
          re_0_Out   <= '0';
398
          av_out     <= '1';
399
          empty_Out  <= '0';
400
 
401
 
402
 
403
 
404
        when 4 =>
405
          -- data fifossa 1
406
          -- Siirretaan fifosta 1
407
 
408
 
409
          if av_1_in = '1' and one_d_1_in = '1' then
410
            -- Fifossa 1 pelkka osoite
411
 
412
            if empty_0_in = '1'
413
              or (av_0_in = '1' and one_d_0_in = '1') then
414
              -- Fifo 0 tyhja tai siella pelkka osoite
415
              re_0_Out  <= '0';
416
              re_1_Out  <= '0';
417
              data_out  <= (others => rst_value_arr (dbg_level *2));
418
              comm_out  <= (others => rst_value_arr (dbg_level *2));
419
              av_out    <= '0';
420
              empty_Out <= '1';
421
            else
422
              -- Fifossa 0 olisi jotain, otetaan varman paalle
423
              re_0_Out  <= '0';
424
              re_1_Out  <= '0';
425
              data_out  <= (others => rst_value_arr (dbg_level *2));
426
              comm_out  <= (others => rst_value_arr (dbg_level *2));
427
              av_out    <= '0';
428
              empty_Out <= '1';
429
            end if;  --e_0 || (av0&1left0)            
430
          else
431
            -- Fifossa 1 osoite+jotain tai dataa
432
            re_0_Out    <= '0';
433
            re_1_Out    <= re_in;
434
 
435
            data_out  <= data_1_in;
436
            comm_out  <= comm_1_in;
437
            av_out    <= av_1_in;
438
            empty_Out <= empty_1_in;
439
          end if;  --av_1
440
 
441
 
442
 
443
        when 5                 =>
444
          -- Molemmat fifot tyhjia
445
          re_0_Out  <= '0';
446
          re_1_Out  <= '0';
447
          data_out  <= (others => rst_value_arr (dbg_level *1));
448
          comm_out  <= (others => rst_value_arr (dbg_level *1));
449
          av_out    <= '0';
450
          empty_Out <= '1';
451
 
452
        when others            =>
453
          re_0_Out  <= '0';
454
          re_1_Out  <= '0';
455
          data_out  <= (others => rst_value_arr (dbg_level));
456
          comm_out  <= (others => rst_value_arr (dbg_level));
457
          av_out    <= '0';
458
          empty_Out <= '1';
459
          assert false report "Illegal state in fifo_mux_rd" severity warning;
460
      end case;
461
 
462
  end process Assign_Outputs;
463
 
464
 
465
 
466
 
467
  -- SEQ PROC
468
  Reg_proc : process (clk, rst_n)
469
  begin  -- process Reg_proc
470
    if rst_n = '0' then                 -- asynchronous reset (active low)
471
      curr_state_r       <= 5;
472
      Last_Addr_0_r.addr <= (others => rst_value_arr (dbg_level));
473
      Last_Addr_0_r.comm <= (others => rst_value_arr (dbg_level));
474
      Last_Addr_1_r.addr <= (others => rst_value_arr (dbg_level));
475
      Last_Addr_1_r.comm <= (others => rst_value_arr (dbg_level));
476
 
477
    elsif clk'event and clk = '1' then  -- rising clock edge
478
      case curr_state_r is
479
 
480
        when 0 =>
481
          --           -- Ei ole tehty mitaan
482
          -- Tassa tilassa ei kauaa viihdy.
483
          curr_state_r <= 5;
484
 
485
 
486
 
487
        when 1 =>
488
          -- Siirretaan osoite 0
489
          -- joko rekisterista (sama osoite kuin viimeksikin)
490
          -- tai suoraan fifosta (uusi osoite, otetaan se myos talteen)
491
          if re_in = '1' then
492
            curr_state_r <= 2;
493
          else
494
            curr_state_r <= 1;
495
          end if;
496
 
497
          if av_0_in = '1' then
498
            -- Uusi osoite
499
            Last_Addr_0_r.addr <= data_0_in;
500
            Last_Addr_0_r.comm <= comm_0_in;
501
          else
502
            Last_Addr_0_r      <= Last_Addr_0_r;
503
          end if;
504
 
505
 
506
 
507
        when 2 =>
508
          -- Siirretaan fifosta 0
509
 
510
          if re_in = '1' then
511
            -- Luetaan fifosta 0
512
 
513
            if one_d_0_in = '1' then
514
              -- Oli viim data fifossa 0
515
              if empty_1_in = '1'
516
              or (av_1_in = '1' and one_d_1_in = '1') then
517
                -- Myos fifo 1 tyhja tai siella pelkka osoite
518
                curr_state_r <= 5;
519
              else
520
                -- Siirretaan osoite 1 (fifosta tai rekisterista)
521
                curr_state_r <= 3;
522
              end if;                   --empty_1_in
523
              Last_Addr_0_r <= Last_Addr_0_r;
524
              Last_Addr_1_r <= Last_Addr_1_r;
525
 
526
            else
527
              -- Fifossa 0 lukemisen jalkeenkin viela jotain
528
              curr_state_r       <= 2;
529
              Last_Addr_1_r <= Last_Addr_1_r;
530
 
531
              if av_0_in = '1' then
532
                -- fifosta 0 luettiin osoite
533
                Last_Addr_0_r.addr <= data_0_in;
534
                Last_Addr_0_r.comm <= comm_0_in;
535
              else
536
                -- Fifosta 0 luettiin dataa
537
                Last_Addr_0_r      <= Last_Addr_0_r;
538
              end if;  --av_0_in
539
            end if;  --empty_0_in
540
 
541
 
542
 
543
 
544
          else
545
            -- Odotellaan etta data luetaan
546
            curr_state_r       <= 2;
547
            Last_Addr_0_r <= Last_Addr_0_r;
548
            Last_Addr_1_r <= Last_Addr_1_r;
549
          end if;  --re_in
550
 
551
 
552
 
553
 
554
 
555
 
556
 
557
        when 3 =>
558
          -- Siirretaan osoite 1
559
          if re_in = '1' then
560
              curr_state_r <= 4;
561
          else
562
            -- Odotellaan lukua
563
            curr_state_r <= 3;
564
          end if;
565
 
566
          if av_1_in = '1' then
567
            -- Uusi osoite
568
            Last_Addr_1_r.addr <= data_1_in;
569
            Last_Addr_1_r.comm <= comm_1_in;
570
          else
571
            Last_Addr_1_r <= Last_Addr_1_r;
572
          end if;
573
 
574
 
575
 
576
        when 4 =>
577
          -- Siirretaan fifosta 1
578
 
579
          if re_in = '1' then
580
            -- Luetaan fifoa 1
581
 
582
            if av_1_in = '1' then
583
              -- Luetaan osoite fifosta 1
584
              Last_Addr_0_r      <= Last_Addr_0_r;
585
              Last_Addr_1_r.addr <= data_1_in;
586
              Last_Addr_1_r.comm <= comm_1_in;
587
 
588
              if one_d_1_in = '1' then
589
                -- fifossa oli pelkka osoite
590
                -- puolittainen VIRHE?
591
                --assert false report "Was? 1" severity note;
592
                curr_state_r <= 5;
593
              else
594
                -- Fifossa 1 on myos dataa, luetaan se 
595
                -- ennen (mahdollista) siirtymista
596
                -- fifon 1 lukemiseen
597
                curr_state_r <= 4;
598
              end if;  --one_d_1_in
599
 
600
            else
601
              -- Luetaan data fifosta 1
602
 
603
              if empty_0_in = '1'
604
                or (av_0_in = '1' and one_d_0_in = '1') then
605
                -- Fifo 0 tyhja tai siella pelkka osoite
606
 
607
                if one_d_1_in = '0' then
608
                  -- Onneksi fifossa 1 on viela jotain
609
                  curr_state_r <= 4;
610
                else
611
                  -- Ei ole siis kummassakaan fifossa mit'n
612
                  curr_state_r <= 5;
613
                end if;  -- one_d_1_in
614
 
615
 
616
              else
617
                -- fifossa 0 luettavaa
618
                -- siirretann siis osoite 1 seuraavaksi (fifosta/rekisterista)
619
                curr_state_r       <= 1;
620
                Last_Addr_0_r <= Last_Addr_0_r;
621
                Last_Addr_1_r <= Last_Addr_1_r;
622
              end if;  --empty_0_in or (av0 & 1left_0)
623
            end if;  --av_0_in
624
 
625
 
626
          else
627
            -- Odotetaan etta luetaan fifoa 1
628
            --curr_state_r       <= 4;
629
            Last_Addr_0_r <= Last_Addr_0_r;
630
            Last_Addr_1_r <= Last_Addr_1_r;
631
 
632
            if av_1_in = '1' and one_d_1_in ='1' then
633
              -- Ei olekaan kuin pelkka osoite fifossa #1!
634
              if empty_0_in = '1'
635
                or (av_0_in = '1' and one_d_0_in ='1') then
636
                -- Ei ole fifossa 0 :kaan mitaan jarkevaa
637
                curr_state_r <= 5;
638
              else
639
                -- Voidaan siirtaa osoite 0 seuraavaksi
640
                curr_state_r <= 1;
641
              end if;
642
            else
643
              -- fifossa 1 on myos dataa, odotellaan lukemista
644
              curr_state_r <= 4;
645
            end if;
646
 
647
 
648
 
649
          end if;  --re_in
650
 
651
 
652
 
653
 
654
        when 5 =>
655
          -- Ei voitu lukea kummastakaan fifosta
656
 
657
          Last_Addr_0_r <= Last_Addr_0_r;
658
          Last_Addr_1_r <= Last_Addr_1_r;
659
 
660
 
661
          if empty_0_in = '1' or ( av_0_in = '1' and one_d_0_in ='1') then
662
            -- Fifo 0 tyhja tai siella pelkka osoite
663
            if empty_1_in = '1' or ( av_1_in = '1' and one_d_1_in ='1') then
664
              -- Fifo 1 tyhja tai siella pelkka osoite
665
              -- => KUmmastakaan ei voi lukea
666
              curr_state_r       <= 5;
667
            else
668
              -- Fifossa 1 jotain
669
              -- siirretann siis osoite 1 seuraavaksi (fifosta/rekisterista)
670
              curr_state_r <= 3;
671
            end if;--empty_0_in or (av0 & 1left_0)
672
 
673
          else
674
            -- Fifossa 0 jotain
675
            -- siirretann siis osoite 0 seuraavaksi (fifosta/rekisterista)
676
            curr_state_r <= 1;
677
          end if; --empty_0_in or (av0 & 1left_0)
678
 
679
 
680
 
681
 
682
 
683
 
684
 
685
        when others =>
686
          assert false report "Illegal state in fifo_mux_rd" severity warning;
687
      end case;
688
 
689
 
690
    end if;
691
  end process Reg_proc;
692
 
693
 
694
  -- one_d_Out on sen verta vaikea, etta tehdaan se omassa prosessissaan
695
  Assign_1_D_Left_Out : process (curr_state_r,
696
                                 -- data_0_in,     data_1_in,
697
                                 -- comm_0_in,     comm_1_in,
698
                                 empty_0_in,    empty_1_in,
699
                                 av_0_in,       av_1_in,
700
                                 one_d_0_in,    one_d_1_in--,
701
                                 -- Last_Addr_0_r, Last_Addr_1_r,
702
                                 -- re_in
703
                                 )
704
  begin  -- process Assign_1_D_Left_Out
705
      case curr_state_r is
706
 
707
        when 0                         =>
708
          -- Ei ole tehty mitaan
709
          one_d_Out <= '0';
710
 
711
        when 1 =>
712
          -- Siirretaan osoite 0
713
          -- ellei ihmeita tapahdu, one_d_Out pitaisi olla 0!
714
 
715
          if av_0_in = '1' then
716
            --Olisi syyta olla dataakin fifossa 0, toivotaan
717
            one_d_Out <= '0';
718
          else
719
            -- Sama osoite kuin viimeksi (rekisterista)
720
            if empty_0_in = '1' then
721
              -- Fifossa 0 tyhja
722
              assert false report
723
                "Retrsnferring addr#0, but fifo#0 is empty. ERROR?" severity warning;
724
 
725
 
726
              if empty_1_in = '1'
727
              or (av_1_in = '1' and one_d_1_in = '1') then
728
                -- ja fifo 1:kin on tyhja, tai siina on pelkka osoite
729
                one_d_Out <= '1';
730
              else
731
                -- Voidaan siirtya lukemaan fifoa 1
732
                one_d_Out <= '0';
733
              end if;  -- empty_1_in || (av1 &1d_Left1)
734
            else
735
              one_d_Out <= '0';
736
            end if;  -- empty_0_in
737
 
738
          end if;  -- av_0 
739
 
740
 
741
 
742
 
743
        when 2 =>
744
          -- Siirretaan data fifosta 0
745
 
746
          if one_d_0_in = '1' then
747
            -- Fifo 0 tyhjenee
748
 
749
            if empty_1_in = '1' then
750
              -- ja fifo 1:kin on tyhja
751
              one_d_Out   <= '1';
752
            else
753
              if av_1_in = '1' and one_d_1_in = '1' then
754
                -- Fifossa 1 pelkka osoite
755
                one_d_Out <= '1';
756
              else
757
                -- Voidaan siirtya lukemaan fifoa 1
758
                one_d_Out <= '0';
759
              end if;  --AV1 & 1D_Left1
760
            end if;  -- empty_1_in            
761
          else
762
            -- Fifoon 0 jaa jotain
763
            one_d_Out     <= '0';
764
          end if;  --one_d_0_in
765
 
766
 
767
 
768
        when 3                      =>
769
          -- Siirretaan osoite 1
770
          -- ellei ihmeita tapahdu, one_d_Out pitaisi olla 0!
771
 
772
          if av_1_in = '1' then
773
            --Olisi syyta olla dataakin fifossa 1, toivotaan
774
            one_d_Out <= '0';
775
          else
776
            -- Sama osoite kuin viimeksi (rekisterista)
777
 
778
            if empty_1_in = '1' then
779
              -- Fifo 1 on tyhja
780
              assert false report
781
                "Retrsnferring addr#1, but fifo#1 is empty. ERROR?" severity warning;
782
 
783
              if empty_0_in = '1'
784
                or (av_0_in = '1' and one_d_0_in = '1' )then
785
                -- ja fifo 0:kin on tyhja
786
                one_d_Out <= '1';
787
              else
788
                -- Voidaan siirtya lukemaan fifoa 0
789
                one_d_Out <= '0';
790
              end if;  -- empty_1_in & (AV1 & 1D_Left1)
791
                       -- 
792
            else
793
              one_d_Out   <= '0';
794
            end if;  --empty_Left_1_in
795
          end if;  -- av_1
796
 
797
 
798
 
799
 
800
 
801
 
802
        when 4 =>
803
          -- Siirretaan data 1
804
 
805
          if one_d_1_in = '1' then
806
            -- fifo 1 tyhjenee
807
 
808
            if empty_0_in = '1'
809
              or (av_0_in = '1' and one_d_0_in = '1') then
810
              -- Fifo 0:kin on tyhja tai siella pelkka osoite
811
              one_d_Out <= '1';
812
            else
813
              -- Voidaan siirtya lukemaan fifoa 0
814
              one_d_Out <= '0';
815
            end if;  --empty_0_in & (av0 & 1_D_Left0)
816
 
817
          else
818
            -- Fifoon 1 jaa jotain
819
            one_d_Out <= '0';
820
          end if;                       --one_d_1_in
821
 
822
 
823
 
824
        when 5                         =>
825
          -- Molemmat fifot tyhjia
826
          one_d_Out <= '0';
827
 
828
 
829
        when others                    =>
830
          one_d_Out <= '0';
831
          assert false report "Illegal state in fifo_mux_rd" severity warning;
832
      end case;
833
  end process Assign_1_D_Left_Out;
834
 
835
end rtl;
836
 
837
 
838
 
839
 
840
 
841
 
842
 
843
 

powered by: WebSVN 2.1.0

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