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/] [addr_data_muxes.vhd] - Blame information for rev 148

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        : addr_data_muxes.vhdl
27
-- Design
28
-- Description : Converts separated addr+data signalling into multiplexed addr/data.
29
--               Two components : one for writing and one for reading fifo.
30
--               Input : separate addr + data ports
31
--               Out   : addr + data muxed into one port
32
--               Write_Mux checks the incoming addr+comm. Same addr+comm is not
33
--               written to fifo more than once!
34
--               
35
-- Author      : Erno Salminen
36
-- e-mail       : erno.salminen@tut.fi
37
-- Design      : Do not use term design when you mean system
38
-- Project      huuhaa
39
-- Date        : 15.01.2003
40
-- Modified    : 
41
--               
42
-- 20.01        ES Comm_In/Out added
43
-- 05.02.2003   Name changed from fifo_mux_X to addr_data_mux_X
44
-- 26.03.03     Last_Comm_Reg added
45
-- 18.09.03     ES one_place / one_dat could be removed ??
46
-- 10.11.03     ES  write:elsif Full_In = '1' and Tmp_Data_Valid_Reg = '0' added 10.11.2003 es
47
--
48
-- 15.12.04     ES names changed
49
-------------------------------------------------------------------------------
50
library ieee;
51
use ieee.std_logic_1164.all;
52
use ieee.std_logic_arith.all;
53
use ieee.std_logic_unsigned.all;
54
 
55
 
56
 
57
 
58
 
59
entity addr_data_mux_write is
60
 
61
  generic (
62
    data_width_g         :     integer := 0;
63
    addr_width_g         :     integer := 0;
64
    comm_width_g         :     integer := 0
65
    );
66
  port (
67
    clk                : in  std_logic;
68
    rst_n              : in  std_logic;
69
 
70
    data_in   : in  std_logic_vector ( data_width_g-1 downto 0);
71
    addr_in   : in  std_logic_vector ( addr_width_g-1 downto 0);
72
    comm_in   : in  std_logic_vector ( comm_width_g-1 downto 0);
73
    we_in     : in  std_logic;
74
    full_out  : out std_logic;
75
    one_p_out : out std_logic;          -- unused ??
76
 
77
    data_out : out std_logic_vector ( data_width_g-1 downto 0);
78
    comm_out : out std_logic_vector ( comm_width_g-1 downto 0);
79
    av_out   : out std_logic;
80
    we_out   : out std_logic;
81
    one_p_in : in  std_logic;           -- ununsed ??
82
    full_in  : in  std_logic
83
    );
84
 
85
end addr_data_mux_write;
86
 
87
 
88
 
89
architecture rtl of addr_data_mux_write is
90
 
91
  -- rekisterit
92
  signal   state_r    : integer range 0 to 4;
93
  signal   next_state : integer range 0 to 4;
94
  -- Tilakoodaus
95
  -- 0 idle
96
  -- 1 write addr, keep output, write d_r when leaving
97
  -- 2 write data
98
  -- 3 write data full, keep output, write d_r when leaving
99
  -- 4 write data full 2, keep output, write a_r when leaving
100
  constant idle_c     : integer := 0;
101
  constant wr_a_c     : integer := 1;
102
  constant wr_d_c     : integer := 2;
103
  constant wr_d_f1_c  : integer := 3;
104
  constant wr_d_f2_c  : integer := 4;
105
 
106
 
107
  signal addr_r     : std_logic_vector ( addr_width_g-1 downto 0);
108
  signal comm_r     : std_logic_vector ( comm_width_g-1 downto 0);
109
  signal comm_out_r : std_logic_vector ( comm_width_g-1 downto 0);
110
  signal data_r     : std_logic_vector ( data_width_g-1 downto 0);
111
  signal data_out_r : std_logic_vector ( data_width_g-1 downto 0);
112
  signal full_out_r : std_logic;
113
  signal av_out_r   : std_logic;
114
  signal we_out_r   : std_logic;
115
 
116
 
117
begin  -- rtl
118
 
119
  -- Concurrent assignments
120
  av_out   <= av_out_r;
121
  full_out <= full_out_r;
122
  comm_out <= comm_out_r;
123
  data_out <= data_out_r;
124
  we_out   <= we_out_r;
125
 
126
  -- Unused?? 08.02.05 
127
  one_p_out <= one_p_in;                -- ???
128
 
129
 
130
  -- COMB PROC
131
  -- Define next state
