Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
18 years ago

Syntax Error

can anyone tell me whats wrong with this code? :confused:

My device is

Family : Cyclone

Package : FBGA

Pin Out : 256

Speed Grade : 6

Name : EP1C12F256C6

My code:

-----------------------------------------------------

library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity allT is
	port(g, y, r : buffer std_logic(1 to 4);
	     clk     : in std_logic);
end allT;
architecture behav of allT is
	
	signal d, q : std_logic;
	signal gL   : std_logic_vector(1 to 16);
	signal yL   : std_logic_vector(1 to 4);
	
	component delay
		port(D, clk : in std_logic;
			 Q      : out std_logic);
	end component;
	
begin
	process(r, clk, x)
		begin
		if (clk'event AND clk = '1') then
		d <= '1';
		
		case r is 
			when "0111" =>
				g <= "0001";
			when others =>
				null;
		end case;
		
		for gL in 1 to 15 loop
			greenL : delay port map (d, clk, q);
			gL <= gL + 1;	
		end loop;
		
		case r is 
			when "0111" =>
				g <= "0000";
			when others =>
				null;
		end case;
					
		case r is 
			when "0111" =>
				y <= "1000";
			when others =>
				null;
		end case;
	
		for yL in 1 to 3 loop
			yellowL : delay port map (d, clk, q);
			yL <= yL + 1;
		end loop;
		
		case r is		
			when "0111" =>
				y <= "0000";
			when others =>
				null;
		end case;
		
		case r is
			when "0111" =>
				r <= "1011";
			when others =>
				null;
		end case;
		
		end if;
	end process;
end behav;

-------------------------------------------------------

When i compile this code, i get 4 errors.

Error (10500): VHDL syntax error at allT.vhd(35) near text "port"; expecting "(", or "'", or "."

Error (10500): VHDL syntax error at allT.vhd(35) near text ";"; expecting ":=", or "<="

Error (10500): VHDL syntax error at allT.vhd(54) near text "port"; expecting "(", or "'", or "."

Error (10500): VHDL syntax error at allT.vhd(54) near text ";"; expecting ":=", or "<="

--------------------------------------------------------

i'm new member here, please tell me if i make an illegal act or something wrong in this forum..thanks..:D

15 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    thanks again frank..

    in your code..

    CASE state IS
    WHEN S1 =>
      timer <= conv_unsigned(10,4);
    WHEN S_WAIT =>
      IF timer = 0 THEN
        state <= S_UP;
      ELSE
        timer <= timer - 1;
      END IF;
    WHEN S_UP =>

    what kind of signal is for 'timer'?
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hello,

    timer is unsigned(3 downto 0) here, for this reason conv_unsigned is used to assign an integer value. There are other options, too. Obviously, the size has to be adjusted according to your requirements.

    Regards,

    Frank
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    frank..finally i've manage to finish designing my traffic light..thanks for ur advice..but the code is really mess..:p

    i'll take my time to clear it..:D

    library ieee;
    use ieee.std_logic_1164.all;
    use ieee.std_logic_unsigned.all;
    entity allTnew is
    	port
    		(clk	 : in     std_logic;
    		 input   : buffer std_logic_vector(1 to 4);
    		 g, y, r : out    std_logic_vector(1 to 4);
    		 reset	 : in     std_logic);
    end entity;
    architecture behavT of allTnew is
    	signal timer : std_logic_vector(3 downto 0);
    	type state_type is (s1, s2, s4, s5, s7, s8);
    	signal state : state_type;
    begin
    	process (clk, reset, input)
    	begin
    		if reset = '1' then
    			state <= s1;
    			input <= "0111";
    		elsif (clk'event AND clk = '1') then
    			timer <= (others => '0');
    			case state is
    			
    				when s1 =>
    					if input = "0111" then
    						g <= "1000";
    						y <= "0000";
    						r <= input;
    						state <= s2;
    					elsif input = "1011" then
    						g <= "0100";
    						state <= s2;
    					elsif input = "1101" then
    						g <= "0010";
    						state <= s2;
    					elsif input = "1110" then
    						g <= "0001";
    						state <= s2;
    					end if;
    					
    				when s2 =>
    					if timer = "0100" then
    						state <= s4;
    						g <= "0000";
    					else
    						timer <= timer + 1;
    					end if;			
    					
    				when s4 =>
    					if input = "0111" then
    						y <= "1000";
    						state <= s5;						
    					elsif input = "1011" then
    						y <= "0100";
    						state <= s5;						
    					elsif input = "1101" then
    						y <= "0010";
    						state <= s5;						
    					elsif input = "1110" then
    						y <= "0001";
    						state <= s5;						
    					end if;
    					
    				when s5 =>
    					if timer = "0010" then
    						state <= s7;
    						y <= "0000";
    					else
    						timer <= timer + 1;
    					end if;													
    				
    				when s7 =>
    					if input = "0111" then
    						r <= "1011";	
    						state <= s8;					
    					elsif input = "1011" then
    						r <= "1101";
    						state <= s8;				
    					elsif input = "1101" then
    						r <= "1110";	
    						state <= s8;					
    					elsif input = "1110" then
    						r <= "0111";	
    						state <= s8;					
    					end if;	
    				
    				when s8 =>
    					if input = "0111" then
    						input <= "1011";	
    						state <= s1;					
    					elsif input = "1011" then
    						input <= "1101";	
    						state <= s1;				
    					elsif input = "1101" then
    						input <= "1110";	
    						state <= s1;					
    					elsif input = "1110" then
    						input <= "0111";
    						state <= s1;					
    					end if;
    					
    				end case;
    					
    		end if;
    				
    	end process;
    end behavT;

    now its time to make the report for my assigment..:D
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi.. i'm wondering if you can explain some of your codes to me.. especially this part..:

    when s1 =>

    if input = "0111" then

    g <= "1000";

    y <= "0000";

    r <= input;

    state <= s2;

    elsif input = "1011" then

    g <= "0100";

    state <= s2;

    elsif input = "1101" then

    g <= "0010";

    state <= s2;

    elsif input = "1110" then

    g <= "0001";

    state <= s2;

    end if;

    when s2 =>

    if timer = "0100" then

    state <= s4;

    g <= "0000";

    else

    timer <= timer + 1;

    end if;

    when s4 =>

    if input = "0111" then

    y <= "1000";

    state <= s5;

    elsif input = "1011" then

    y <= "0100";

    state <= s5;

    elsif input = "1101" then

    y <= "0010";

    state <= s5;

    elsif input = "1110" then

    y <= "0001";

    state <= s5;

    end if;

    when s5 =>

    if timer = "0010" then

    state <= s7;

    y <= "0000";

    else

    timer <= timer + 1;

    end if;

    when s7 =>

    if input = "0111" then

    r <= "1011";

    state <= s8;

    elsif input = "1011" then

    r <= "1101";

    state <= s8;

    elsif input = "1101" then

    r <= "1110";

    state <= s8;

    elsif input = "1110" then

    r <= "0111";

    state <= s8;

    end if;

    when s8 =>

    if input = "0111" then

    input <= "1011";

    state <= s1;

    elsif input = "1011" then

    input <= "1101";

    state <= s1;

    elsif input = "1101" then

    input <= "1110";

    state <= s1;

    elsif input = "1110" then

    input <= "0111";

    state <= s1;

    end if;

    end case;
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    What is it that you don't understand in this code?

    Take a good VHDL book and look for the case and if statements.