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_v2.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: 14.12.2006
9
-- Description:
10
-------------------------------------------------------------------------------
11
-- Copyright (c) 2005
12
-- Works in fpga testbench. 
13
-------------------------------------------------------------------------------
14
-- Revisions  :
15
-- Date        Version  Author  Description
16
-- 16.12.2005  1.0      AK      Created
17
-------------------------------------------------------------------------------
18
 
19
library ieee;
20
use ieee.std_logic_1164.all;
21
use ieee.std_logic_arith.all;
22
use ieee.std_logic_unsigned.all;
23
 
24
entity mixed_clk_fifo is
25
 
26
  generic (
27
    depth_g      : integer := 0;
28
    data_width_g : integer := 0
29
    );
30
  port (
31
    clk_re    : in std_logic;
32
    clk_ps_re : in std_logic;           -- phase shifted pulse
33
    clk_we    : in std_logic;
34
    clk_ps_we : in std_logic;           -- phase shifted pulse
35
    rst_n     : in std_logic;
36
 
37
    data_in   : in  std_logic_vector (data_width_g-1 downto 0);
38
    we_in     : in  std_logic;
39
    full_out  : out std_logic;
40
    one_p_out : out std_logic;
41
 
42
    re_in     : in  std_logic;
43
    data_out  : out std_logic_vector (data_width_g-1 downto 0);
44
    empty_out : out std_logic;
45
    one_d_out : out std_logic
46
    );
47
end mixed_clk_fifo;
48
 
49
architecture rtl of mixed_clk_fifo is
50
 
51
  component fifo
52
    generic (
53
      data_width_g : integer;
54
      depth_g      : integer);
55
    port (
56
      clk       : in  std_logic;
57
      rst_n     : in  std_logic;
58
      data_in   : in  std_logic_vector (data_width_g-1 downto 0);
59
      we_in     : in  std_logic;
60
      full_out  : out std_logic;
61
      one_p_out : out std_logic;
62
      re_in     : in  std_logic;
63
      data_out  : out std_logic_vector (data_width_g-1 downto 0);
64
      empty_out : out std_logic;
65
      one_d_out : out std_logic);
66
  end component;
67
 
68
  signal data_to_fifo : std_logic_vector (data_width_g-1 downto 0);
69
  signal we_to_fifo   : std_logic;
70
  signal we_local_r   : std_logic;
71
  signal clk_we_was_r : std_logic;
72
 
73
  signal data_between_r  : std_logic_vector (data_width_g-1 downto 0);
74
  signal we_between_r    : std_logic;
75
  signal full_between_r  : std_logic;
76
  signal one_p_between_r : std_logic;
77
  signal full_from_fifo  : std_logic;
78
  signal one_p_from_fifo : std_logic;
79
  signal re_to_fifo      : std_logic;
80
  signal data_from_fifo  : std_logic_vector (data_width_g-1 downto 0);
81
  signal empty_from_fifo : std_logic;
82
  signal one_d_from_fifo : std_logic;
83
  signal empty_out_r     : std_logic;
84
  signal full_out_r      : std_logic;
85
  signal clk_we_period_r : std_logic;
86
 
87
  signal derived_clk : std_logic;
88
 
89
begin  -- rtl
90
 
91
  full_out  <= full_out_r;              --from_fifo;
92
  data_out  <= data_from_fifo;
93
  empty_out <= empty_from_fifo;
94
 
95
  regular_fifo : fifo
96
    generic map (
97
      data_width_g => data_width_g,
98
      depth_g      => depth_g)
99
    port map (
100
      clk       => clk_re,
101
      rst_n     => rst_n,
102
      data_in   => data_to_fifo,
103
      we_in     => we_to_fifo,
104
      full_out  => full_from_fifo,
105
      one_p_out => one_p_from_fifo,
106
      re_in     => re_in,
107
      data_out  => data_from_fifo,
108
      empty_out => empty_from_fifo,
109
      one_d_out => one_d_from_fifo
110
      );
111
 
112
  -----------------------------------------------------------------------------
113
  -- RE CLK IS FASTER
114
 
115
  process (clk_we, rst_n)
116
  begin  -- process wefaster
117
    if rst_n = '0' then                 -- asynchronous reset (active low)
118
      full_out_r     <= '1';
119
      data_between_r <= (others => '0');
120
      we_between_r   <= '0';
121
 
122
    elsif clk_we'event and clk_we = '1' then  -- rising clock edge
123
      if full_between_r = '0' then
124
        data_between_r <= data_in;
125
        we_between_r   <= we_in;
126
      end if;
127
      full_out_r <= full_between_r or one_p_between_r;
128
    end if;
129
  end process;
130
 
131
 
132
  derived_clk <= (clk_ps_we nand clk_ps_re) and clk_we;
133
 
134
  derclk : process (derived_clk, rst_n)
135
  begin  -- process derclk
136
    if rst_n = '0' then                 -- asynchronous reset (active low)
137
      data_to_fifo    <= (others => '0');
138
      we_local_r      <= '0';
139
      full_between_r  <= '0';
140
      one_p_between_r <= '0';
141
      clk_we_period_r <= '0';
142
 
143
    elsif derived_clk'event and derived_clk = '1' then  -- rising clock edge
144
      if full_from_fifo = '0' then
145
        data_to_fifo <= data_between_r;
146
        we_local_r   <= we_between_r;
147
      else
148
        we_local_r <= '0';
149
      end if;
150
      full_between_r  <= full_from_fifo;
151
      one_p_between_r <= one_p_from_fifo;
152
      clk_we_period_r <= not clk_we_period_r;
153
    end if;
154
  end process derclk;
155
 
156
  we_to_fifo <= (clk_we_period_r xor clk_we_was_r) and we_local_r;
157
 
158
  process (clk_re, rst_n)
159
  begin  -- process
160
    if rst_n = '0' then                 -- asynchronous reset (active low)
161
      clk_we_was_r <= '0';
162
 
163
    elsif clk_re'event and clk_re = '1' then  -- rising clock edge
164
      clk_we_was_r <= clk_we_period_r;
165
    end if;
166
  end process;
167
 
168
 
169
end rtl;

powered by: WebSVN 2.1.0

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