ghdl / ghdl-yosys-plugin

VHDL synthesis (based on ghdl)
GNU General Public License v3.0
304 stars 31 forks source link

Function with two input arguments doesn't synthesize #58

Closed marph91 closed 4 years ago

marph91 commented 4 years ago

Synthesizing the following example with ghdl --synth function_test seems to produce valid output. However, yosys -m ghdl -p 'ghdl function_test; synth_ice40' fails with:

-- Running command `ghdl function_test; synth_ice40' --

1. Executing GHDL.
Importing module function_test.
ERROR: Assert `n.id != 0' failed in src/ghdl.cc:58.
library ieee;
  use ieee.std_logic_1164.all;

entity function_test is
  generic (
    g : std_logic := '1'
  );
  port (
    i : in std_logic_vector(7 downto 0);
    o : out std_logic_vector(7 downto 0)
  );
end function_test;

architecture rtl of function_test is

  function assign_value(value : in std_logic_vector(7 downto 0);
                        invert : in std_logic)
                        return std_logic_vector is
    variable slv_out : std_logic_vector(7 downto 0);
  begin
    if invert = '0' then
      slv_out := value;
    elsif invert = '1' then
      slv_out := not value;
    end if;
    return slv_out;
  end;

begin
  o <= assign_value(i, g);
end rtl;
tgingold commented 4 years ago

It's due to the local variable. Will be fixed by a clean-up pass.

tgingold commented 4 years ago

Should be fixed.