-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathelevator_test_2.vht
123 lines (112 loc) · 2.45 KB
/
elevator_test_2.vht
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
117
118
119
120
121
122
123
-- Vhdl Self-Checking Test Bench (with test vectors) for design : elevator
-- Auto generated by Quartus II
-- Modified and checked by
-- Roberto Uceda Gomez, NIA 100346538
-- Digital electronics lab, session 2
LIBRARY ieee;
USE ieee.std_logic_1164.all;
LIBRARY STD;
USE STD.textio.ALL; -- to enable writing to console
ENTITY elevator_vhd_vec_tst IS
END elevator_vhd_vec_tst;
ARCHITECTURE elevator_arch OF elevator_vhd_vec_tst IS
-- constants
-- signals
-- inputs
SIGNAL B : STD_LOGIC_VECTOR(3 DOWNTO 0);
SIGNAL RESET : STD_LOGIC;
SIGNAL S : STD_LOGIC;
SIGNAL CLK : STD_LOGIC;
-- outputs
SIGNAL BUSY : STD_LOGIC;
SIGNAL FLOOR : STD_LOGIC_VECTOR(1 DOWNTO 0);
SIGNAL MOTOR : STD_LOGIC;
SIGNAL OPENING : STD_LOGIC;
SIGNAL SENSE : STD_LOGIC;
SIGNAL TARGET : STD_LOGIC_VECTOR(1 DOWNTO 0);
--clock period
constant clk_period : time := 1ms;
COMPONENT elevator
PORT (
B : IN STD_LOGIC_VECTOR(3 DOWNTO 0);
BUSY : OUT STD_LOGIC;
CLK : IN STD_LOGIC;
FLOOR : OUT STD_LOGIC_VECTOR(1 DOWNTO 0);
MOTOR : OUT STD_LOGIC;
OPENING : OUT STD_LOGIC;
RESET : IN STD_LOGIC;
S : IN STD_LOGIC;
SENSE : OUT STD_LOGIC;
TARGET : OUT STD_LOGIC_VECTOR(1 DOWNTO 0)
);
END COMPONENT;
BEGIN
uut : elevator
PORT MAP (
-- list connections between master ports and signals
B => B,
BUSY => BUSY,
CLK => CLK,
FLOOR => FLOOR,
MOTOR => MOTOR,
OPENING => OPENING,
RESET => RESET,
S => S,
SENSE => SENSE,
TARGET => TARGET
);
END elevator_arch;
-- clock process def
process
begin
CLK <= '0';
wait for clk_period/2;
CLK <= '1';
wait for clk_period/2;
end process;
-- stimulus
stim_proc: process
begin
-- reset
RESET <= '1';
wait for 10ms;
RESET <= '0';
wait for 10ms;
-- button press - third floor
B(3) <= '1';
wait for 2ms;
B(3) <= '0';
wait for 20ms;
-- floor pass, three floors
S <= '1';
wait for 2ms;
S <= '0';
wait for 20ms;
S <= '1';
wait for 2ms;
S <= '0';
wait for 20ms;
S <= '1';
wait for 2ms;
S <= '0';
wait for 200ms;
-- button press - first floor
B(0) <= '1';
wait for 2ms;
B(0) <= '0';
wait for 20ms;
-- floor pass, three floors
S <= '1';
wait for 2ms;
S <= '0';
wait for 20ms;
S <= '1';
wait for 2ms;
S <= '0';
wait for 20ms;
S <= '1';
wait for 2ms;
S <= '0';
wait for 200ms;
end process;
end elevator_arch;