Closed bpadalino closed 1 month ago
Generic types/packages with components and configurations don't work very well at the moment. Here's another example:
entity sub is
generic (
type t;
function "+" (a, b : t) return t is <> );
port (
x, y : in t;
z : out t );
end entity;
architecture test of sub is
begin
z <= x + y;
end architecture;
-------------------------------------------------------------------------------
entity top is
end entity;
architecture test of top is
component sub is
generic (
type t;
function "+" (a, b : t) return t is <> );
port (
x : in t;
z : out t );
end component;
signal xr, zr : real;
signal xi, zi : integer;
begin
u1: sub generic map ( real ) port map ( xr, zr );
-- u2: sub generic map ( integer ) port map ( xi, zi );
end architecture;
-------------------------------------------------------------------------------
configuration gentype8 of top is
for test
for u1 : sub use entity work.sub
port map ( x => x, y => x, z => z );
end for;
end for;
end configuration;
Questa also crashes on this. GHDL reports an error:
../test/regress/gentype8.vhd:45:29:error: expression associated before its type
port map ( x => x, y => x, z => z );
^
This seems wrong though, the type should come from the generic map on the instance.
This no longer crashes, but produces this error when run:
** Fatal: 0ms+0: actual length 54 does not match port B length 27
> /home/nick/nvc/test/regress/issue883.vhd:141
|
141 | b : in std_ulogic_vector(26 downto 0) ;
| ^
I haven't checked whether it's actually valid or not. The error comes from the complex.pack(complex.resize(a, DSP51_A_SIZE))
expression in the port map, I'll try to improve the reporting here a bit.
I've improved the error message so it points at the complex.pack
call. I think the problem is that function returns a value 2x the width of the port, perhaps it should be using DSP51_A_SIZE/2
? If I fix those up it runs now.
The following code:
... errors with the following:
Something very well might be wrong with my code. Riviera fails with an error:
The type of the actual in the port map does not match the "complex" type of the "~complex~1329" port.
Questa fails with a segfault. ghdl fails with an assertion failure, though I am not sure if they really support generic packages fully.