Advertisement
Guest User

relogiooriginal

a guest
Oct 23rd, 2014
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 2.13 KB | None | 0 0
  1. library IEEE;
  2. use IEEE.std_logic_1164.all;
  3. -----------------------------------------
  4. entity relogio_func is
  5.     port
  6.     (
  7.         -- IN
  8.         clk,clear, B: in std_logic;
  9.                
  10.         -- OUT
  11.         s: out std_logic_vector (1 downto 0)
  12.     );
  13. end relogio_func;
  14. ---------------------------------------
  15. architecture funcionamento of relogio_func is
  16.  
  17.     type estado is (hora_atual, alarme, cronometro, data, si0,si1,si2,si3);
  18.     signal estado_atual, proximo_estado: estado;
  19.     begin
  20.        
  21.         sequencial:
  22.         process (clear, clk) is
  23.         begin
  24.             if(clear = '1') then
  25.                 estado_atual <= hora_atual;
  26.             elsif(rising_edge(clk)) then
  27.                 estado_atual <= proximo_estado;
  28.             end if;
  29.         end process;
  30.        
  31.         combinacional:
  32.         process (b,estado_atual) is
  33.         begin
  34.             case estado_atual is
  35.                 when hora_atual =>
  36.                     s<="00";
  37.                     if (b='1') then
  38.                         proximo_estado <= hora_atual;
  39.                         --s = '00';
  40.                     else
  41.                         proximo_estado <= si0;
  42.                         --s = '00';
  43.                     end if;
  44.                 when si0 =>
  45.                     if (b='1') then
  46.                         proximo_estado <= alarme;
  47.                         s <= "01";
  48.                     else
  49.                         proximo_estado <= si0;
  50.                         s <= "00";
  51.                     end if;
  52.                 when alarme =>
  53.                     s<="01";
  54.                     if (b='1') then
  55.                         proximo_estado <= alarme;
  56.                         --s='01';
  57.                     else
  58.                         proximo_estado <=si1;
  59.                         --s='01'
  60.                     end if;
  61.                 when si1 =>
  62.                     if (b='1') then
  63.                         proximo_estado <= cronometro;
  64.                         s<="10";
  65.                     else
  66.                         proximo_estado <= si1;
  67.                         s<="01";
  68.                     end if;
  69.                 when cronometro =>
  70.                     --s<="10";
  71.                     if (b='1') then
  72.                         proximo_estado <= cronometro;
  73.                         s<="10";
  74.                     else
  75.                         proximo_estado <=si2;
  76.                         s<="10";
  77.                     end if;
  78.                 when si2 =>
  79.                     if (b='1') then
  80.                         proximo_estado <= data;
  81.                         s<="11";
  82.                     else
  83.                         proximo_estado <= si2;
  84.                         s<="10";
  85.                     end if;
  86.                 when data =>
  87.                    
  88.                     if (b='1') then
  89.                         proximo_estado <= data;
  90.                         s<="11";
  91.                     else
  92.                         proximo_estado <= si3;
  93.                         s<="11";
  94.                     end if;
  95.                 when si3 =>
  96.                     if (b='1') then
  97.                         proximo_estado <= hora_atual;
  98.                         s<="00";
  99.                     else
  100.                         proximo_estado <= si3;
  101.                         s<="11";
  102.                     end if;
  103.             end case;
  104.         end process;
  105. end funcionamento;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement