Advertisement
Guest User

Untitled

a guest
Jan 10th, 2019
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 1.77 KB | None | 0 0
  1. library IEEE;
  2. use IEEE.STD_LOGIC_1164.ALL;
  3.  
  4. entity test is
  5. end test;
  6.  
  7. architecture Behavioral of test is
  8.     component FSM is
  9.         Port (
  10.             CLK : in STD_LOGIC;
  11.             RST : in STD_LOGIC;
  12.             FRONT_SENSOR : in STD_LOGIC;
  13.             BACK_SENSOR : in STD_LOGIC;
  14.             PASSWORD_1 : in STD_LOGIC_VECTOR(1 downto 0);
  15.             PASSWORD_2 : in STD_LOGIC_VECTOR(1 downto 0);
  16.             GREEN_LED : inout STD_LOGIC;
  17.             RED_LED : inout STD_LOGIC
  18.         );
  19.     end component;
  20.     SIGNAL CLK : STD_LOGIC;
  21.     SIGNAL RST : STD_LOGIC;
  22.     SIGNAL FRONT_SENSOR : STD_LOGIC;
  23.     SIGNAL BACK_SENSOR : STD_LOGIC;
  24.     SIGNAL PASSWORD_1 : STD_LOGIC_VECTOR(1 downto 0);
  25.     SIGNAL PASSWORD_2 : STD_LOGIC_VECTOR(1 downto 0);
  26.     SIGNAL GREEN_LED : STD_LOGIC;
  27.     SIGNAL RED_LED : STD_LOGIC;
  28. begin
  29.     car_parking : fsm port map(
  30.         clk=>clk,rst=>rst,front_sensor=>front_sensor,back_sensor=>back_sensor,
  31.         password_1=>password_1,password_2=>password_2,green_led=>green_led,red_led=>red_led
  32.     );
  33.    
  34.     process begin
  35.         wait for 15ns;
  36.         clk<='0';
  37.         wait for 15ns;
  38.         clk<='1';
  39.     end process;
  40.    
  41.     process begin
  42.         wait for 100ns;
  43.         rst<='1';
  44.         wait until falling_edge(clk);
  45.         rst<='0';
  46.         front_sensor<='1';
  47.         password_1<="11";
  48.         password_2<="11";
  49.         wait until green_led='1';
  50.         back_sensor<='1';
  51.         password_1<="10";
  52.         wait until falling_edge(clk);
  53.         back_sensor<='0';
  54.         wait until falling_edge(clk);
  55.         password_1<="11";
  56.         wait until falling_edge(clk);
  57.         front_sensor<='0';
  58.         back_sensor<='1';
  59.         wait until falling_edge(clk);
  60.         back_sensor<='0';
  61.     end process;
  62. end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement