Start for free Book a free session

Incorrect assignment operator

VHDL assigns signals with the <= operator and variables with the := operator. Sigasi reports assignments that use the wrong operator as errors. A quick fix is offered to replace the operator.

Replacing the operator is not always the right fix. A signal only takes its new value when the process suspends, while a variable changes immediately. So sometimes, changing the declaration instead is the right fix.

A signal cannot be the target of a variable assignment

A signal cannot be assigned with := (rule 34). This includes signal parameters and external names of class signal.

VHDL
architecture rtl of counter is
  signal count : unsigned(7 downto 0);
begin
  process(clk) is
  begin
    if rising_edge(clk) then
      count := count + 1; -- signal assigned with :=
      count <= count + 1;
    end if;
  end process;
end architecture;

A port cannot be the target of a variable assignment

Ports are signals as well, so a port cannot be assigned with := either (rule 35).

VHDL
entity counter is
  port(
    clk   : in  std_logic;
    ready : out std_logic
  );
end entity;

architecture rtl of counter is
begin
  process(clk) is
  begin
    if rising_edge(clk) then
      ready := '1'; -- port (= a signal) assigned with :=
      ready <= '1';
    end if;
  end process;
end architecture;

A variable cannot be the target of a signal assignment

A variable cannot be assigned with <= (rule 36). This includes variable parameters and external names of class variable.

VHDL
process(clk) is
  variable total : unsigned(7 downto 0);
begin
  if rising_edge(clk) then
    total <= total + 1; -- variable assigned with <=
    total := total + 1;
  end if;
end process;

An out or inout procedure parameter without a class is a variable parameter too.

VHDL
procedure clear(variable count : out natural; total : out natural) is
begin
  count <= 0; -- variable parameter assigned with <=
  total <= 0; -- out parameter without a class assigned with <=
  count := 0;
  total := 0;
end procedure;
VHDL
process is
begin
  <<variable .tb.dut.total : unsigned(7 downto 0)>> <= (others => '0'); -- variable assigned with <=
  <<variable .tb.dut.total : unsigned(7 downto 0)>> := (others => '0');
  wait;
end process;