[VHDL]Distributore di bibite
devo descrivere e simulare una macchina a stati finiti che prevede l'inserimento di monete da 10,20 e 50 cent per acquistare una lattina del costo di 50 cent.Devo gestire oltre all'uscita della lattina anche il resto.
Ecco il mio codice:
non posto anche il test bench perché dovrebbe essere certamente corretto.
In questa parte invece il ghdl mi rileva degli errori:

Ecco il mio codice:
- Codice: Seleziona tutto
entity MSFresto is
Port ( monete : in STD_LOGIC_VECTOR (2 downto 0);
clk : in STD_LOGIC;
reset : in STD_LOGIC;
resto : out STD_LOGIC_vector(2 downto 0);
lattina : out STD_LOGIC);
end MSFresto;
architecture behavioral of MSFresto is
type stato is (s0,s10,s20,s30,s40,s50,s60,s70,s80,s90);
signal SC, SF : stato;
begin
process(clk,reset)
begin
if reset='1' then SC<=s0;
elsif clk'event and clk='1' then SC<=SF;
else null;
end if;
end process;
process(SC)
begin
case SC is
when s0 => lattina<='0',
=> resto<='000';
when s10 => lattina<='0',
=> resto<='000';
when s20 => lattina<='0',
=> resto<='000';
when s30 => lattina<='0',
=> resto<='000';
when s40 => lattina<='0',
=> resto<='000';
when s50 => lattina<='1',
=> resto<='000';
when s60 => lattina<='1',
=> resto<='001';
when s70 => lattina<='1',
=> resto<='010';
when s80 => lattina<='1',
=> resto<='011';
when s90 => lattina<='1',
=> resto<='100';
when others => null;
end case;
end process;
process(SC, monete)
begin
case SC is
when s0 => if monete="000" then SF<=S0;
elsif monete="001" then SF<=s10;
elsif monete="010" then SF<=s20;
elsif monete="100" then SF<=s50;
else null;
end if;
when s10 => if monete="000" then SF<=S10;
elsif monete="001" then SF<=s20;
elsif monete="010" then SF<=s30;
elsif monete="100" then SF<=s60;
else null;
end if;
when s20 => if monete="000" then SF<=S20;
elsif monete="001" then SF<=s30;
elsif monete="010" then SF<=s40;
elsif monete="100" then SF<=s70;
else null;
end if;
when s30 => if monete="000" then SF<=S30;
elsif monete="001" then SF<=s40;
elsif monete="010" then SF<=s50;
elsif monete="100" then SF<=s80;
else null;
end if;
when s40 => if monete="000" then SF<=S40;
elsif monete="001" then SF<=s50;
elsif monete="010" then SF<=s60;
elsif monete="100" then SF<=s90;
else null;
end if;
when s50 => if monete="000" then SF<=s0;
elsif monete="001" then SF<=s10;
elsif monete="010" then SF<=s20;
elsif monete="100" then SF<=s50;
else null;
end if;
when s60 => if monete="000" then SF<=s0;
elsif monete="001" then SF<=s10;
elsif monete="010" then SF<=s20;
elsif monete="100" then SF<=s50;
else null;
end if;
when s70 => if monete="000" then SF<=S0;
elsif monete="001" then SF<=s10;
elsif monete="010" then SF<=s20;
elsif monete="100" then SF<=s50;
else null;
end if;
when s80 => if monete="000" then SF<=S0;
elsif monete="001" then SF<=s10;
elsif monete="010" then SF<=s20;
elsif monete="100" then SF<=s50;
else null;
end if;
when s90 => if monete="000" then SF<=s0;
elsif monete="001" then SF<=s10;
elsif monete="010" then SF<=s20;
elsif monete="100" then SF<=s50;
else null;
end if;
when others => null;
end case;
end process;
end behavioral;
non posto anche il test bench perché dovrebbe essere certamente corretto.
In questa parte invece il ghdl mi rileva degli errori:
- Codice: Seleziona tutto
MSFresto.vhdl:30:18: unexpected token '=>' in a primary
MSFresto.vhdl:30:18: ';' is expected instead of '=>'
/usr/lib/ghdl/bin/ghdl: compilation error
error: cannot find entity or configuration msfresto
/usr/lib/ghdl/bin/ghdl: compilation error
error: cannot find entity or configuration tb_msfresto
/usr/lib/ghdl/bin/ghdl: compilation error
/usr/lib/ghdl/bin/ghdl: file 'tb_msfresto' does not exists
/usr/lib/ghdl/bin/ghdl: Please elaborate your design.
GTKWave Analyzer v3.3.24 (w)1999-2011 BSI
Error opening .vcd file 'out.vcd'.