0
votes

I currently have a bug between two version of a VHDL simulator

my code (simple version to trigger the error)

library ieee;
use ieee.std_logic_1164.all;

entity test is
end;

architecture test of test is
    constant mpc_ibif_data_width          : integer := 16;
    subtype  t_mpc_ibif_data              is std_logic_vector (mpc_ibif_data_width - 1 downto 0);

    type t_device_2_mpc_ibif is
      record
        rd_data     : t_mpc_ibif_data;  --
        rd_data_en  : std_logic;        -- '1': rd_data must be driven to the CPU
        berr_n      : std_logic;        --
    end record;

    type  t_device_2_mpc_ibif_array    is array (natural range <>) of t_device_2_mpc_ibif;
    signal flash_cnt_2_mpc_o : t_device_2_mpc_ibif;
begin
    process 
    begin
        wait for 10 ns;
        assert flash_cnt_2_mpc_o.rd_data = t_device_2_mpc_ibif.rd_data'(others => '0') report"flash_cnt_2_mpc_o.rd_data should have been deasserted" severity error;
        wait;
    end process;
end;

In the first version the following is legal

assert flash_cnt_2_mpc_o.rd_data = t_device_2_mpc_ibif.rd_data'(others => '0') report"flash_cnt_2_mpc_o.rd_data should have been deasserted" severity error;

However in a new version, I get a "Type Error" on the same line. Specifically on

t_device_2_mpc_ibif.rd_data'(others => '0') 

I created this as a bug at vendor who tells me to use below code:

assert flash_cnt_2_mpc_o.rd_data = t_mpc_ibif_data'(others => '0') report"flash_cnt_2_mpc_o.rd_data should have been deasserted" severity error;

based on these arguments

In this context the type is expected not its selection.


Here is what I do not understand and want an answer to:

To my understanding there are types and subtypes. subtypes inherit from types

So when you create a signal

signal NameOfSignal : std_logic_vector(1 downto 0)

This signal now inherit all from std_logic_vector plus its contrained IE it's a "subtype" of the type std_logic_vector.

And regardless of the signal is in a record or not should not change this fact.

I asked this and got the following answer:

t_device_2_mpc_ibif.rd_data It is not type_name neither subtype_name but selected name (element name of record).

But in my world this shouldn't matter since the signal(element) inherit all of the types methods.

Please correct me because I clearly misunderstand something

EDIT: I used VHDL2008

Regards Anders

2
wow your fast, you manged to edit the post before me - Ephreal

2 Answers

2
votes

Your problem code:

t_device_2_mpc_ibif.rd_data'(others => '0') 

In this line, you are trying to qualify (others => '0') as type t_device_2_mpc_ibif.rd_data. The problem, and what tech support have said, is that rd_data isn't a type, so you can't qualify anything as it. There is no syntax for "qualify this as the same type as the supplied signal".

Examples:

signal foo : std_logic_vector (1 downto 0);
subtype MyType is std_logic_vector (1 downto 0);
signal bar : MyType;

...

-- Simple assignment, OK
foo <= "00";

-- Qualify the literal "00" as a type std_logic_vector, OK
foo <= std_logic_vector'("00");

-- Simple assignment; subtypes have automatic conversion to/from the parent type, OK
bar <= "00";

-- Qualify the literal "00" as type 'foo', not OK, since 'foo' isn't a type.
bar <= foo'("00");

-- Qualify the literal "00" as type 'MyType', OK.
bar <= MyType'("00");

-- Qualify the literal "00" as type 'bar', not OK, since 'bar' is not a type.
bar <= bar'("00");

This issue has nothing to do with sub types or records. If your original code worked in an older tool version, this was a bug.

1
votes

Here is what I do not understand and want an answer to:

To my understanding there are types and subtypes. subtypes inherit from types

So when you create a signal

    signal NameOfSignal : std_logic_vector(1 downto 0)

This signal now inherit all from std_logic_vector plus its contrained IE it's a "subtype" of the type std_logic_vector.

And regardless of the signal is in a record or not should not change this fact.

I asked this and got the following answer:

t_device_2_mpc_ibif.rd_data It is not type_name neither subtype_name but selected name (element name of record).

But in my world this shouldn't matter since the signal(element) inherit all of the types methods.

Please correct me because I clearly misunderstand something

First off the only place you'll find mention on inheritance in IEEE Std 1076-2008 (the LRM) is in reference to VHPI which doesn't apply here. Further the only other place you find inherit is in a description of attribute specifications (7.2).

There's a basic issue of trying to superimpose language and concepts external to the LRM which is a formal specification of the VHDL language.

As your vendor notes and is supported by the LRM (5.3.3 Record types) the identifier rd_data is distinct from the subtype indication of the element declaration.

You could also note that an element declaration is distinct from a subtype declaration (6.3).

9.3.5 Qualified expressions

A qualified expression is a basic operation (see 5.1) that is used to explicitly state the type, and possibly the subtype, of an operand that is an expression or an aggregate.

qualified_expression ::=
      type_mark ' ( expression )
    | type_mark ' aggregate

The operand shall have the same type as the base type of the type mark. The value of a qualified expression is the value of the operand. The evaluation of a qualified expression evaluates the operand and converts it to the subtype denoted by the type mark.

So what can be used in a qualified expression is determined by what is acceptable as a type_mark.

And that get's us to 6.3 Subtype declarations:

type_mark ::=
      type_name
    | subtype_name

And the accompanying text:

A type mark denotes a type or a subtype. If a type mark is the name of a type, the type mark denotes this type and also the corresponding unconstrained subtype. The base type of a type mark is, by definition, the base type of the type or subtype denoted by the type mark.

If we look at subtype_declaration we see that the name of a subtype is an identifier:

subtype_declaration ::=
    subtype identifier is subtype_indication ;

If we look in 6.2 Type declarations:

type_declaration ::=
      full_type_declaration
    | incomplete_type_declaration

full_type_declaration ::=
    type identifier is type_definition ;

type_definition ::=
      scalar_type_definition
    | composite_type_definition
    | access_type_definition
    | file_type_definition
    | protected_type_definition

We see that a declared type name is an identifier.

And if we look in 15. Lexical elements, 15.4 identifiers we find that an identifier is a lexical element and a selected name doesn't qualify, being comprised of at least three lexical elements (See 8.3 Selected names).

You'd also find by looking through 16.2 Predefined attributes there are no predefined attributes that will aid in determining the type of a record element.

Simply put types or subtypes aren't class. There are entity classes in VHDL used to describe declared names in attributes (see 7.2 Attribute specifications):

entity_specification ::=
    entity_name_list : entity_class

entity_class ::=
      entity
    | architecture
    | configuration
    | procedure
    | function
    | package
    | type
    | subtype
    | constant
    | signal
    | variable
    | component
    | label
    | literal
    | units
    | group
    | file
    | property
    | sequence

and there are object classes (See 6.4.2 Object declarations):

object_declaration ::=
      constant_declaration
    | signal_declaration
    | variable_declaration
    | file_declaration

Of which only signals exhibit OOP characteristics, depending on explicitly or implicitly specified sensitivity lists (for which there are formally defined syntax and semantics, and understanding might require a thorough read of the LRM).

In short don't try to superimpose concepts garnered elsewhere on VHDL.

The difference between -2008 and previous revisions of the LRM are mentioned in Peter Ashenden and Jim Lewis's book 'VHDL-2008 Just the New Stuff' section 9.3 Qualified Expression Subtype, and as scary_jeff notes isn't applicable here. This is about type and subtype names in a type mark.