Newer
Older
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
124
125
126
127
128
----------------------------------------------------------------------------------
-- Company:
-- Engineer:
--
-- Create Date: 29.03.2023 12:06:38
-- Design Name:
-- Module Name: security_door_TB - Behavioral
-- Project Name:
-- Target Devices:
-- Tool Versions:
-- Description:
--
-- Dependencies:
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
--
----------------------------------------------------------------------------------
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 leaf cells in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity security_door_TB is
-- Port ( );
end security_door_TB;
architecture Behavioral of security_door_TB is
component Security_Door
generic(freq : integer := 100000000);
Port ( A : in STD_LOGIC;
B : in STD_LOGIC;
C : in STD_LOGIC;
D : in STD_LOGIC;
E : in STD_LOGIC;
F : in STD_LOGIC;
--buttons
SEND : in std_logic;
RESET : in std_logic;
--clock
CLK : in std_logic;
--for seven segment display
ANODE : out std_logic_vector (3 downto 0); --all digits declared although only 3 and 0 are used
LED_out : out STD_LOGIC_VECTOR (6 downto 0);
locked_test : out std_logic );
end component;
--signal declarations
---user input
signal input : std_logic_vector(5 downto 0);
---hardset password
signal password : std_logic_vector(5 downto 0);
--count for displayed countdown
signal count : integer range 2 to 11;
--locked flag
signal locked: boolean := true;
--ticks to innumerate clock ticks
signal ticks: integer := 0;
--counters for flashing function
signal flashCount: integer;
signal flashCountX: integer;
--count for debouncing button (0.25 seconds)
constant buttonCount: integer := 25000000;
signal buttonReset: integer := 0;
type button_state is (idle, waiting, pressed);
signal user_in : button_state;
signal send_in : button_state := idle;
--signal sendState : button_state := idle;
--signal resetState : button_state := idle;
signal reset_in : button_state := idle;
constant button_active : std_logic := '1';
signal buttonticks : integer := 0;
signal send_out : integer := 0;
signal reset_out : integer := 0;
signal send_pressed : boolean := false;
signal reset_pressed : boolean := false;
type LED_state is (flashing, lockedLED, unlockedLED);
signal LED : LED_state := unlockedLED;
signal internalReset : boolean := true;
signal CLK : std_logic ;
signal A, B, C, D, E, F, SEND, RESET, locked_test : std_logic ;
begin
process
begin
clk <= '0';
wait for 10 NS;
clk <= '1';
wait for 10 NS;
end process;
stimuli : process
begin
A <= '1'; B <= '1'; C <= '0'; D <= '0'; E <= '1'; F <= '1'; send_pressed <= true; wait for 1000000000 NS;
send_pressed <= false; wait for 10 ns;
reset_pressed <= true; wait for 10 ns;
A <= '1'; B <= '1'; C <= '1'; D <= '1'; E <= '1'; F <= '1'; send_pressed <= true; wait for 1000000000 NS;
end process;
G1 : Security_Door port map (A => A, B=> B, C => C, D => D, E=> E, F => F, SEND => SEND, RESET => RESET, locked_test => locked_test, CLK => CLK);
end Behavioral;