Altera_Forum
Honored Contributor
13 years agoVHDL Syntax Questions - State Machine
Hello everyone, working on a class assignment and am struggling with VHDL syntax. I am getting the following error:
Error (10500): VHDL syntax error at SM_VHDL.VHD(79) near text "ELSE"; expecting ";" So I know my issues has to do with my declaration of Z or Q. This is a state-machine implementation with the following equations state equations:- Q1+ = X1*X0 + Q1*X1
- Q2+ = |X1*|X0 + Q0*|X0
- Z = Q1
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.All;
ENTITY SM_VHDL IS -- Do not modify this entity statement!
PORT(X : IN STD_LOGIC_VECTOR(1 DOWNTO 0);
RESETN,
CLOCK : IN STD_LOGIC;
Z : OUT STD_LOGIC;
Q : OUT STD_LOGIC_VECTOR(1 DOWNTO 0) );
END SM_VHDL; -- Do not modify this entity statement!
ARCHITECTURE behavior of SM_VHDL IS
TYPE STATE_TYPE IS (A, B, C);
SIGNAL state : STATE_TYPE;
BEGIN
PROCESS(CLOCK, RESETN)
BEGIN
IF RESETN = '0' THEN
state <= A;
ELSIF CLOCK'EVENT AND CLOCK = '1' THEN
CASE state IS
WHEN A =>
CASE X IS
WHEN "00" =>
state <= B;
END CASE;
CASE X IS
WHEN "01" =>
state <= A;
END CASE;
CASE X IS
WHEN "10" =>
state <= A;
END CASE;
CASE X IS
WHEN "11" =>
state <= C;
END CASE;
WHEN B =>
CASE X IS
WHEN "00" =>
state <= B;
END CASE;
CASE X IS
WHEN "01" =>
state <= A;
END CASE;
CASE X IS
WHEN "10" =>
state <= B;
END CASE;
CASE X IS
WHEN "11" =>
state <= C;
END CASE;
WHEN C =>
CASE X IS
WHEN "00" =>
state <= B;
END CASE;
CASE X IS
WHEN "01" =>
state <= A;
END CASE;
CASE X IS
WHEN "10" =>
state <= C;
END CASE;
CASE X IS
WHEN "11" =>
state <= C;
END CASE;
END CASE;
END IF;
END PROCESS;
Z <= '1' WHEN state = A ELSE '0';
Q <= "00" WHEN state = A ELSE "01" ELSE "10";
END behavior;
This is the format that was given by the way:
Z <= '1' WHEN ... ELSE ...;
Q <= "00" WHEN ... ELSE ... ELSE ... Any help getting this compiled, and furthering my understanding would be greatly appreciated.