Hardware Reference
In-Depth Information
5 entity triggered_mono is
6 port (
7 x, clk, rst: in std_logic;
8 y: buffer std_logic;
9 y_reg: out std_logic);
10 end entity;
11 -------------------------------------------------------
12 architecture moore_fsm of triggered_mono is
13
14
--FSM-related declarations:
15
type state is (A, B, C, D);
16
signal pr_state, nx_state: state;
17
18
--Timer-related declarations:
19
constant delay: natural := 3; --any value >=2
20
signal t: natural range 0 to delay-1; --tmax≥delay-1
21
22 begin
23
24
--Timer (strategy #1, adapted):
25
process (clk, rst)
26
begin
27
if rst='1' then
28
t <= 0;
29
elsif rising_edge(clk) then
30
if pr_state /= nx_state then
31
if nx_state/=D then
32
t <= 0;
33
end if;
34
elsif t/=delay-1 then
35
t <= t + 1;
36
end if;
37
end if;
38
end process;
39
40
--FSM state register:
41
process (clk, rst)
42
begin
43
if rst='1' then
44
pr_state <= A;
45
elsif rising_edge(clk) then
46
pr_state <= nx_state;
47
end if;
48
end process;
49
50
--FSM combinational logic:
51
process (all)
52
begin
53
case pr_state is
54
when A =>
55
y <= '0';
56
if x='0' then
57
nx_state <= B;
58
else
59
nx_state <= A;
60
end if;
Search WWH ::




Custom Search