-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFSM01.vhd
51 lines (47 loc) · 878 Bytes
/
FSM01.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
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned;
entity FSM01 is
port(
reset, clk, k: in std_logic;
q: out std_logic
);
end FSM01;
--output depends on current state and input, since Mealy machine
architecture behaviour of FSM01 is
type state_type is (E0, E1);
signal pres_st, next_st: state_type;
begin
process(pres_st, k)
begin
case pres_st is
when E0 =>
if (k = '0') then
next_st <= E1;
q <= '1';
else
next_st <= E0;
q <= '0';
end if;
when E1 =>
if (k = '0') then
next_st <= E1;
q <= '1';
else
next_st <= E0;
q <= '0';
end if;
when others =>
next_st <= E0;
q<= '0';
end case;
end process;
process(clk, reset)
begin
if (reset = '1') then
pres_st <= E0;
elsif (rising_edge(clk)) then
pres_st <= next_st;
end if;
end process;
end behaviour;