Skip to content
Snippets Groups Projects
security_door_TB.vhd 3.58 KiB
Newer Older
----------------------------------------------------------------------------------
-- 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;