132
  Define_next_state : process ( addr_in,
133
                                --data_in,comm_in,
134
                                we_in, full_in,
135
                               addr_r, state_r)
136
  begin  -- process Define_next_state
137
    case state_r is
138
 
139
      when idle_c =>
140
        if we_in = '0' then
141
          next_state <= idle_c;
142
        else
143
          if addr_in = addr_r then
144
            next_state <= wr_d_c;
145
          else
146
            next_state <= wr_a_c;
147
          end if;
148
        end if;
149
 
150
      when wr_a_c =>
151
        if full_in = '0' then
152
          next_state <= wr_d_c;
153
        else
154
          next_state <= wr_a_c;
155
        end if;
156
 
157
      when wr_d_c =>
158
        if full_in = '0' then
159
          if we_in = '0' then
160
            next_state <= idle_c;
161
          else
162
            if addr_in = addr_r then
163
              next_state <= wr_d_c;
164
            else
165
              next_state <= wr_a_c;
166
            end if;
167
          end if;
168
        else
169
          if we_in = '0' then
170
            next_state <= wr_d_c;
171
          else
172
            if addr_in = addr_r then
173
              next_state <= wr_d_f1_c;
174
            else
175
              next_state <= wr_d_f2_c;
176
            end if;
177
          end if;
178
        end if;
179
 
180
 
181
      when wr_d_f1_c =>
182
        if full_in = '0' then
183
          next_state <= wr_d_c;
184
        else
185
          next_state <= wr_d_f1_c;
186
        end if;
187
 
188
      when wr_d_f2_c =>
189
        if full_in = '0' then
190
          next_state <= wr_a_c;
191
        else
192
          next_state <= wr_d_f2_c;
193
        end if;
194
 
195
 
196
      when others =>
197
        next_state <= idle_c;
198
        assert false report "Illegal state in addr_data_mux_write" severity WARNING;
199
 
200
    end case;                           -- state_r
201
 
202
  end process Define_next_state;
203
 
204
 
205
  -- SEQ PROC
206
  -- Change state
207
  change_state: process (clk, rst_n)
208
  begin  -- process change_state
209
    if rst_n = '0' then                 -- asynchronous reset (active low)
210
      state_r <= 0;
211
    elsif clk'event and clk = '1' then  -- rising clock edge
212
      state_r <= next_state;
213
    end if;
214
  end process change_state;
215
 
216
 
217
 
218
  -- SEQ PROC
219
  -- Define output
220
  Define_output : process (clk, rst_n)
221
  begin  -- process Define_output
222
    if rst_n = '0' then                 -- asynchronous reset (active low)
223
      full_out_r <= '0';
224
      av_out_r   <= '0';
225
      data_out_r <= (others => '0');    -- 'Z');
226
      comm_out_r <= "000";
227
      we_out_r   <= '0';
228
 
229
      addr_r <= (others => '1'); -- 'Z');
230
      comm_r <= (others => '0');
231
      data_r <= (others => '0'); -- 'Z');
232
 
233
    elsif clk'event and clk = '1' then  -- rising clock edge
234
 
235
      -- Registers keep their values by default
236
      full_out_r <= full_out_r;
237
      av_out_r   <= av_out_r;
238
      data_out_r <= data_out_r;
239
      comm_out_r <= comm_out_r;
240
      we_out_r   <= we_out_r;
241
 
242
      addr_r <= addr_r;
243
      comm_r <= comm_r;
244
      data_r <= DAta_r;
245
 
246
 
247
      -- Always write when not in IDLE state
248
      if next_state = idle_c then
249
        we_out_r <= '0';
250
      else
251
        we_out_r <= '1';
252
      end if;
253
 
254
      -- adrresses are awriten only in state wr_a_c
255
      if next_state = wr_a_c then
256
        av_out_r <= '1';
257
      else
258
        av_out_r <= '0';
259
      end if;
260
 
261
 
262
      -- Define register values
263
      case state_r is
264
        when idle_c                 =>
265
          if next_state = idle_c then
266
            full_out_r <= '0';
267
            data_out_r <= (others => '0'); -- 'Z');
268
            comm_out_r <= (others => '0');
269
          elsif next_state = wr_d_c then
270
            full_out_r <= '0';
271
            data_out_r <= data_in;
272
            comm_out_r <= comm_in;
273
          else
274
            --next_state <= wr_a_c;
275
            full_out_r <= '1';
276
            data_out_r <= addr_in;
277
            comm_out_r <= comm_in;
278
            addr_r     <= addr_in;
