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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 145 lanttu
-------------------------------------------------------------------------------
2
-- Title      : Read pulse synchronizer for Mixed clock FIFO
3
-- WE faster than re
4
-- Project    :
5
-------------------------------------------------------------------------------
6
-- File       : 
7
-- Author     : kulmala3
8
-- Created    : 16.12.2005
9
-- Last update: 15.12.2006
10
-- Description: An extra FIFO slot that synchronizes the data between different
11
-- clock domains
12
-------------------------------------------------------------------------------
13
-- Copyright (c) 2005
14
--
15
-------------------------------------------------------------------------------
16
-- Revisions  :
17
-- Date        Version  Author  Description
18
-- 16.12.2005  1.0      AK      Created
19
-------------------------------------------------------------------------------
20
 
21
library ieee;
22
use ieee.std_logic_1164.all;
23
use ieee.std_logic_arith.all;
24
use ieee.std_logic_unsigned.all;
25
 
26
entity re_pulse_synchronizer is
27
 
28
  generic (
29
    data_width_g : integer := 0
30
    );
31
  port (
32
    clk_re    : in std_logic;           -- THIS IS ALWAYS THE SLOWER CLOCK!!!
33
    clk_ps_re : in std_logic;           -- phase shifted pulse
34
    clk_we    : in std_logic;
35
    clk_ps_we : in std_logic;           -- phase shifted pulse
36
    rst_n     : in std_logic;
37
 
38
    -- from/to we domain
39
    data_in  : in  std_logic_vector (data_width_g-1 downto 0);
40
    empty_in : in  std_logic;
41
    re_out   : out std_logic;
42
 
43
    -- from/to re domain
44
    data_out  : out std_logic_vector (data_width_g-1 downto 0);
45
    re_in     : in  std_logic;
46
    empty_out : out std_logic
47
 
48
    -- From clk_re domain FIFO
49
--    full_in : in std_logic;
50
--    one_p_in : in std_logic
51
 
52
 
53
 
54
    );
55
end re_pulse_synchronizer;
56
 
57
architecture rtl of re_pulse_synchronizer is
58
 
59
  signal clk_re_was_r    : std_logic;
60
  signal clk_re_period_r : std_logic;
61
 
62
  signal derived_clk : std_logic;
63
 
64
  signal re_to_fifo : std_logic;
65
--  signal re_between_r : std_logic;
66
 
67
--  signal data_between_r  : std_logic_vector(data_width_g-1 downto 0);
68
  signal data_out_r : std_logic_vector(data_width_g-1 downto 0);
69
  signal valid_r    : std_logic;
70
--  signal valid_between_r : std_logic;
71
  signal clk_was_r  : std_logic;
72
  signal re_valid_r : std_logic;
73
  signal re_was_r   : std_logic;
74
begin  -- rtl
75
 
76
 
77
  derived_clk <= (clk_ps_re nand clk_ps_we) and clk_re;
78
 
79
  -- read the fifo signals and read to the slot
80
  derclk : process (derived_clk, rst_n)
81
  begin  -- process derclk
82
    if rst_n = '0' then                 -- asynchronous reset (active low)
83
      data_out_r      <= (others => '0');
84
      re_to_fifo      <= '0';
85
      valid_r         <= '0';
86
      clk_re_period_r <= '0';
87
 
88
    elsif derived_clk'event and derived_clk = '1' then  -- rising clock edge
89
      if re_valid_r = '1'  or (re_was_r = '1') then
90
        -- by default, read invalidates data. next if will set again
91
        -- if new one is read instead.
92
        valid_r <= '0';
93
      end if;
94
      if empty_in = '0' and (valid_r = '0' or
95
                             (valid_r = '1' and
96
                              (re_valid_r = '1' or
97
                               (re_was_r = '1' and re_in = '1')))) then
98
        -- read data to output from fifo
99
        re_to_fifo <= '1';
100
        data_out_r <= data_in;
101
        valid_r    <= '1';
102
      else
103
        re_to_fifo <= '0';
104
        data_out_r <= data_out_r;
105
      end if;
106
 
107
      clk_re_period_r <= not clk_re_period_r;
108
 
109
    end if;
110
  end process derclk;
111
 
112
  empty_out <= not valid_r;
113
  data_out  <= data_out_r;
114
  re_out    <= re_to_fifo and (clk_re_was_r xor clk_re_period_r);
115
 
116
  re_valid_r <= (clk_was_r xnor clk_re_period_r) and re_in;
117
 
118
  process (clk_re, rst_n)
119
  begin  -- process
120
    if rst_n = '0' then                 -- asynchronous reset (active low)
121
      clk_was_r <= '0';
122
      re_was_r        <= '0';
123
 
124
    elsif clk_re'event and clk_re = '1' then  -- rising clock edge
125
      clk_was_r <= not clk_was_r;
126
      re_was_r <= re_in;
127
 
128
    end if;
129
  end process;
130
 
131
--  refaster : process (clk_re, rst_n)
132
--  begin  -- process refaster
133
--    if rst_n = '0' then                 -- asynchronous reset (active low)
134
--      re_between_r <= '0';
135
--      valid_r      <= '0';
136
--      data_out_r   <= (others => '0');
137
 
138
--    elsif clk_re'event and clk_re = '1' then  -- rising clock edge
139
--      if re_in = '1' then
140
--        -- by default, read invalidates data. next if will set again
141
--        -- if new one is read instead.
142
--        valid_r <= '0';
143
--      end if;
144
--      if valid_between_r = '0' and (valid_r = '0' or
145
--                            (valid_r = '1' and re_in = '1')) then
146
--        -- read data to output from fifo
147
--        re_between_r <= '1';
148
--        data_out_r   <= data_in;
149
--        valid_r      <= '1';
150
--      else
151
--        re_between_r <= '0';
152
--        data_out_r   <= data_between_r;
153
--      end if;
154
--    end if;
155
--  end process refaster;
156
 
157
 
158
-- we faster, make the pulse length equal
159
  process (clk_we, rst_n)
160
  begin  -- process
161
    if rst_n = '0' then                 -- asynchronous reset (active low)
162
      clk_re_was_r <= '0';
163
 
164
    elsif clk_we'event and clk_we = '1' then  -- rising clock edge
165
      clk_re_was_r <= clk_re_period_r;
166
    end if;
167
  end process;
168
 
169
 
170
end rtl;

powered by: WebSVN 2.1.0

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