1 |
3 |
danv |
-------------------------------------------------------------------------------
|
2 |
|
|
--
|
3 |
|
|
-- Copyright (C) 2010
|
4 |
|
|
-- ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/>
|
5 |
|
|
-- JIVE (Joint Institute for VLBI in Europe) <http://www.jive.nl/>
|
6 |
|
|
-- P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
|
7 |
|
|
--
|
8 |
|
|
-- This program is free software: you can redistribute it and/or modify
|
9 |
|
|
-- it under the terms of the GNU General Public License as published by
|
10 |
|
|
-- the Free Software Foundation, either version 3 of the License, or
|
11 |
|
|
-- (at your option) any later version.
|
12 |
|
|
--
|
13 |
|
|
-- This program is distributed in the hope that it will be useful,
|
14 |
|
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15 |
|
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16 |
|
|
-- GNU General Public License for more details.
|
17 |
|
|
--
|
18 |
|
|
-- You should have received a copy of the GNU General Public License
|
19 |
|
|
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
20 |
|
|
--
|
21 |
|
|
-------------------------------------------------------------------------------
|
22 |
|
|
|
23 |
|
|
-- Purpose: Get in_pulse from in_clk to out_pulse in the out_clk domain.
|
24 |
|
|
-- Description:
|
25 |
|
|
-- The in_pulse is captured in the in_clk domain and then transfered to the
|
26 |
|
|
-- out_clk domain. The out_pulse is also only one cycle wide and transfered
|
27 |
|
|
-- back to the in_clk domain to serve as an acknowledge signal to ensure
|
28 |
|
|
-- that the in_pulse was recognized also in case the in_clk is faster than
|
29 |
|
|
-- the out_clk. The in_busy is active during the entire transfer. Hence the
|
30 |
|
|
-- rate of pulses that can be transfered is limited by g_delay_len and by
|
31 |
|
|
-- the out_clk rate.
|
32 |
|
|
|
33 |
|
|
LIBRARY IEEE, common_pkg_lib;
|
34 |
|
|
USE IEEE.std_logic_1164.ALL;
|
35 |
|
|
USE common_pkg_lib.common_pkg.ALL;
|
36 |
|
|
|
37 |
|
|
ENTITY common_spulse IS
|
38 |
|
|
GENERIC (
|
39 |
|
|
g_delay_len : NATURAL := c_meta_delay_len
|
40 |
|
|
);
|
41 |
|
|
PORT (
|
42 |
|
|
in_rst : IN STD_LOGIC := '0';
|
43 |
|
|
in_clk : IN STD_LOGIC;
|
44 |
|
|
in_clken : IN STD_LOGIC := '1';
|
45 |
|
|
in_pulse : IN STD_LOGIC;
|
46 |
|
|
in_busy : OUT STD_LOGIC;
|
47 |
|
|
out_rst : IN STD_LOGIC := '0';
|
48 |
|
|
out_clk : IN STD_LOGIC;
|
49 |
|
|
out_clken : IN STD_LOGIC := '1';
|
50 |
|
|
out_pulse : OUT STD_LOGIC
|
51 |
|
|
);
|
52 |
|
|
END;
|
53 |
|
|
|
54 |
|
|
ARCHITECTURE rtl OF common_spulse IS
|
55 |
|
|
|
56 |
|
|
SIGNAL in_level : STD_LOGIC;
|
57 |
|
|
SIGNAL meta_level : STD_LOGIC_VECTOR(0 TO g_delay_len-1);
|
58 |
|
|
SIGNAL out_level : STD_LOGIC;
|
59 |
|
|
SIGNAL prev_out_level : STD_LOGIC;
|
60 |
|
|
SIGNAL meta_ack : STD_LOGIC_VECTOR(0 TO g_delay_len-1);
|
61 |
|
|
SIGNAL pulse_ack : STD_LOGIC;
|
62 |
|
|
SIGNAL nxt_out_pulse : STD_LOGIC;
|
63 |
|
|
|
64 |
|
|
BEGIN
|
65 |
|
|
|
66 |
|
|
capture_in_pulse : ENTITY work.common_switch
|
67 |
|
|
PORT MAP (
|
68 |
|
|
clk => in_clk,
|
69 |
|
|
clken => in_clken,
|
70 |
|
|
rst => in_rst,
|
71 |
|
|
switch_high => in_pulse,
|
72 |
|
|
switch_low => pulse_ack,
|
73 |
|
|
out_level => in_level
|
74 |
|
|
);
|
75 |
|
|
|
76 |
|
|
in_busy <= in_level OR pulse_ack;
|
77 |
|
|
|
78 |
|
|
p_out_clk : PROCESS(out_rst, out_clk)
|
79 |
|
|
BEGIN
|
80 |
|
|
IF out_rst='1' THEN
|
81 |
|
|
meta_level <= (OTHERS=>'0');
|
82 |
|
|
out_level <= '0';
|
83 |
|
|
prev_out_level <= '0';
|
84 |
|
|
out_pulse <= '0';
|
85 |
|
|
ELSIF RISING_EDGE(out_clk) THEN
|
86 |
|
|
IF out_clken='1' THEN
|
87 |
|
|
meta_level <= in_level & meta_level(0 TO meta_level'HIGH-1);
|
88 |
|
|
out_level <= meta_level(meta_level'HIGH);
|
89 |
|
|
prev_out_level <= out_level;
|
90 |
|
|
out_pulse <= nxt_out_pulse;
|
91 |
|
|
END IF;
|
92 |
|
|
END IF;
|
93 |
|
|
END PROCESS;
|
94 |
|
|
|
95 |
|
|
p_in_clk : PROCESS(in_rst, in_clk)
|
96 |
|
|
BEGIN
|
97 |
|
|
IF in_rst='1' THEN
|
98 |
|
|
meta_ack <= (OTHERS=>'0');
|
99 |
|
|
pulse_ack <= '0';
|
100 |
|
|
ELSIF RISING_EDGE(in_clk) THEN
|
101 |
|
|
IF in_clken='1' THEN
|
102 |
|
|
meta_ack <= out_level & meta_ack(0 TO meta_ack'HIGH-1);
|
103 |
|
|
pulse_ack <= meta_ack(meta_ack'HIGH);
|
104 |
|
|
END IF;
|
105 |
|
|
END IF;
|
106 |
|
|
END PROCESS;
|
107 |
|
|
|
108 |
|
|
nxt_out_pulse <= out_level AND NOT prev_out_level;
|
109 |
|
|
|
110 |
|
|
END rtl;
|