Advertisement
Guest User

Untitled

a guest
Nov 21st, 2012
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 1.56 KB | None | 0 0
  1. --Robin Gonzalez. código en VHDL de una maquina de estados para un sistema de alarma, implementado en un GAL22v10
  2. library ieee;
  3. use ieee.std_logic_1164.all;
  4. use ieee.std_logic_arith.all;
  5. entity alarm is port (
  6.     clk: in std_logic;
  7.     a: in std_logic_vector(3 downto 0);
  8.     b: in std_logic_vector(3 downto 0);
  9.     ledOn: out std_logic;
  10.     x: out std_logic_vector(1 downto 0));
  11.  attribute pin_numbers of alarm: entity is
  12.     --inputs
  13.     "b(0):6 b(1):5 b(2):4 b(3):3 "
  14.     &
  15.     "a(0):10 a(1):9 a(2):8 a(3):7 "
  16.     --outputs
  17.     &
  18.     "x(0):15 x(1):16 "
  19.     &
  20.     "ledOn:17";
  21. end alarm;
  22.  
  23. architecture arch_alarm of alarm is
  24.     type states is (state0, state1, state2, state3 );
  25.     signal stado_pres, stado_fut: states;
  26.     --type boolean is (true, false);
  27.     --signal vdd: boolean;
  28. begin
  29.  
  30. p_estados: process(stado_pres,a,b) begin
  31.     case stado_pres is
  32.                 when state0 =>
  33.                     x <= "00";
  34.                     ledOn <= '0';
  35.                     if a = NOT(b) then
  36.                         stado_fut <= state1;
  37.                     else
  38.                         stado_fut <= state0;
  39.                     end if;
  40.                 when state1 =>
  41.                     x <= "01";
  42.                     if a = NOT(b) then
  43.                         stado_fut <= state2;
  44.                     else
  45.                         stado_fut <= state0;
  46.                     end if;
  47.                 when state2 =>
  48.                     x <= "10";
  49.                     if a = NOT(b) then
  50.                         stado_fut <= state3;
  51.                     else
  52.                         stado_fut <= state0;
  53.                     end if;
  54.                 when state3 =>
  55.                     x <= "11";
  56.                     if a = NOT(b) then
  57.                         ledOn <= '1';
  58.                     end if;
  59.                     stado_fut <= state0;
  60.             end case;
  61.     end process p_estados;
  62.        
  63.     p_reloj: process(clk) begin
  64.         if(clk'event and clk= '1') then
  65.             stado_pres <= stado_fut;
  66.         end if;
  67.     end process p_reloj;
  68. end arch_alarm;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement