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/] [multiclk_fifo/] [1.0/] [vhd/] [mixed_clk_fifo_v3.vhd] - Blame information for rev 145

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 145 lanttu
-------------------------------------------------------------------------------
2
-- Title      : Mixed clock FIFO
3
-- Project    :
4
-------------------------------------------------------------------------------
5
-- File       : 
6
-- Author     : kulmala3
7
-- Created    : 16.12.2005
8
-- Last update: 18.12.2006
9
-- Description: This aims to include possibility to have the
10
-- synchronization interface on both sides instead of fixed re faster scheme.
11
--
12
-- NOTE! one_p may be high when full is also high
13
-- one_d is high when empty is '0'.
14
-------------------------------------------------------------------------------
15
-- Copyright (c) 2005
16
-- Works in fpga testbench. 
17
-------------------------------------------------------------------------------
18
-- Revisions  :
19
-- Date        Version  Author  Description
20
-- 16.12.2005  1.0      AK      Created
21
-------------------------------------------------------------------------------
22
 
23
library ieee;
24
use ieee.std_logic_1164.all;
25
use ieee.std_logic_arith.all;
26
use ieee.std_logic_unsigned.all;
27
 
28
entity mixed_clk_fifo is
29
 
30
  generic (
31
    re_faster_g : integer := 1; -- 0 we faster, 1 re faster.
32
    depth_g      : integer := 0;
33
    data_width_g : integer := 0
34
    );
35
  port (
36
    clk_re    : in std_logic;
37
    clk_ps_re : in std_logic;           -- phase shifted pulse
38
    clk_we    : in std_logic;
39
    clk_ps_we : in std_logic;           -- phase shifted pulse
40
    rst_n     : in std_logic;
41
 
42
    data_in   : in  std_logic_vector (data_width_g-1 downto 0);
43
    we_in     : in  std_logic;
44
    full_out  : out std_logic;
45
    one_p_out : out std_logic;
46
 
47
    re_in     : in  std_logic;
48
    data_out  : out std_logic_vector (data_width_g-1 downto 0);
49
    empty_out : out std_logic;
50
    one_d_out : out std_logic
51
    );
52
end mixed_clk_fifo;
53
 
54
architecture rtl of mixed_clk_fifo is
55
 
56
  component fifo
57
    generic (
58
      data_width_g : integer;
59
      depth_g      : integer);
60
    port (
61
      clk       : in  std_logic;
62
      rst_n     : in  std_logic;
63
      data_in   : in  std_logic_vector (data_width_g-1 downto 0);
64
      we_in     : in  std_logic;
65
      full_out  : out std_logic;
66
      one_p_out : out std_logic;
67
      re_in     : in  std_logic;
68
      data_out  : out std_logic_vector (data_width_g-1 downto 0);
69
      empty_out : out std_logic;
70
      one_d_out : out std_logic);
71
  end component;
72
 
73
  component we_pulse_synchronizer
74
    generic (
75
      data_width_g : integer);
76
    port (
77
      clk_re    : in  std_logic;
78
      clk_ps_re : in  std_logic;
79
      clk_we    : in  std_logic;
80
      clk_ps_we : in  std_logic;
81
      rst_n     : in  std_logic;
82
      data_in   : in  std_logic_vector (data_width_g-1 downto 0);
83
      we_in     : in  std_logic;
84
      full_out  : out std_logic;
85
      one_p_out : out std_logic;
86
      data_out  : out std_logic_vector (data_width_g-1 downto 0);
87
      we_out    : out std_logic;
88
      full_in   : in  std_logic;
89
      one_p_in  : in  std_logic);
90
  end component;
91
 
92
  component re_pulse_synchronizer
93
    generic (
94
      data_width_g : integer);
95
    port (
96
      clk_re    : in  std_logic;
97
      clk_ps_re : in  std_logic;
98
      clk_we    : in  std_logic;
99
      clk_ps_we : in  std_logic;
100
      rst_n     : in  std_logic;
101
      data_in   : in  std_logic_vector (data_width_g-1 downto 0);
102
      empty_in  : in  std_logic;
103
      re_out    : out std_logic;
104
      data_out  : out std_logic_vector (data_width_g-1 downto 0);
105
      re_in     : in  std_logic;
106
      empty_out : out std_logic);
107
  end component;
108
 
109
  signal data_to_fifo : std_logic_vector (data_width_g-1 downto 0);
110
  signal we_to_fifo   : std_logic;
111
 
112
  signal full_from_fifo  : std_logic;
113
  signal one_p_from_fifo : std_logic;
114
  signal re_to_fifo      : std_logic;
115
  signal data_from_fifo  : std_logic_vector (data_width_g-1 downto 0);
116
  signal empty_from_fifo : std_logic;
117
  signal one_d_from_fifo : std_logic;
118
 
119
  signal full_out_from_synch : std_logic;
120
  signal empty_out_from_synch : std_logic;
121
  signal one_p_from_synch : std_logic;
122
 
123
  signal clk_fifo : std_logic;
124
begin  -- rtl
125
 
126
 
127
  regular_fifo : fifo
128
    generic map (
129
      data_width_g => data_width_g,
130
      depth_g      => depth_g)
131
    port map (
132
      clk       => clk_fifo,
133
      rst_n     => rst_n,
134
      data_in   => data_to_fifo,
135
      we_in     => we_to_fifo,
136
      full_out  => full_from_fifo,
137
      one_p_out => one_p_from_fifo,
138
      re_in     => re_to_fifo,
139
      data_out  => data_from_fifo,
140
      empty_out => empty_from_fifo,
141
      one_d_out => one_d_from_fifo
142
      );
143
 
144
refaster: if re_faster_g > 0 generate
145
 
146
  we_pulse_synchronizer_1: we_pulse_synchronizer
147
    generic map (
148
      data_width_g => data_width_g)
149
    port map (
150
      clk_re    => clk_re,
151
      clk_ps_re => clk_ps_re,
152
      clk_we    => clk_we,
153
      clk_ps_we => clk_ps_we,
154
      rst_n     => rst_n,
155
      -- to/from we domain
156
      data_in   => data_in,
157
      we_in     => we_in,
158
      full_out  => full_out_from_synch,
159
      one_p_out => one_p_from_synch,
160
      -- to/from re domain
161
      data_out  => data_to_fifo,
162
      we_out    => we_to_fifo,
163
      full_in   => full_from_fifo,
164
      one_p_in  => one_p_from_fifo);
165
 
166
  re_to_fifo <= re_in;
167
  data_out <= data_from_fifo;
168
  empty_out <= empty_from_fifo;
169
  -- NOTE! this is for stupid HIBI which does not start when one_p is '1' and
170
  -- addres is coming
171
  one_p_out <= one_p_from_synch;--'0'; --not full_out_from_synch;
172
  full_out <= full_out_from_synch;
173
  one_d_out <= one_d_from_fifo;
174
 
175
  clk_fifo <= clk_re;
176
end generate refaster;
177
 
178
wefaster: if re_faster_g = 0 generate
179
  re_pulse_synchronizer_1: re_pulse_synchronizer
180
    generic map (
181
      data_width_g => data_width_g)
182
    port map (
183
      clk_re    => clk_re,
184
      clk_ps_re => clk_ps_re,
185
      clk_we    => clk_we,
186
      clk_ps_we => clk_ps_we,
187
 
188
      rst_n     => rst_n,
189
      data_in   => data_from_fifo,
190
      empty_in  => empty_from_fifo,
191
      re_out    => re_to_fifo,
192
      data_out  => data_out,
193
      re_in     => re_in,
194
      empty_out => empty_out_from_synch
195
      );
196
 
197
  we_to_fifo <= we_in;
198
  full_out <= full_from_fifo;
199
  one_p_out <= one_p_from_fifo;
200
  data_to_fifo <= data_in;
201
 
202
  empty_out <= empty_out_from_synch;
203
  one_d_out <= not empty_out_from_synch;
204
  clk_fifo <= clk_we;
205
end generate wefaster;
206
 
207
end rtl;

powered by: WebSVN 2.1.0

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