-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQ5.a -2017-18 Dsd
62 lines (54 loc) · 904 Bytes
/
Q5.a -2017-18 Dsd
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
Library ieee;
use ieee.std_logic_1164.all;
Entity of FSM is
port(Clk,Reset,x: in Std_logic;
y : out Std_logic);
end Fsm;
Architecture Beh of FSM is
Type State is (A,B,C,D);
Signal next_state : State;
begin
Process(Clk,Reset)
begin
if (Reset='1') then
next_state<= A;
elsif(Clk='1' and Clk'event) then
Case next_state is
when A=>
if (x='0') then
next_state<=A;
y<=0;
else
next_state <=B;
y<=0;
end if;
when B=>
if (x='0') then
next_state<=C;
y<=0;
else
next_state<=D;
y<=1;
end if;
when C=>
if (x='0') then
next_state<=C;
y<=0;
else
next_state<=D;
y<=1;
end if;
when D=>
if (x='0') then
next_state<=B;
y<=0;
else
next_state<=A;
y<=0;
end if;
when others=>
null;
end case;
end if;
end Process;
end Beh;