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/] [3.0/] [vhd/] [addr_data_demux_read.vhd] - Blame information for rev 145

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 145 lanttu
-------------------------------------------------------------------------------
2
-- File :       addr_data_demux_read.vdh
3
-- Description: Reads addr and data sequentially and outputs them in parallel.
4
--              Can be used, e.g., in interfacing HIBI with IP.
5
--
6
-- Project:
7
-- Author:     Erno Salminen
8
-- Date :      2003
9
-- Modified:
10
-- 06.08.2004   ES, one_data_in/out removed
11
--
12
-------------------------------------------------------------------------------
13
-- Funbase IP library Copyright (C) 2011 TUT Department of Computer Systems
14
--
15
-- This file is part of HIBI
16
--
17
-- This source file may be used and distributed without
18
-- restriction provided that this copyright statement is not
19
-- removed from the file and that any derivative work contains
20
-- the original copyright notice and the associated disclaimer.
21
--
22
-- This source file is free software; you can redistribute it
23
-- and/or modify it under the terms of the GNU Lesser General
24
-- Public License as published by the Free Software Foundation;
25
-- either version 2.1 of the License, or (at your option) any
26
-- later version.
27
--
28
-- This source is distributed in the hope that it will be
29
-- useful, but WITHOUT ANY WARRANTY; without even the implied
30
-- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
31
-- PURPOSE.  See the GNU Lesser General Public License for more
32
-- details.
33
--
34
-- You should have received a copy of the GNU Lesser General
35
-- Public License along with this source; if not, download it
36
-- from http://www.opencores.org/lgpl.shtml
37
-------------------------------------------------------------------------------
38
 
39
 
40
library ieee;
41
use ieee.std_logic_1164.all;
42
use ieee.std_logic_arith.all;
43
use ieee.std_logic_unsigned.all;
44
 
45
 
46
entity addr_data_demux_read is
47
 
48
  generic (
49
    data_width_g : integer := 0;
50
    addr_width_g : integer := 0;
51
    comm_width_g : integer := 0
52
    );
53
  port (
54
    clk   : in std_logic;
55
    rst_n : in std_logic;
56
 
57
    av_in    : in  std_logic;
58
    data_in  : in  std_logic_vector (data_width_g-1 downto 0);
59
    comm_in  : in  std_logic_vector (comm_width_g-1 downto 0);
60
    empty_in : in  std_logic;
61
    re_out   : out std_logic;
62
 
63
    re_in     : in  std_logic;
64
    addr_out  : out std_logic_vector (addr_width_g-1 downto 0);
65
    data_out  : out std_logic_vector (data_width_g-1 downto 0);
66
    comm_out  : out std_logic_vector (comm_width_g-1 downto 0);
67
    empty_out : out std_logic
68
    );
69
 
70
end addr_data_demux_read;
71
 
72
 
73
architecture rtl of addr_data_demux_read is
74
 
75
  signal addr_r   : std_logic_vector (addr_width_g-1 downto 0);
76
  signal re_r     : std_logic;
77
  signal rd_rdy_r : std_logic;
78
 
79
 
80
begin  -- rtl
81
 
82
  -- 1) COMB PROC
83
  Read_fifo : process (re_in, re_r, empty_in, av_in)
84
  begin  -- process Read_fifo
85
 
86
    -- 21.01.2003 kokeilukorjaus, saa nähdä toimiiko jos IP pitää koko ajan re=1
87
    if empty_in = '1' then
88
      -- Fifossa ei ole mitaan
89
      re_out <= '0';
90
    else
91
      if av_in = '1' then
92
        -- Demux reads addr
93
        re_out <= re_r;
94
      else
95
        -- IP reads data
96
        re_out <= re_in;
97
      end if;
98
    end if;
99
 
100
  end process Read_fifo;
101
 
102
 
103
  -- 2) COMB PROC
104
  Assign_empty_out : process (empty_in, av_in)
105
  begin  -- process Assign_empty_out
106
    -- addr must read to register before it is tramsferred to reader.
107
    -- Therefore, empty_out is asserted until addr is read from fifo. 
108
 
109
    if empty_in = '1' then
110
      -- Fifossa ei ole mitaan
111
      empty_out <= '1';
112
    else
113
      if av_in = '1' then
114
        empty_out <= '1';
115
      else
116
        empty_out <= '0';
117
      end if;
118
    end if;
119
  end process Assign_empty_out;
120
 
121
 
122
  -- 3) COMB PROC
123
  Demux_addr_data : process (data_in, av_in, comm_in,
124
                             addr_r, empty_in)
125
  begin  -- process Demux_addr_data
126
    -- Fifo outputs are directed outputs when addr has been read to register
127
    -- and there is data coming from fifo
128
 
129
 
130
    if empty_in = '0' and av_in = '0' then
131
      -- data coming from fifo
132
      data_out <= data_in;
133
      addr_out <= addr_r;
134
      comm_out <= comm_in;
135
    else
136
      -- addr coming fifo or fifo empty 
137
      data_out <= (others => '0');
138
      addr_out <= (others => '0');
139
      comm_out <= (others => '0');
140
    end if;
141
  end process Demux_addr_data;
142
 
143
 
144
  -- 4) SEQ PROC
145
  Store_addr : process (clk, rst_n)
146
  begin  -- process Store_addr
147
    -- Reads addr from fifo to register
148
    -- read_ready goes 1 after each fifo read operation, either initiated
149
    --  + by demux (=addr read). 
150
    --  + by reader ip (=data read).
151
    -- read_ready remains 1, if fifo became empty
152
    --  
153
    --  Read goes 0 if fifo is not empty and no read operation is performed,
154
    --  see above.
155
 
156
 
157
    if rst_n = '0' then                 -- asynchronous reset (active low)
158
      addr_r   <= (others => '0');
159
      re_r     <= '0';
160
      rd_rdy_r <= '1';
161
 
162
    elsif clk'event and clk = '1' then  -- rising clock edge
163
 
164
      if empty_in = '1' then
165
        -- Fifo is empty, keep state
166
        addr_r   <= addr_r;
167
        re_r     <= '0';
168
        rd_rdy_r <= rd_rdy_r;
169
 
170
      else
171
        -- Fifo not empty
172
 
173
        if av_in = '1' then
174
          -- Fifo has addr, read it
175
          addr_r <= data_in(addr_width_g-1 downto 0);
176
 
177
          -- Keep RE=1 for one cycle
178
          if re_r = '0' then
179
            re_r     <= '1';
180
            rd_rdy_r <= '0';
181
          else
182
            re_r     <= '0';
183
            rd_rdy_r <= '1';
184
          end if;  --re_r
185
 
186
          --assert false report "New addr in fifo" severity note;
187
 
188
        else
189
          -- Fifossa on lukematon data
190
          addr_r <= addr_r;
191
          re_r   <= '0';
192
 
193
          if re_in = '1' then
194
            -- Reader ip perfroms read operation
195
            rd_rdy_r <= '1';
196
            --assert false report "IP reads addr+data" severity note;
197
          else
198
            -- Wait, until read ip performs read operation
199
            rd_rdy_r <= '0';
200
            --assert false report "Wait for IP to read addr+data" severity note;            
201
          end if;  --re_in
202
 
203
        end if;  --av        
204
      end if;  --empty_in
205
    end if;  --rst_n    
206
  end process Store_addr;
207
 
208
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.