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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 145 lanttu
-------------------------------------------------------------------------------
2
-- Title      : Write pulse synchronizer for Mixed clock FIFO
3
-- Project    :
4
-------------------------------------------------------------------------------
5
-- File       : 
6
-- Author     : kulmala3
7
-- Created    : 16.12.2005
8
-- Last update: 18.12.2006
9
-- Description: Re faster than WE
10
-------------------------------------------------------------------------------
11
-- Copyright (c) 2005
12
-- one p may be a bit suspicious if blindly trusted. should not be used.
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 we_pulse_synchronizer is
25
 
26
  generic (
27
    data_width_g : integer := 0
28
    );
29
  port (
30
    clk_re    : in std_logic;   -- THIS IS ALWAYS THE FASTER CLOCK!!!
31
    clk_ps_re : in std_logic;           -- phase shifted pulse
32
    clk_we    : in std_logic;
33
    clk_ps_we : in std_logic;           -- phase shifted pulse
34
    rst_n     : in std_logic;
35
 
36
    -- to synchronize clk_we -> clk_re
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
    -- from synchronization to clk_re, we pulse width adjusted
43
    data_out  : out std_logic_vector (data_width_g-1 downto 0);
44
    we_out     : out  std_logic;
45
 
46
    -- From clk_re domain FIFO
47
    full_in : in std_logic;
48
    one_p_in : in std_logic
49
 
50
 
51
 
52
    );
53
end we_pulse_synchronizer;
54
 
55
architecture rtl of we_pulse_synchronizer is
56
 
57
 
58
  signal data_to_fifo : std_logic_vector (data_width_g-1 downto 0);
59
  signal we_to_fifo   : std_logic;
60
  signal we_local_r   : std_logic;
61
  signal clk_we_was_r : std_logic;
62
 
63
  signal data_between_r  : std_logic_vector (data_width_g-1 downto 0);
64
  signal we_between_r    : std_logic;
65
  signal full_between_r  : std_logic;
66
  signal one_p_between_r : std_logic;
67
  signal full_from_fifo  : std_logic;
68
  signal one_p_from_fifo : std_logic;
69
  signal full_out_r      : std_logic;
70
  signal clk_we_period_r : std_logic;
71
 
72
  signal derived_clk : std_logic;
73
 
74
begin  -- rtl
75
 
76
  full_out  <= full_out_r;              --from_fifo;
77
  data_out <= data_to_fifo;
78
  we_out <= we_to_fifo;
79
  one_p_from_fifo <= one_p_in;
80
  full_from_fifo <= full_in;
81
 
82
  refaster : process (clk_we, rst_n)
83
  begin  -- process refaster
84
    if rst_n = '0' then                 -- asynchronous reset (active low)
85
      full_out_r     <= '1';
86
      data_between_r <= (others => '0');
87
      we_between_r   <= '0';
88
 
89
    elsif clk_we'event and clk_we = '1' then  -- rising clock edge
90
      if full_between_r = '0' then
91
        data_between_r <= data_in;
92
        we_between_r   <= we_in;
93
      end if;
94
      full_out_r <= full_between_r or one_p_between_r;
95
    end if;
96
  end process refaster;
97
 
98
 
99
  derived_clk <= (clk_ps_we nand clk_ps_re) and clk_we;
100
 
101
  derclk : process (derived_clk, rst_n)
102
  begin  -- process derclk
103
    if rst_n = '0' then                 -- asynchronous reset (active low)
104
      data_to_fifo    <= (others => '0');
105
      we_local_r      <= '0';
106
      full_between_r  <= '0';
107
      one_p_between_r <= '0';
108
      clk_we_period_r <= '0';
109
    elsif derived_clk'event and derived_clk = '1' then  -- rising clock edge
110
      if full_from_fifo = '0' then
111
        data_to_fifo <= data_between_r;
112
        we_local_r   <= we_between_r;
113
      else
114
        we_local_r <= '0';
115
      end if;
116
      full_between_r  <= full_from_fifo;
117
      one_p_between_r <= one_p_from_fifo;
118
      clk_we_period_r <= not clk_we_period_r;
119
    end if;
120
  end process derclk;
121
 
122
  one_p_out <= one_p_between_r;         -- follows one_p_between.
123
  we_to_fifo <= (clk_we_period_r xor clk_we_was_r) and we_local_r;
124
 
125
  process (clk_re, rst_n)
126
  begin  -- process
127
    if rst_n = '0' then                 -- asynchronous reset (active low)
128
      clk_we_was_r <= '0';
129
 
130
    elsif clk_re'event and clk_re = '1' then  -- rising clock edge
131
      clk_we_was_r <= clk_we_period_r;
132
    end if;
133
  end process;
134
 
135
 
136
end rtl;

powered by: WebSVN 2.1.0

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