-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathpsi_common_simple_cc.vhd
96 lines (86 loc) · 3.65 KB
/
psi_common_simple_cc.vhd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
------------------------------------------------------------------------------
-- Copyright (c) 2018 by Paul Scherrer Institute, Switzerland
-- All rights reserved.
-- Authors: Oliver Bruendler
------------------------------------------------------------------------------
------------------------------------------------------------------------------
-- Description
------------------------------------------------------------------------------
-- This is a very basic clock crossing that allows passing single samples of data
-- from one clock domain to another. It only works if sample rates are significantly
-- lower than the clock speed of both domains.
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
-- @formatter:off
entity psi_common_simple_cc is
generic(width_g : positive := 16; -- Width of the data signal to implement the clock crossing for
a_rst_pol_g : std_logic:='1'; -- reset polarity A port
b_rst_pol_g : std_logic:='1'); -- reset polarity B port
port( a_clk_i : in std_logic; -- Clock A
a_rst_i : in std_logic; -- Clock domain A reset input (active high)
a_rst_o : out std_logic; -- Clock domain A reset output (active high), active if *RstInA* or *RstInB* is asserted, de-asserted synchronously to *ClkA*
a_dat_i : in std_logic_vector(width_g - 1 downto 0); -- Data signal input
a_vld_i : in std_logic; -- AXI-S handshaking signal
b_clk_i : in std_logic; -- Clock B
b_rst_i : in std_logic; -- Clock domain A reset input (active high)
b_rst_o : out std_logic; -- Clock domain B reset output (active high), active if *RstInA* or *RstInB* is asserted, de-asserted synchronously to *ClkA*
b_dat_o : out std_logic_vector(width_g - 1 downto 0); -- Data signal output
b_vld_o : out std_logic); -- AXI-S handshaking signal
end entity;
-- @formatter:on
architecture rtl of psi_common_simple_cc is
-- Domain A signals
signal RstAI : std_logic;
signal DataLatchA : std_logic_vector(width_g - 1 downto 0);
-- Domain B signals
signal RstBI : std_logic;
signal VldBI : std_logic;
begin
i_pulse_cc : entity work.psi_common_pulse_cc
generic map(
num_pulses_g => 1,
a_rst_pol_g => a_rst_pol_g,
b_rst_pol_g => b_rst_pol_g
)
port map(
a_clk_i => a_clk_i,
a_rst_i => a_rst_i,
a_rst_o => RstAI,
a_dat_i(0) => a_vld_i,
b_clk_i => b_clk_i,
b_rst_i => b_rst_i,
b_rst_o => RstBI,
b_dat_o(0) => VldBI
);
a_rst_o <= RstAI;
b_rst_o <= RstBI;
-- Data transmit side (A)
DataA_p : process(a_clk_i)
begin
if rising_edge(a_clk_i) then
if RstAI = a_rst_pol_g then
DataLatchA <= (others => '0');
else
if a_vld_i = '1' then
DataLatchA <= a_dat_i;
end if;
end if;
end if;
end process;
-- Data receive side (B)
DataB_p : process(b_clk_i)
begin
if rising_edge(b_clk_i) then
if RstBI = b_rst_pol_g then
b_dat_o <= (others => '0');
b_vld_o <= '0';
else
b_vld_o <= VldBI;
if VldBI = '1' then
b_dat_o <= DataLatchA;
end if;
end if;
end if;
end process;
end architecture;