-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfgc.vhd
83 lines (67 loc) · 1.95 KB
/
fgc.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
82
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
-- A simple demonstration of using formal verification
-- to solve the Fox-Goat-Cabbage problem
entity fgc is
port (
clk_i : in std_logic;
rst_i : in std_logic;
-- THe boat can only carry one of the three items
item_i : in std_logic_vector(1 downto 0);
-- Current status
bank_f_o : out std_logic;
bank_g_o : out std_logic;
bank_c_o : out std_logic;
bank_m_o : out std_logic
);
end entity fgc;
architecture synthesis of fgc is
signal bank_f : std_logic := '0';
signal bank_g : std_logic := '0';
signal bank_c : std_logic := '0';
signal bank_m : std_logic := '0';
begin
p_move : process (clk_i)
begin
if rising_edge(clk_i) then
case item_i is
when "00" =>
-- Move MAN only
bank_m <= not bank_m;
when "01" =>
if bank_f = bank_m then
-- Move MAN and FOX
bank_f <= not bank_f;
bank_m <= not bank_m;
end if;
when "10" =>
if bank_g = bank_m then
-- Move MAN and GOAT
bank_g <= not bank_g;
bank_m <= not bank_m;
end if;
when "11" =>
if bank_c = bank_m then
-- Move MAN and CABBAGE
bank_c <= not bank_c;
bank_m <= not bank_m;
end if;
when others =>
null;
end case;
if rst_i = '1' then
-- Initially, everything is on bank 0
bank_f <= '0';
bank_g <= '0';
bank_c <= '0';
bank_m <= '0';
end if;
end if;
end process p_move;
-- Connect output signals
bank_f_o <= bank_f;
bank_g_o <= bank_g;
bank_c_o <= bank_c;
bank_m_o <= bank_m;
end architecture synthesis;