279
            data_r     <= data_in;
280
            comm_r     <= comm_in;
281
          end if;
282
 
283
        when wr_a_c                   =>
284
          if next_state = wr_d_c then
285
            full_out_r <= '0';
286
            data_out_r <= data_r;
287
            comm_out_r <= comm_r;
288
            data_r     <= (others => '0'); -- 'Z');
289
          else
290
            -- next_state <= wr_a_c;
291
            full_out_r <= '1';
292
            data_out_r <= data_out_r;
293
            comm_out_r <= comm_out_r;
294
          end if;
295
 
296
        when wr_d_c                     =>
297
          if next_state = wr_d_c then
298
            if we_in = '0' then
299
              full_out_r <= '0';
300
              data_out_r <= data_out_r;
301
              comm_out_r <= comm_out_r;
302
            else
303
              full_out_r <= '0';
304
              data_out_r <= data_in;
305
              comm_out_r <= comm_in;
306
            end if;
307
            data_r       <= (others => '0'); -- 'Z');
308
          elsif next_state = wr_a_c then
309
            full_out_r   <= '1';
310
            data_out_r   <= addr_in;
311
            comm_out_r   <= comm_in;
312
            addr_r       <= addr_in;
313
            data_r       <= data_in;
314
            comm_r       <= comm_in;
315
          elsif next_state = wr_d_f1_c then
316
            full_out_r   <= '1';
317
            data_out_r   <= data_out_r;
318
            comm_out_r   <= comm_out_r;
319
            data_r       <= data_in;
320
            comm_r       <= comm_in;    -- 2011-01-19
321
          elsif next_state = wr_d_f2_c then
322
            full_out_r   <= '1';
323
            data_out_r   <= data_out_r;
324
            comm_out_r   <= comm_out_r;
325
            addr_r       <= addr_in;
326
            data_r       <= data_in;
327
            comm_r       <= comm_in;
328
          else
329
            -- next_state = idle_c
330
            full_out_r   <= '0';
331
            data_out_r   <= (others => '0'); -- 'Z');
332
            comm_out_r   <= (others => '0');
333
            data_r       <= (others => '0'); -- 'Z');
334
 
335
          end if;
336
 
337
 
338
        when wr_d_f1_c =>
339
          if next_state = wr_d_c then
340
            full_out_r <= '0';
341
            data_out_r <= data_r;
342
            comm_out_r <= comm_r;
343
            data_r <=  (others => '0'); -- 'Z');
344
          else
345
            -- next_state <= wr_d_f1_c;
346
            full_out_r <= '1';
347
            data_out_r <= data_out_r;
348
            comm_out_r <= comm_out_r;
349
          end if;
350
 
351
        when wr_d_f2_c =>
352
          if next_state = wr_a_c then
353
            full_out_r <= '1';
354
            data_out_r <= addr_r;
355
            comm_out_r <= comm_r;
356
          else
357
            --next_state <= wr_d_f2_c;
358
            full_out_r <= '1';
359
            data_out_r <= data_out_r;
360
            comm_out_r <= comm_out_r;
361
         end if;
362
      end case;
363
    end if;  -- rst_n/clk
364
  end process Define_output;
365
 
366
 
367
end rtl;
368
 
369
 
370
 
371
 
372
 
373
 
374
-------------------------------------------------------------------------------
375
-------------------------------------------------------------------------------
376
-- File        : addr_data_muxes.vhdl
377
-- Design
378
-- Description : Converts separated addr+data signalling into multiplexed addr/data.
379
--               Two components : one for writing and one for reading fifo.
380
--               Input : separate addr + data ports
381
--               Out   : addr + data muxed into one port
382
--               Write_Mux checks the incoming addr+comm. Same addr+comm is not
383
--               written to fifo more than once!
384
--               
385
-- Author      : Erno Salminen
386
-- e-mail      : erno.salminen@tut.fi
387
-- Design      : Do not use term design (noun) when you mean system
388
-- Project     : huuhaa
389
-- Date        : 15.01.2003
390
-- Modified    : 
391
--entityä addr_data_mux_read kaytetaan lukemaan fifosta osoite ja data rinnakkain ja
392
-- siirretaan ne perakkain IP:lle
393
library ieee;
394
use ieee.std_logic_1164.all;
395
use ieee.std_logic_arith.all;
396
use ieee.std_logic_unsigned.all;
397
 
398
 
399
 
400
 
401
 
402
entity addr_data_mux_read is
403
 
