forked from peterotte/A2ExpTrigger
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DelayByCounter.vhd
81 lines (70 loc) · 1.79 KB
/
DelayByCounter.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
-- Peter-Bernd Otte
-- 7.5.2012
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity DelayByCounter is
Generic (
DelayTime : integer := 10;
OutputTime : integer := 4
);
Port ( Clock : in STD_LOGIC;
Input : in STD_LOGIC;
DelayedOutput : out STD_LOGIC);
end DelayByCounter;
architecture Behavioral of DelayByCounter is
COMPONENT SingleBitStorage
PORT( Data : IN STD_LOGIC;
Clock : IN STD_LOGIC;
Clear : IN STD_LOGIC;
Output : OUT STD_LOGIC);
END COMPONENT;
signal Counter : std_logic_vector(11 downto 0);
signal CounterEnabled : std_logic;
signal Reset : std_logic;
signal Treshold1, Treshold2 : std_logic;
signal Treshold1_Hold, Treshold2_Hold : std_logic;
begin
Inst_SingleBitStorage_1: SingleBitStorage PORT MAP(
Data => '1',
Clock => Input,
Clear => Reset,
Output => CounterEnabled
);
process (clock)
begin
if rising_edge(clock) then
if CounterEnabled = '1' then
Counter <= Counter + 1;
else
Counter <= (others=> '0');
end if;
end if;
end process;
process (clock)
begin
if CounterEnabled = '0' then --this should be replaced by some clocked version
Treshold1 <= '0';
elsif Counter = DelayTime then
Treshold1 <= '1';
end if;
end process;
process (clock)
begin
if CounterEnabled = '0' then --this should be replaced by some clocked version
Treshold2 <= '0';
elsif Counter = DelayTime+OutputTime then
Treshold2 <= '1';
end if;
end process;
process (clock)
begin
if rising_edge(clock) then
Treshold1_Hold <= Treshold1;
Treshold2_Hold <= Treshold2;
end if;
end process;
Reset <= Treshold2_Hold;
DelayedOutput <= '1' when (Treshold2_Hold = '0') and (Treshold1_Hold = '1') else '0';
end Behavioral;