-
Notifications
You must be signed in to change notification settings - Fork 0
/
g09_dealer_FSM.vhd
64 lines (51 loc) · 1.16 KB
/
g09_dealer_FSM.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
library ieee;
use ieee.std_logic_1164.all;
entity g09_dealer_FSM is
port (
Request_Deal, RAND_LT_NUM, reset, Clock : in std_logic;
Stack_Enable, Rand_Enable : out std_logic);
end g09_dealer_FSM;
architecture behavioural of g09_dealer_FSM is
type state_type is (A,B,C,D);
signal y_present,y_next : state_type;
begin
process1: process(y_present,y_next,Request_Deal,RAND_LT_NUM)
begin
case y_present is
when A =>
if Request_Deal = '0' then
y_next <= B;
else
y_next <= A;
end if;
when B =>
if Request_Deal = '1' then
y_next <= C;
else
y_next <= B;
end if;
when C =>
if RAND_LT_NUM = '0' then
y_next <= C;
else
y_next <= D;
end if;
when D =>
y_next <= A;
when others =>
y_next <= A;
end case;
end process;
process2: process (Clock, reset)
begin
if reset = '1' then
y_present <= A;
elsif (clock'event and clock = '1') then
y_present <= y_next;
end if;
end process;
Rand_Enable <= '1' when y_present = C
else '0';
Stack_Enable <= '1' when y_present = D
else '0';
end behavioural;