--------------------------------------------------------------------- -- whoareyou.vhd -- Soluzione del Tema di Esame del 11 giugno 2002 -- (Architetture di Sistemi Integrati/ Progetto di sistemi elettronici) --------------------------------------------------------------------- -- NOTA: Questa soluzione e' stata mappata su dispositivo -- FLEX6000 EPF601ATC100-1 -- Frequenza max 35.21 MHZ -- Logic cells 107 FFs 8 library IEEE; use IEEE.std_logic_1164.all; use IEEE.std_logic_arith.all; use IEEE.std_logic_unsigned.all; entity Whoareyou is port( clk,reset : in std_logic; orario : in unsigned(4 downto 0); codicein : in std_logic_vector(7 downto 0); codiceout : in std_logic_vector(7 downto 0); appartienecorso : in std_logic; eslibera : in std_logic; apri : out std_logic ); end Whoareyou; architecture b of Whoareyou is type stati is (night,empty,ready,apri_night,apri_ready,es_libera); signal cs,ns : stati; signal t,nt : unsigned(4 downto 0); begin -- Parte sequenziale della FSM process(clk,reset) begin if reset='1' then cs <= night; t <= conv_unsigned(0,5); elsif clk'event and clk='1' then cs <= ns; t <= nt; end if; end process; -- Parte combinatoria della FSM process(cs,orario,codicein,codiceout,eslibera,appartienecorso,t) begin case cs is when night => apri <= '0'; nt <= t; -- O meglio 0 !! if (orario=conv_unsigned(9,5)) then ns <= empty; elsif (codicein(7 downto 6)="11") then ns <= apri_night; else ns <= night; end if; when apri_night => apri <= '1'; nt <= t; -- O meglio 0 !! ns <= night; when empty => apri <= '0'; if orario = conv_unsigned(19,5) then ns <= night; nt <= t; -- O meglio 0!! elsif (codicein(7 downto 6)="10") then ns <= apri_ready; nt <= t+conv_unsigned(1,5); else ns <= empty; nt <= t; -- O meglio 0!! end if; when ready => apri <='0'; if (codiceout(7 downto 6) = "10") then ns <= ready; nt <= t - conv_unsigned(1,5); elsif eslibera='1' then ns <= es_libera; nt <= t; elsif (codicein(7 downto 6)="10") then ns <= apri_ready; nt <= t+conv_unsigned(1,5); elsif (codicein(7 downto 6)="01") then ns <= apri_ready; nt <= t; elsif (codicein(7 downto 6)="00") and (codicein/="00000000") and (appartienecorso='1') then ns <= apri_ready; nt <= t; -- Se e' uscito l'ultimo tecnico ritorno nello stato labvuoto. elsif t=conv_unsigned(0,5) then ns <= empty; nt <= t; -- O meglio 0 !! end if; when apri_ready => apri <= '1'; nt <= t; ns <= ready; when es_libera => apri <= '1'; if eslibera='0' then ns <= ready; nt <= t; elsif codiceout="10" then ns <= es_libera; nt <= t - conv_unsigned(1,5); elsif (codicein(7 downto 6)="10") then ns <= es_libera; nt <= t+conv_unsigned(1,5); end if; when others => apri <= '0'; ns <= empty; nt <= t; end case; end process; end b;