cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
rakrav15
Newbie
Newbie
207 Views
Registered: ‎01-18-2021

VHDL code error. Help me debug, Im not familiar with VHDL.

entity clothes_washer is
port(
--inputs
clk: in std_logic;       --Clock 50Mhz
start_wash: std_logic;   --SW17
heat_dry: std_logic;     --SW14
Door_open: in std_logic; --SW0
reset: in std_logic;     --KEY3
fifty_cent: in std_logic;  --SW15
twenty_cent: in std_logic;  --SW16

--outputs
door_lock: out std_logic;  --LED0
water_pump: out std_logic; --LED1
soap: out std_logic; --LED2
rotate_drum:out std_logic; --LED3
drain: out std_logic; --LED4
heat: out std_logic; --LED5
air_ventilate: out std_logic; --LED6
check: out std_logic; --LEDG7, to proof the ongoing process

);
end Clothes_washer

architecture Behavioral of Clothes_washer is
TYPE state_type IS (zero,one,two,three,four,five,six,seven,eight,nine);
SIGNAL state: state_type:=zero;

begin
next_state_logic: process(clk)
begin
if(clk' event and clk='1') then
case state is

when zero=>
-----------------------Washer------------------
if(fifty_cent = '1' and twenty_cent='0') then
	if(door_open = '0') then
		check<='1';
		if (start_wash='1' and heat_dry= '0' ) then
			state<= one;
		else
			state<= zero;
		end if;
	else
		state<=zero;
	end if;

-----------------------Dryer------------------
if(fifty_cent = '0' and twenty_cent='1') then
	if(door_open = '0') then
		if (start_wash='0' and heat_dry= '1' ) then
			state<= eight;
		else
			state<= zero;
		end if;
	else
		state<=zero;
	end if;
----------------------------------------------
---STATES-----
when one =>
state<=two;

when two =>
state<=three;

when three =>
state<=four;

when four =>
state<=five;

when five =>
state<=six;

when six =>
state<=seven;

when seven =>
state<=zero;

when eight =>
state<=nine;

when nine =>
state<=zero;

end case;
end if;
end process;

------------------------------------------------
--------OUTPUT----------

output_logic:process(reset,state,clk)
begin
if reset = '0' then
case state is

when zero=>
door_lock<= '0';
water_pump<='0';
soap<='0';
rotate_drum<='0';
drain<='0';
heat<='0';
air_ventilate<='0';

when one=>
door_lock<= '1';
water_pump<='1';
soap<='1';
rotate_drum<='0';
drain<='0';
heat<='0';
air_ventilate<='0';

when two=>
door_lock<= '1';
water_pump<='0';
soap<='0';
rotate_drum<='1';
drain<='0';
heat<='0';
air_ventilate<='0';

when three=>
door_lock<= '1';
water_pump<='0';
soap<='0';
rotate_drum<='0';
drain<='1';
heat<='0';
air_ventilate<='0';

when four=>
door_lock<= '1';
water_pump<='1';
soap<='0';
rotate_drum<='0';
drain<='0';
heat<='0';
air_ventilate<='0';

when five=>
door_lock<= '1';
water_pump<='0';
soap<='0';
rotate_drum<='1';
drain<='0';
heat<='0';
air_ventilate<='0';

when six=>
door_lock<= '1';
water_pump<='0';
soap<='0';
rotate_drum<='0';
drain<='1';
heat<='0';
air_ventilate<='0';

when seven=>
door_lock<= '1';
water_pump<='0';
soap<='0';
rotate_drum<='0';
drain<='1';
heat<='0';
air_ventilate<='0';

when eight=>
door_lock<= '1';
water_pump<='0';
soap<='0';
rotate_drum<='1';
drain<='0';
heat<='0';
air_ventilate<='0';

when nine=>
door_lock<= '1';
water_pump<='0';
soap<='0';
rotate_drum<='1';
drain<='0';
heat<='1';
air_ventilate<='1';

end case;
elsif reset='1' then
door_lock<= '1';
water_pump<='0';
soap<='0';
rotate_drum<='0';
drain<='0';
heat<='0';
air_ventilate<='0';

end if;
end process;

end bahavioral;
	
)
Tags (2)
errorrr.png
0 Kudos
Reply
2 Replies
samamherb
Visitor
Visitor
124 Views
Registered: ‎06-11-2018

Hi 

I would strongly suggest that you read up on VHDL 

http://freerangefactory.org/pdf/df344hdh4h8kjfh3500ft2/free_range_vhdl.pdf

However, the syntax error of the code corrected but without more detail of your project, I can not debug it.

