aboutsummaryrefslogtreecommitdiffstats
path: root/testsuite/gna/issue1051/psi_common_bit_cc.vhd
blob: 6078571aac42705afac6d2631e523c8c3a261a3c (plain)
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
------------------------------------------------------------------------------
--  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 multple independent
-- single-bit signals from one clock domain to another one.
-- Double stage synchronizers are implemeted for each bit, including then
-- required attributes.
--
------------------------------------------------------------------------------
-- Libraries
------------------------------------------------------------------------------
library ieee ;
	use ieee.std_logic_1164.all;
	use ieee.numeric_std.all;
	
------------------------------------------------------------------------------
-- Entity Declaration
------------------------------------------------------------------------------
entity psi_common_bit_cc is
	generic (
		NumBits_g		: positive		:= 1
	);
	port (
		-- Clock Domain A
		BitsA		: in 	std_logic_vector(NumBits_g-1 downto 0);
		
		-- Clock Domain B
		ClkB		: in	std_logic;
		BitsB		: out	std_logic_vector(NumBits_g-1 downto 0)
	);
end entity;
		
------------------------------------------------------------------------------
-- Architecture Declaration
------------------------------------------------------------------------------
architecture rtl of psi_common_bit_cc is

	signal Reg0	: std_logic_vector(NumBits_g-1 downto 0)	:= (others => '0');
	signal Reg1 : std_logic_vector(NumBits_g-1 downto 0)	:= (others => '0');
	
	attribute syn_srlstyle : string;
    attribute syn_srlstyle of Reg0 	: signal is "registers";
    attribute syn_srlstyle of Reg1 	: signal is "registers";
	
	attribute shreg_extract : string;
    attribute shreg_extract of Reg0 	: signal is "no";
    attribute shreg_extract of Reg1 	: signal is "no";
	
	attribute ASYNC_REG : string;
    attribute ASYNC_REG of Reg0 		: signal is "TRUE";
    attribute ASYNC_REG of Reg1 		: signal is "TRUE";
	
begin
	
	-- Process
	p : process(ClkB)
	begin
		if rising_edge(ClkB) then
			Reg0 <= BitsA;
			Reg1 <= Reg0;
		end if;
	end process;
	BitsB <= Reg1;
end;