AMC13
Firmwares for the different applications of the AMC13 uTCA board made at Boston University
 All Classes Variables
resync.vhd
1 --###################################################
2 -- clock domain translate
3 --
4 -- V1.00 : clock IN should be lower that clock out
5 -- v2.00 : clock IN and clock out can be anything
6 --
7 --
8 --
9 
10 
11 LIBRARY ieee;
12 USE ieee.std_logic_1164.all;
13 use ieee.numeric_std.all;
14 entity resync is
15 port (
16  reset : in std_logic;
17  Free_clki : in std_logic := '1'; -- '0' the clocki is not a free runing clock -- '1' the clocki is a free running clock
18  clocki : in std_logic;
19  clocko : in std_logic;
20  input : in std_logic;
21  output : out std_logic
22  );
23 end resync;
24 architecture behavioral of resync is
25 signal reg : std_logic_vector(2 downto 0);
26 signal mem : std_logic;
27 signal glb_rst : std_logic;
28 
29 
30 --#################################################
31 --# here start code
32 --#################################################
33 begin
34 
35 glb_rst <= '0' when reset = '0' or reg(2) = '1' else '1';
36 
37 process(glb_rst,clocki)
38 begin
39  if glb_rst = '0' then
40  reg(0) <= '0';
41  elsif rising_edge(clocki) then
42  if input = '1' and mem = '0' then
43  reg(0) <= '1';
44  end if;
45  end if;
46 end process;
47 
48 process( reset,clocki)
49 begin
50  if reset = '0' then
51  mem <= '0';
52  elsif rising_edge(clocki) then
53  mem <= input and Free_clki;
54  end if;
55 
56 end process;
57 
58 process(glb_rst,clocko)
59 begin
60  if glb_rst = '0' then
61  reg(1) <= '0';
62  elsif rising_edge(clocko) then
63  reg(1) <= reg(0);
64  end if;
65 end process;
66 
67 process(reset,clocko)
68 begin
69  if rising_edge(clocko) then
70  reg(2) <= reg(1);
71  end if;
72 end process;
73 
74 output <= reg(2);
75 
76 end behavioral;