forked from IanGoodbody/ECE281_Lab3
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMooreElevatorController_Shell.vhd
More file actions
117 lines (104 loc) · 3.59 KB
/
Copy pathMooreElevatorController_Shell.vhd
File metadata and controls
117 lines (104 loc) · 3.59 KB
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
----------------------------------------------------------------------------------
-- Company: USAFA/DFEC
-- Engineer: Silva
--
-- Create Date: 10:33:47 07/07/2012
-- Design Name: CE3
-- Module Name: MooreElevatorController_Shell - Behavioral
-- Description: Shell for completing CE3
--
----------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--use IEEE.NUMERIC_STD.ALL;
-- Uncomment the following library declaration if instantiating
-- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity MooreElevatorController_Shell is
Port ( clk : in STD_LOGIC;
reset : in STD_LOGIC;
stop : in STD_LOGIC;
up_down : in STD_LOGIC;
floor : out STD_LOGIC_VECTOR (3 downto 0));
end MooreElevatorController_Shell;
architecture Behavioral of MooreElevatorController_Shell is
--Below you create a new variable type! You also define what values that
--variable type can take on. Now you can assign a signal as
--"floor_state_type" the same way you'd assign a signal as std_logic
type floor_state_type is (floor1, floor2, floor3, floor4);
--Here you create a variable "floor_state" that can take on the values
--defined above. Neat-o!
signal floor_state : floor_state_type;
begin
---------------------------------------------
--Below you will code your next-state process
---------------------------------------------
--This line will set up a process that is sensitive to the clock
floor_state_machine: process(clk)
begin
--clk'event and clk='1' is VHDL-speak for a rising edge
if clk'event and clk='1' then
--reset is active high and will return the elevator to floor1
--Question: is reset synchronous or asynchronous?
if reset='1' then
floor_state <= floor1;
--now we will code our next-state logic
else
case floor_state is
--when our current state is floor1
when floor1 =>
--if up_down is set to "go up" and stop is set to
--"don't stop" which floor do we want to go to?
if (up_down='1' and stop='0') then
--floor2 right?? This makes sense!
floor_state <= floor2;
--otherwise we're going to stay at floor1
else
floor_state <= floor1;
end if;
--when our current state is floor2
when floor2 =>
--if up_down is set to "go up" and stop is set to
--"don't stop" which floor do we want to go to?
if (up_down='1' and stop='0') then
floor_state <= floor3;
--if up_down is set to "go down" and stop is set to
--"don't stop" which floor do we want to go to?
elsif (up_down='0' and stop='0') then
floor_state <= floor1;
--otherwise we're going to stay at floor2
else
floor_state <= floor2;
end if;
--COMPLETE THE NEXT STATE LOGIC ASSIGNMENTS FOR FLOORS 3 AND 4
when floor3 =>
if ( ) then
floor_state <=
elsif ( ) then
floor_state <=
else
floor_state <=
end if;
when floor4 =>
if ( ) then
floor_state <=
else
floor_state <=
end if;
--This line accounts for phantom states
when others =>
floor_state <= floor1;
end case;
end if;
end if;
end process;
-- Here you define your output logic. Finish the statements below
floor <= "0001" when (floor_state = ) else
"0010" when ( ) else
"0011" when ( ) else
"0100" when ( ) else
"0001";
end Behavioral;