404
  generic (
405
    data_width_g         :     integer := 0;
406
    addr_width_g         :     integer := 0;
407
    comm_width_g         :     integer := 0
408
    );
409
  port (
410
    clk              : in  std_logic;
411
    rst_n            : in  std_logic;
412
 
413
    addr_in  : in  std_logic_vector ( addr_width_g-1 downto 0);
414
    data_in  : in  std_logic_vector ( data_width_g-1 downto 0);
415
    comm_in  : in  std_logic_vector ( comm_width_g-1 downto 0);
416
    one_d_in : in  std_logic;           -- unused ??
417
    empty_in : in  std_logic;
418
    re_out   : out std_logic;
419
 
420
    re_in          : in  std_logic;
421
    data_out       : out std_logic_vector ( data_width_g-1 downto 0);
422
    comm_out       : out std_logic_vector ( comm_width_g-1 downto 0);
423
    av_out : out std_logic;
424
    one_d_out      : out std_logic;     -- unused??
425
    empty_out      : out std_logic
426
    );
427
 
428
end addr_data_mux_read;
429
 
430
 
431
architecture rtl of addr_data_mux_read is
432
  signal last_addr_r   : std_logic_vector ( addr_width_g -1 downto 0);
433
  signal last_comm_r   : std_logic_vector ( comm_width_g -1 downto 0);  --26.03.03
434
 
435
  signal Transferred_r : std_logic_vector ( 1 downto 0);
436
  -- Transferred_r - siirron tila
437
  -- 00) Ei ole siirretty viela mitaan
438
  -- 01) Uusi osoite siirretty
439
  -- 10) Osoite ja ainakin yksi data siirretty
440
  -- 11) ?? Laiton tila
441
 
442
begin  -- rtl
443
 
444
 
445
 
446
 
447
 
448
 
449
  --PROC
450
  -- Herkkyyslista muutettu 26.03.03
451
  --Assign_outputs : process (re_in, empty_in, last_addr_r, addr_in,
452
  --                     data_in, Transferred_r, comm_in)
453
  Assign_outputs : process (re_in, empty_in, last_addr_r, last_comm_r,
454
                            addr_in, data_in, Transferred_r, comm_in)
455
 
456
  begin  -- process Assign_outputs
457
 
458
    if Transferred_r = "00" then
459
      -- Ei ole viela sirretty mitaan/uutta osoitetta
460
 
461
      re_out <= '0';
462
      empty_out       <= empty_in;
463
 
464
      if empty_in = '1' then
465
        -- Ei ole mitaan siirrettavaa        
466
        data_out       <= (others => '0'); -- X');
467
        comm_out       <= (others => '0'); -- 'X'); 
468
        av_out <= '0';
469
 
470
      else
471
        -- Fifo ei ole tyhja        
472
        --muutos 26.03.03: if addr_in /= last_addr_r then
473
        if addr_in /= last_addr_r
474
          or comm_in /= last_comm_r then
475
          -- Uusi osoite tai komento fifossa, ohjataan se IP:lle
476
          data_out       <= addr_in;
477
          comm_out       <= comm_in;
478
          av_out <= '1';
479
        else
480
          -- Sama osoite kuin viimeksi, siirretaan data suoraan IP:lle
481
          data_out       <= data_in;
482
          comm_out       <= comm_in;
483
          av_out <= '0';
484
        end if;  --addr_in
485
      end if;  --empty_in
486
 
487
 
488
 
489
 
490
 
491
    elsif Transferred_r = "01" then
492
      -- Osoite sirretty, luetaan data fifosta sitten kun IP haluaa
493
      if empty_in = '1' then
494
        data_out      <= (others => '0');
495
        comm_out      <= (others => '0');
496
      else
497
        data_out      <= data_in;
498
        comm_out      <= comm_in;
499
      end if;
500
      av_out  <= '0';
501
      re_out <= re_in;
502
      empty_out       <= empty_in;
503
 
504
 
505
 
506
 
507
    elsif Transferred_r = "10" then
508
      -- Osoite ja ainakin yksi data siirretty
509
 
510
      --muutos 26.03.03: if addr_in /= last_addr_r then
511
      if addr_in /= last_addr_r
512
        or comm_in /= last_comm_r then
513
        -- Uusi osoite tai komento 
514
 
515
        re_out  <= '0';
516
        empty_out        <= empty_in;   --'1';
517
        if empty_in = '1' then
518
          -- Ei ole mitaan siirrettavaakaan
