Skip to content

Implicit operators for incomplete types.

I have a problem with interpreting the usage of implicit operators for incomplete types. It is best for me to explain my problem with a use case. Given the example below:

library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;

entity top is
end;
architecture top of top is

    procedure foo_temp
        generic(
            type t is array (natural range <>) of std_logic;
            a,b : t;
            ----function "<" (a,b : t) return boolean is <>;
        ) is
    begin
        report boolean'image( a < b );
    end;

begin
    process
        constant a_0 : std_ulogic_vector := "LLL";
        constant a_1 : std_ulogic_vector := "111";
        constant c_0 : unsigned          := "LLL";
        constant c_1 : unsigned          := "111";
    begin
        wait for 1 ps;
        foo_temp generic map (std_ulogic_vector, a_0, a_1);
        foo_temp generic map (unsigned,          c_0, c_1);     
        wait;
    end process;
end;

What is the expected output?

NOTE: false
NOTE: false

or

NOTE: false
NOTE: true

Should the implicit "<" operator for array incomplete type t should be treated like:

  • standard "<" operator for arrays - which returns false (because character 'L'>'1')
  • ieee.numeric_std."<" - which returns true (there are TO_01 conversions in numeric_std implementation)

If the second option is correct, maybe the LRM should point out that those implicit operators are like implicit generic subprograms following the declaration of implicit type (as the commented line in the example above).

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information