-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsynchronizer.vhd
44 lines (29 loc) · 976 Bytes
/
synchronizer.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
-- By George and Daniel
-- library declaration
library ieee;
use ieee.std_logic_1164.all;
-- declare ports (intputs/outputs)d
entity synchronizer is port (
clk : in std_logic; -- global clock signal
reset : in std_logic; -- synchronized reset
din : in std_logic; -- data input
dout : out std_logic -- data output
);
end synchronizer;
architecture circuit of synchronizer is
-- 2 bit signal used to track register value
Signal sreg : std_logic_vector(1 downto 0);
BEGIN
-- change sreg depending on the clock signal
process (clk) is
begin
if (rising_edge(clk)) then -- only evaluate if clock is on rising edge
if (reset = '1') then -- if reset bit is active, set sreg to "00"
sreg <= "00";
else -- else, shift the bits of sreg left and concatonate din to sreg(0)
sreg(1 downto 0) <= sreg(0) & din;
end if;
end if;
end process;
dout <= sreg(1); -- assigns data output the vzlue of the second register
end circuit;