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_demuxes.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_demuxes.vhdl
27
-- Design:
28
-- Project:
29
-- e-mail : 
30
-- Description : Converts separated addr+data signalling into multiplexed addr/data.
31
--               Two components : one for writing and one for reading fifo.
32
--               Input : addr + data muxed into one port
33
--               Out   : separate addr + data ports
34
--               
35
-- Author      : Erno Salminen
36
-- Date        : 16.01.2003
37
-- Modified    : 
38
--               
39
-- 
40
-- 05.02.2003   Name changed from fifo_demux_X to addr_data_demux_X
41
-- 15.12.2004   ES names changed
42
-------------------------------------------------------------------------------
43
library ieee;
44
use ieee.std_logic_1164.all;
45
use ieee.std_logic_arith.all;
46
use ieee.std_logic_unsigned.all;
47
 
48
 
49
-- IP:lta tulee osoite ja data perakkain, siirretaan ne fifoon rinnakkain
50
entity addr_data_demux_write is
51
 
52
  generic (
53
    data_width_g         :     integer := 0;
54
    addr_width_g         :     integer := 0
55
    );
56
  port (
57
    clk                : in  std_logic;
58
    rst_n              : in  std_logic;
59
 
60
    av_in     : in  std_logic;
61
    data_in   : in  std_logic_vector ( data_width_g-1 downto 0);
62
    we_in     : in  std_logic;
63
    full_out  : out std_logic;
64
    one_p_out : out std_logic;
65
 
66
    we_out   : out std_logic;
67
    data_out : out std_logic_vector ( data_width_g-1 downto 0);
68
    addr_out : out std_logic_vector ( addr_width_g-1 downto 0);
69
    full_in  : in  std_logic;
70
    one_p_in : in  std_logic
71
    );
72
 
73
end addr_data_demux_write;
74
 
75
 
76
 
77
 
78
 
79
 
80
 
81
architecture rtl of addr_data_demux_write is
82
 
83
  signal addr_r        : std_logic_vector ( addr_width_g-1 downto 0);
84
 
85
 
86
begin  -- rtl
87
 
88
  Store_addr : process (clk, rst_n)
89
  begin  -- process Store_addr
90
    if rst_n = '0' then                 -- asynchronous reset (active low)
91
 
92
      data_out <= (others => '0');
93
      addr_out <= (others => '0');
94
      we_out   <= '0';
95
      addr_r   <= (others => '0');
96
 
97
 
98
    elsif clk'event and clk = '1' then  -- rising clock edge
99
 
100
      if we_in = '1' then
101
        if av_in = '1' then
102
          -- New addr
103
          if full_in = '0' then
104
            addr_r <= data_in;
105
          else
106
            addr_r <= addr_r;
107
          end if;
108
 
109
 
110
        else
111
          -- New data
112
          if full_in = '0' then
113
            -- Prev write ready, write new data
114
            data_out <= data_in;
115
            addr_out <= addr_r;
116
            we_out   <= '1';
117
          else
118
            -- Prev write is not ready yet
119
            -- Keep all values
120
 
121
          end if;                       --write_ready          
122
        end if;                         --av
123
 
124
      else
125
        -- No new write
126
 
127
 
128
      end if;                           --we
129
 
130
 
131
    end if;                             --rst
132
 
133
 
134
  end process Store_addr;
135
 
136
 
137
 
138
 
139
end rtl;                                --addr_data_demux_write
140
 
141
 
142
 
143
 
144
 
145
 
146
-------------------------------------------------------------------------------
147
--entity addr_data_demux_read luetaan fifosta osoite ja perakkain ja siirretaan
148
-- ne IP:lle rinnakkain
149
-- File :
150
-- Description: 
151
-- Design:
152
-- Project:
153
-- e-mail :
154
-- Author:     Erno Salminen
155
-- Date :       2003
156
-- Modified:
157
-- 06.08.2004   ES, one_data_in/out removed
158
--
159
-------------------------------------------------------------------------------
160
 
161
 
162
library ieee;
163
use ieee.std_logic_1164.all;
164
use ieee.std_logic_arith.all;
165
use ieee.std_logic_unsigned.all;
166
 
167
 
168
 
169
 
170
 
171
entity addr_data_demux_read is
172
 
173
  generic (
174
    data_width_g :    integer := 0;
175
    addr_width_g :    integer := 0;
176
    comm_width_g :    integer := 0
177
    );
178
  port (
179
    clk          : in std_logic;
180
    rst_n        : in std_logic;
181
 
182
    av_in    : in  std_logic;
183
    data_in  : in  std_logic_vector ( data_width_g-1 downto 0);
184
    comm_in  : in  std_logic_vector ( comm_width_g-1 downto 0);
185
    empty_in : in  std_logic;
186
    re_out   : out std_logic;
187
 
188
    re_in     : in  std_logic;
189
    addr_out  : out std_logic_vector ( addr_width_g-1 downto 0);
190
    data_out  : out std_logic_vector ( data_width_g-1 downto 0);
191
    comm_out  : out std_logic_vector ( comm_width_g-1 downto 0);
192
    empty_out : out std_logic
193
    );