library ieee;
use ieee.std_logic_1164.all;
--- library added for std_logic signal type
entity clothes_washer is
port(
--inputs
clk: in std_logic; --Clock 50Mhz
start_wash: std_logic; --SW17
heat_dry: std_logic; --SW14
Door_open: in std_logic; --SW0
reset: in std_logic; --KEY3
fifty_cent: in std_logic; --SW15
twenty_cent: in std_logic; --SW16

--outputs
door_lock: out std_logic; --LED0
water_pump: out std_logic; --LED1
soap: out std_logic; --LED2
rotate_drum:out std_logic; --LED3
drain: out std_logic; --LED4
heat: out std_logic; --LED5
air_ventilate: out std_logic; --LED6
check: out std_logic --LEDG7, to proof the ongoing process --- syntax mistake removed (;)

);
end Clothes_washer; --- Syntax mistake (; added)

architecture Behavioral of Clothes_washer is
TYPE state_type IS (zero,one,two,three,four,five,six,seven,eight,nine);
SIGNAL state: state_type:=zero;

begin
next_state_logic: process(clk)
begin
if(clk' event and clk='1') then
case state is

when zero=>
-----------------------Washer------------------
if(fifty_cent = '1' and twenty_cent='0') then
if(door_open = '0') then
check<='1';
if (start_wash='1' and heat_dry= '0' ) then
state<= one;
else
state<= zero;
end if;
else
state<=zero;
end if;
end if; --- "end if" added
-----------------------Dryer------------------
if(fifty_cent = '0' and twenty_cent='1') then
if(door_open = '0') then
if (start_wash='0' and heat_dry= '1' ) then
state<= eight;
else
state<= zero;
end if;
else
state<=zero;
end if;
end if; --- "end if" added
----------------------------------------------
when one =>
state<=two;

when two =>
state<=three;

when three =>
state<=four;

when four =>
state<=five;

when five =>
state<=six;

when six =>
state<=seven;

when seven =>
state<=zero;

when eight =>
state<=nine;

when nine =>
state<=zero;
end case;
end if;
end process;

------------------------------------------------
--------OUTPUT----------

output_logic:process(reset,state,clk)
begin
if reset = '0' then
case state is

when zero=>
door_lock<= '0';
water_pump<='0';
soap<='0';
rotate_drum<='0';
drain<='0';
heat<='0';
air_ventilate<='0';

when one=>
door_lock<= '1';
water_pump<='1';
soap<='1';
rotate_drum<='0';
drain<='0';
heat<='0';
air_ventilate<='0';

when two=>
door_lock<= '1';
water_pump<='0';
soap<='0';
rotate_drum<='1';
drain<='0';
heat<='0';
air_ventilate<='0';

when three=>
door_lock<= '1';
water_pump<='0';
soap<='0';
rotate_drum<='0';
drain<='1';
heat<='0';
air_ventilate<='0';

when four=>
door_lock<= '1';
water_pump<='1';
soap<='0';
rotate_drum<='0';
drain<='0';
heat<='0';
air_ventilate<='0';

when five=>
door_lock<= '1';
water_pump<='0';
soap<='0';
rotate_drum<='1';
drain<='0';
heat<='0';
air_ventilate<='0';

when six=>
door_lock<= '1';
water_pump<='0';
soap<='0';
rotate_drum<='0';
drain<='1';
heat<='0';
air_ventilate<='0';

when seven=>
door_lock<= '1';
water_pump<='0';
soap<='0';
rotate_drum<='0';
drain<='1';
heat<='0';
air_ventilate<='0';

when eight=>
door_lock<= '1';
water_pump<='0';
soap<='0';
rotate_drum<='1';
drain<='0';
heat<='0';
air_ventilate<='0';

when nine=>
door_lock<= '1';
water_pump<='0';
soap<='0';
rotate_drum<='1';
drain<='0';
heat<='1';
air_ventilate<='1';

end case;
elsif reset='1' then
door_lock<= '1';
water_pump<='0';
soap<='0';
rotate_drum<='0';
drain<='0';
heat<='0';
air_ventilate<='0';

end if;
end process;

end architecture Behavioral; --- Label matched

I'm a freelance VHDL developer and HDL designer.
0 Kudos
Reply
joancab
Scholar
Scholar
118 Views
Registered: ‎05-11-2015

First, you are using Quartus II, this is a Xilinx forum. 

Second, the error message is clear "syntax error at line 22". You should look at that instead of copy pasting your whole thing.

Third, syntax is the very first thing one learns about a language. You will get better results from your time if you revise the basics of VHDL instead of coding, failing and asking someone to fix your mistakes. "If I had 4 hours to cut a tree I would spend 3 sharpening the axe". 

0 Kudos
Reply