Advertisement
Guest User

Untitled

a guest
Jan 28th, 2020
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.07 KB | None | 0 0
  1. ----------------------------------------------------------------------------------
  2. -- Company:
  3. -- Engineer:
  4. --
  5. -- Create Date: 11:10:12 01/28/2020
  6. -- Design Name:
  7. -- Module Name: progetto_TD_vhdl - Bank_entrance
  8. -- Project Name:
  9. -- Target Devices:
  10. -- Tool versions:
  11. -- Description:
  12. --
  13. -- Dependencies:
  14. --
  15. -- Revision:
  16. -- Revision 0.01 - File Created
  17. -- Additional Comments:
  18. --
  19. ----------------------------------------------------------------------------------
  20. library IEEE;
  21. use IEEE.STD_LOGIC_1164.ALL;
  22.  
  23. -- Uncomment the following library declaration if using
  24. -- arithmetic functions with Signed or Unsigned values
  25. use IEEE.NUMERIC_STD.ALL;
  26.  
  27. -- Uncomment the following library declaration if instantiating
  28. -- any Xilinx primitives in this code.
  29. --library UNISIM;
  30. --use UNISIM.VComponents.all;
  31.  
  32. entity progetto_TD_vhdl is
  33. Port ( --Inputs:
  34. buttonA : in STD_LOGIC; --pulsante apertura portaA
  35. buttonB : in STD_LOGIC; --pulsante apertura portaB
  36. sensorA : in STD_LOGIC; --sensore passaggio porta A
  37. sensorB : in STD_LOGIC; --sensore passaggio porta B
  38. sensorC : in STD_LOGIC; --rilevazione persona tra le due porte
  39. md_detection : in STD_LOGIC; --rilevazione metal detector
  40.  
  41. --Outputs:
  42. doorA : out STD_LOGIC; --apertura porta A
  43. doorB : out STD_LOGIC; --apertura porta B
  44. alarm : out STD_LOGIC; --attivazione allarme di sicurezza
  45.  
  46. clk : in STD_LOGIC;
  47. rst : in STD_LOGIC);
  48. end progetto_TD_vhdl;
  49.  
  50. architecture Bank_entrance of progetto_TD_vhdl is
  51. signal exit_temp : STD_LOGIC_VECTOR (0 to 2);
  52.  
  53. type state is ( s0, s1, s2, s3, s4, s5, s6, s7 ); --dichiarazione stati automa
  54. signal current_state, next_state : state;
  55.  
  56. begin
  57. process(clk)
  58. begin
  59. if ( rising_edge ( clk ) ) then
  60. if ( rst = '1' ) then
  61. current_state <= s7;
  62. else
  63. current_state <= next_state;
  64. end if;
  65. end if;
  66. end process;
  67.  
  68. next_state_and_output_moore: process(current_state, buttonA, buttonB,
  69. sensorA, sensorB, sensorC, md_detection)
  70. begin
  71. case current_state is
  72. when s0 => exit_temp <= "000";
  73. if ( buttonA <= '1' and buttonB <= '0' ) then
  74. next_state <= s1;
  75. elsif ( buttonB <= '1' ) then
  76. next_state <= s5;
  77. else
  78. next_state <= s0;
  79. end if;
  80. when s1 => exit_temp <= "100";
  81. if( sensorC <= '1' and sensorA <= '0') then
  82. next_state <= s2;
  83. else
  84. next_state <= s1;
  85. end if;
  86. when s2 => exit_temp <= "000";
  87. if ( sensorC <= '1' and md_detection <= '0' ) then
  88. next_state <= s3;
  89. elsif ( sensorC <= '1' and md_detection <= '1' ) then
  90. next_state <= s4;
  91. else
  92. next_state <= s2;
  93. end if;
  94. when s3 => exit_temp <= "010";
  95. if ( sensorC <= '0' and sensorB <= '0' ) then
  96. next_state<=s0;
  97. else
  98. next_state<=s3;
  99. end if;
  100. when s4=> exit_temp <= "101";
  101. if( sensorC <= '0' and sensorB <= '0' and md_detection <= '0' ) then
  102. next_state <= s0;
  103. else
  104. next_state <= s4;
  105. end if;
  106. when s5=> exit_temp <= "010";
  107. if( sensorC <= '1' and sensorB <= '0' )then
  108. next_state <= s6;
  109. else
  110. next_state <= s5;
  111. end if;
  112. when s6=> exit_temp <= "000";
  113. --wait for clk;
  114. next_state <= s7;
  115. when s7=> exit_temp <= "100";
  116. if( sensorC <= '0' and sensorA <= '0' ) then
  117. next_state <= s0;
  118. else
  119. next_state <= s7;
  120. end if;
  121. end case;
  122. end process;
  123.  
  124. update_exit : process ( exit_temp )
  125. begin
  126. if(exit_temp<="000") then
  127. doorA<='0';
  128. doorB<='0';
  129. alarm<='0';
  130. elsif(exit_temp<="101") then
  131. doorA<='1';
  132. doorB<='0';
  133. alarm<='1';
  134. elsif(exit_temp<="100") then
  135. doorA<='1';
  136. doorB<='0';
  137. alarm<='0';
  138. elsif(exit_temp<="010") then
  139. doorA<='0';
  140. doorB<='1';
  141. alarm<='0';
  142. else
  143. doorA<='-';
  144. doorB<='-';
  145. alarm<='-';
  146. end if;
  147. end process;
  148.  
  149. end Bank_entrance;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement