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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 145 lanttu
-------------------------------------------------------------------------------
2
-- Title      : Multiclock FIFO
3
-- Project    : 
4
-------------------------------------------------------------------------------
5
-- File       : multiclk_fifo.vhd
6
-- Author     : kulmala3
7
-- Created    : 16.12.2005
8
-- Last update: 16.08.2006
9
-- Description: Synchronous multi-clock FIFO. Note that clock frequencies MUST
10
-- be related (synchronized) in order to avoid metastability.
11
-- Clocks that are asynchronous wrt. each other do not work.
12
--
13
-- Note! data must be ready in the data in wrt. faster clock when writing!
14
-- same applies for re and we
15
--
16
-- This one uses slow full and empty for the corresponding slower clock (i.e.
17
-- reader is slower -> empty is delayed). eg. empty transition from 1->0 is
18
-- delayed.
19
--
20
-- In this implementation we really utilize both clocks, whch can be a problem
21
-- in some systems (routing the another clock).
22
-------------------------------------------------------------------------------
23
-- Copyright (c) 2005 
24
-------------------------------------------------------------------------------
25
-- Revisions  :
26
-- Date        Version  Author  Description
27
-- 16.12.2005  1.0      AK      Created
28
-------------------------------------------------------------------------------
29
 
30
library ieee;
31
use ieee.std_logic_1164.all;
32
use ieee.std_logic_arith.all;
33
use ieee.std_logic_unsigned.all;
34
 
35
entity threeclk_fifo is
36
 
37
  generic (
38
    re_freq_g    :    integer := 1;     -- integer multiple of clk_we
39
    we_freq_g    :    integer := 1;     -- or vice versa
40
    tmp_freq_g   :    integer := 1;     -- integer multiple of both clk_re and clk_we
41
    depth_g      :    integer := 1;
42
    data_width_g :    integer := 1
43
    );
44
  port (
45
    clk_re       : in std_logic;
46
    clk_we       : in std_logic;
47
    clk_tmp      : in std_logic;
48
    rst_n        : in std_logic;
49
 
50
    data_in   : in  std_logic_vector (data_width_g-1 downto 0);
51
    we_in     : in  std_logic;
52
    full_out  : out std_logic;
53
    one_p_out : out std_logic;
54
 
55
    re_in     : in  std_logic;
56
    data_out  : out std_logic_vector (data_width_g-1 downto 0);
57
    empty_out : out std_logic;
58
    one_d_out : out std_logic
59
    );
60
end threeclk_fifo;
61
 
62
architecture structural of threeclk_fifo is
63
 
64
--   component multiclk_fifo
65
--     generic (
66
--       re_freq_g    :    integer := 0;     -- integer multiple of clk_we
67
--       we_freq_g    :    integer := 0;     -- or vice versa
68
--       depth_g      :    integer := 0;
69
--       data_width_g :    integer := 0
70
--       );
71
--     port (
72
--       clk_re       : in std_logic;
73
--       clk_we       : in std_logic;
74
--       rst_n        : in std_logic;
75
 
76
--       data_in   : in  std_logic_vector (data_width_g-1 downto 0);
77
--       we_in     : in  std_logic;
78
--       full_out  : out std_logic;
79
--       one_p_out : out std_logic;
80
 
81
--       re_in     : in  std_logic;
82
--       data_out  : out std_logic_vector (data_width_g-1 downto 0);
83
--       empty_out : out std_logic;
84
--       one_d_out : out std_logic
85
--       );                         
86
--   end component;
87
 
88
   signal data_wef_ref   : std_logic_vector (data_width_g-1 downto 0);
89
   signal we_to_ref      : std_logic;
90
   signal full_from_ref  : std_logic;
91
   signal one_p_from_ref : std_logic;
92
   signal re_to_wef      : std_logic;
93
   signal empty_from_wef : std_logic;
94
 
95
 
96
begin  -- structural
97
 
98
 
99
 
100
   we_fifo : entity work.multiclk_fifo
101
     generic map (
102
       re_freq_g    => tmp_freq_g,
103
       we_freq_g    => we_freq_g,
104
       data_width_g => data_width_g,
105
       depth_g      => depth_g
106
       )
107
     port map(
108
       clk_we       => clk_we,
109
       clk_re       => clk_tmp,
110
       rst_n        => rst_n,
111
 
112
       data_in  => data_in,
113
       we_in    => we_in,
114
       full_out => full_out,
115
       one_p_out => one_p_out,
116
 
117
       data_out  => data_wef_ref,
118
       re_in     => re_to_wef,
119
       empty_out => empty_from_wef
120
       --one_d_out 
121
       );
122
 
123
 
124
   re_to_wef <= not full_from_ref;
125
   we_to_ref <= not empty_from_wef;
126
 
127
 
128
  re_fifo : entity work.multiclk_fifo
129
    generic map (
130
      re_freq_g    => re_freq_g,
131
      we_freq_g    => tmp_freq_g,
132
      data_width_g => data_width_g,
133
      depth_g      => depth_g/2
134
      )
135
    port map(
136
      clk_we       => clk_tmp,
137
      clk_re       => clk_re,
138
      rst_n        => rst_n,
139
 
140
      data_in  => data_wef_ref,
141
      we_in    => we_to_ref,
142
      full_out => full_from_ref,
143
      one_p_out => one_p_from_ref,
144
 
145
      data_out  => data_out,
146
      re_in     => re_in,
147
      empty_out => empty_out,
148
      one_d_out => one_d_out
149
      );
150
 
151
 
152
 
153
 
154
 
155
end structural;

powered by: WebSVN 2.1.0

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