194
 
195
end addr_data_demux_read;
196
 
197
 
198
architecture rtl of addr_data_demux_read is
199
 
200
  signal addr_r   : std_logic_vector (addr_width_g-1 downto 0);
201
  signal re_r     : std_logic;
202
  signal rd_rdy_r : std_logic;
203
 
204
 
205
begin  -- rtl
206
 
207
  -- 1) COMB PROC
208
  Read_fifo : process (re_in, re_r, empty_in, av_in)
209
  begin  -- process Read_fifo
210
 
211
    -- 21.01.2003 kokeilukorjaus, saa nähdä toimiiko jos IP pitää koko ajan re=1
212
    if empty_in = '1' then
213
      -- Fifossa ei ole mitaan
214
      re_out <= '0';
215
    else
216
      if av_in = '1' then
217
        -- Demux reads addr
218
        re_out <= re_r;
219
      else
220
        -- IP reads data
221
        re_out <= re_in;
222
      end if;
223
    end if;
224
 
225
  end process Read_fifo;
226
 
227
 
228
  -- 2) COMB PROC
229
  Assign_empty_out : process (empty_in, av_in)
230
  begin  -- process Assign_empty_out
231
    -- addr must read to register before it is tramsferred to reader.
232
    -- Therefore, empty_out is asserted until addr is read from fifo. 
233
 
234
    if empty_in = '1' then
235
      -- Fifossa ei ole mitaan
236
      empty_out <= '1';
237
    else
238
      if av_in = '1' then
239
        empty_out <=  '1';
240
      else
241
        empty_out <= '0';
242
      end if;
243
    end if;
244
  end process Assign_empty_out;
245
 
246
 
247
  -- 3) COMB PROC
248
  Demux_addr_data : process (data_in, av_in, comm_in,
249
                             addr_r, empty_in)
250
  begin  -- process Demux_addr_data
251
    -- Fifo outputs are directed outputs when addr has been read to register
252
    -- and there is data coming from fifo
253
 
254
 
255
    if empty_in = '0' and av_in = '0' then
256
      -- data coming from fifo
257
      data_out <= data_in;
258
      addr_out <= addr_r;
259
      comm_out <= comm_in;
260
    else
261
      -- addr coming fifo or fifo empty 
262
      data_out <= (others => '0');
263
      addr_out <= (others => '0');
264
      comm_out <= (others => '0');
265
    end if;
266
  end process Demux_addr_data;
267
 
268
 
269
  -- 4) SEQ PROC
270
  Store_addr : process (clk, rst_n)
271
  begin  -- process Store_addr
272
    -- Reads addr from fifo to register
273
    -- read_ready goes 1 after each fifo read operation, either initiated
274
    --  + by demux (=addr read). 
275
    --  + by reader ip (=data read).
276
    -- read_ready remains 1, if fifo became empty
277
    --  
278
    --  Read goes 0 if fifo is not empty and no read operation is performed,
279
    --  see above.
280
 
281
 
282
    if rst_n = '0' then                 -- asynchronous reset (active low)
283
      addr_r   <= (others => '0');
284
      re_r     <= '0';
285
      rd_rdy_r <= '1';
286
 
287
    elsif clk'event and clk = '1' then  -- rising clock edge
288
 
289
      if empty_in = '1' then
290
        -- Fifo is empty, keep state
291
        addr_r   <= addr_r;
292
        re_r     <= '0';
293
        rd_rdy_r <= rd_rdy_r;
294
 
295
      else
296
        -- Fifo not empty
297
 
298
        if av_in = '1' then
299
          -- Fifo has addr, read it
300
          addr_r <= data_in;
301
 
302
          -- Keep RE=1 for one cycle
303
          if re_r = '0' then
304
            re_r     <= '1';
305
            rd_rdy_r <= '0';
306
          else
307
            re_r     <= '0';
308
            rd_rdy_r <= '1';
309
          end if;  --re_r
310
 
311
          --assert false report "New addr in fifo" severity note;
312
 
313
        else
314
          -- Fifossa on lukematon data
315
          addr_r        <= addr_r;
316
          re_r <= '0';
317
 
318
          if re_in = '1' then
319
            -- Reader ip perfroms read operation
320
            rd_rdy_r <= '1';
321
            --assert false report "IP reads addr+data" severity note;
322
          else
323
            -- Wait, until read ip performs read operation
324
            rd_rdy_r <= '0';
325
            --assert false report "Wait for IP to read addr+data" severity note;            
326
          end if;  --re_in
327
 
328
        end if;                         --av        
329
      end if;                           --empty_in
330
    end if;                             --rst_n    
331
  end process Store_addr;
332
 
333
 
334
 
335
 
336
 
337
 
338
 
339
end rtl;                                --addr_data_demux_read

powered by: WebSVN 2.1.0

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