1
votes

I'm new to vhdl, and I have simple code to simulate the slt operation; however, I am getting the following error: Error (10500): VHDL syntax error at SetLessThan.vhd(14) near text "if"; expecting "end", or "(", or an identifier ("if" is a reserved keyword), or a concurrent statement

Can anyone help? (Code pasted below) I tried placing ()'s around a < b but that gave me 2 additional errors.

library IEEE;
use IEEE.STD_LOGIC_1164.all;

entity SetLessThan is
     port(
         a : in std_logic_vector(7 downto 0);
         b : in std_logic_vector(7 downto 0);
         cout : out std_logic_vector(7 downto 0)
         );
end SetLessThan;

architecture dataflow of SetLessThan is
begin
            if a < b then
                cout <= '00000001';
            else
                cout <= '00000000';
            end if;
end dataflow;
2
Try moving the if block inside a process statement. - godel9

2 Answers

1
votes

You're trying to use a sequential statement in a place appropriate for a concurrent statement.

You can either move your if-then-else inside a process statement or re-write it as a conditional waveform (signal) assignment statement.

Then you'll find at one more category of errors, a string literal is delimited by a pair of double quotes instead of instead of single quotes.

Demonstrating the two forms, as well a double quotes:

architecture dataflow of SetLessThan is
begin
process (a,b)
    begin
        if a < b then
            cout <= "00000001";
        else
            cout <= "00000000";
        end if;
    end process;
end dataflow;

architecture cond_waveform of SetLessThan is
begin
    cout <= "00000001" when a < b else
            "00000000";
end architecture;

Conditional signal assignments

The conditional signal assignment represents a process statement in which the signal transform is an if statement.

 conditional_signal_assignment ::=
    target  <=  options conditional_waveforms ;

 conditional_waveforms ::=
      { waveform when condition else }
       waveform [ when condition ]

(The distinction being it is a concurrent statement representing a process)

0
votes

You aren't allowed to use if..then..else in the architecture body raw. You have to include them in a process.

Alternatively you can use a different syntax with a concurrent signal assignment, which is known as a conditional signal assignment. In your case, it would become:

cout <= "0000001" when a < b else "00000000";