519
          data_out       <= (others => '0'); --'X');
520
          comm_out       <= (others => '0'); --'X');
521
          av_out <= '0';
522
        else
523
          data_out       <= addr_in;
524
          comm_out       <= comm_in;
525
          av_out <= '1';        --'0';          
526
        end if;  --empty
527
 
528
      else
529
        -- Sama osoite kuin viimeksikin
530
        re_out  <= re_in;
531
        empty_out        <= empty_in;
532
        if empty_in = '1' then
533
          -- Ei ole mitaan siirrettavaakaan
534
          data_out       <= (others => '0');  -- 'Z');
535
          comm_out       <= (others => '0');  -- 'Z');
536
          av_out <= '0';
537
        else
538
          -- Sama osoite kuin viimeksi
539
          data_out       <= data_in;
540
          comm_out       <= comm_in;
541
          av_out <= '0';
542
        end if;  --empty
543
      end if;  --addr_in        
544
 
545
 
546
 
547
    else
548
      -- ??      
549
      re_out    <= '0';
550
      empty_out <= empty_in;
551
      data_out  <= (others => '0');     -- 'Z'); 
552
      comm_out  <= (others => '0');     -- 'Z');      
553
      av_out    <= '0';
554
    end if;  --Transferred_r
555
 
556
  end process Assign_outputs;
557
 
558
 
559
 
560
 
561
  -- PROC
562
  Store_addr : process (clk, rst_n)
563
  begin  -- process Store_addr
564
    if rst_n = '0' then                 -- asynchronous reset (active low)
565
      last_addr_r          <= (others => '0'); -- 'Z');
566
      last_comm_r          <= (others => '0'); -- 'Z');  --26.03.03
567
      Transferred_r <= "00";
568
 
569
    elsif clk'event and clk = '1' then  -- rising clock edge
570
 
571
      if Transferred_r = "00" then
572
        -- Ei ole viela sirretty mitaan
573
 
574
        if empty_in = '0' and re_in = '1' then
575
          -- Saatiin osoite IP:lle
576
          Transferred_r <= "01";
577
          last_addr_r   <= addr_in;
578
          last_comm_r   <= comm_in;      --26.03.03
579
        else
580
          -- Ei ole dataa tai IP ei lue
581
          Transferred_r <= "00";
582
          last_addr_r   <= last_addr_r;
583
          last_comm_r   <= last_comm_r;  --26.03.03
584
        end if;
585
 
586
 
587
      elsif Transferred_r = "01" then
588
        -- Osoite sirretty
589
        if re_in = '1' then
590
          -- Saatiin data IP:lle
591
          Transferred_r <= "10";
592
        else
593
          -- IP ei lue
594
          Transferred_r <= "01";
595
        end if;
596
        last_addr_r   <= last_addr_r;
597
        last_comm_r   <= last_comm_r;  --26.03.03
598
 
599
 
600
      elsif Transferred_r = "10" then
601
 
602
        -- Osoite ja ainakin yksi data siirretty
603
        if empty_in = '1' then
604
          -- ei ole uutta dataa
605
          Transferred_r <= "10";
606
          last_addr_r   <= last_addr_r;
607
        else
608
          -- if addr_in /= last_addr_r then
609
          if addr_in /= last_addr_r or comm_in /= last_comm_r then  --26.03.03
610
 
611
            -- Uusi osoite tai komento
612
            if re_in = '1' then
613
              -- Saatiin osoite IP:lle
614
              Transferred_r <= "10";
615
              last_addr_r   <= addr_in;
616
              last_comm_r   <= comm_in;      --26.03.03
617
            else
618
              -- IP ei lue viela
619
              Transferred_r <= "00";
620
              last_addr_r   <= last_addr_r;
621
              last_comm_r   <= last_comm_r;  --26.03.03
622
            end if;
623
            -- oli
624
            --Transferred_r <= "00";
625
            --last_addr_r   <= last_addr_r;  
626
          else
627
            -- Sama osoite kuin viimeksi
628
            Transferred_r   <= "01";
629
            last_addr_r     <= last_addr_r;
630
            last_comm_r     <= last_comm_r;  --26.03.03
631
          end if;  --addr_in
632
        end if;  --empty_in
633
 
634
      else
635
        -- ??
636
        last_addr_r   <= last_addr_r;
637
      end if;                             --Transferred_r
638
 
639
 
640
    end if;                             --rst_n
641
 
642
  end process Store_addr;
643
end rtl;

powered by: WebSVN 2.1.0

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