Analysis of IR2075

From: Ajayharsh Varikat <ajay_at_.....>
Date: Thu Jan 12 2006 - 17:41:21 PST
My apologies for sending this out so late.

-ajay

VHDL Issue Number:        2075       

Language_Version          VHDL-2002
Classification            Language Modeling Enhancement or Deficiency
Summary                   Arrays with numeric and enumeration index types are not closely related
Relevant_LRM_Sections     7.3.5 Type conversions
Related_Issues            
Key_Words_and_Phrases     closely related types, array types, type conversion
Authors_Name              Peter Ashenden
Authors_Phone_Number      +61 414 709 106
Authors_Fax_Number        
Authors_Email_Address     peter@ashenden.com.au
Authors_Affiliation       Ashenden Designs
Authors_Address1          
Authors_Address2          
Authors_Address3          

Current Status:           Submitted

Superseded By:

------------------------
Date Submitted:           13 October 2005
Date Analyzed:           
Author of Analysis:       Ajayharsh Varikat
Revision Number:          1
Date Last Revised:        10 January 2006

Description of Problem
----------------------

A user has the following question:
    
Given types:
     
      type SLV15To0 is array (15 downto 0) of std_logic;
      type SMRst is (RstIDE,RstIU,RSTOU, RstCF2B);
      type SMRstSLV is array (SMRst'left to SMRst'right)
                             of std_logic;
    
Given port identifier:
    
      EBD : inout SLV15To0;
    
Given signal:
    
      signal SMRCR : SMRstSLV;
    
How do I set SMRCR to the the 4 lsbs of EBD?
    
An assignment
    
      SMRCR <:   SMRstSLV(EBD(3 downto 0));
    
is not legal, since the array types are not closely related and so the
type conversion cannot be applied. The types are not closely related
since one index type is an abstract numeric type and the other is an
enumeration type.

Proposed Resolution
-------------------

Consider whether arrays with other than numeric index types can be
defined to be closely related, provided they are of the same
dimensionality and have the same element type.

VASG-ISAC Analysis & Rationale
------------------------------

Explicit type conversions are allowed only between closely related
types. Closely related types are defined in section 7.3.5 of the 
LRM. In particular, two array types are closely related if, and only
if, all of the following apply:
    - The types have the same dimensionality
    - For each index position, the index types are either the same or are
      closely related
    - The element types are the same

In the example given in this IR, the second requirement is not satisfied, which makes
it illegal.

It is useful to be able to do explicit type conversions between array
types that have the same element types, even if the index subtypes are not
closely related. The expected result of the conversion is intuitively
obvious in most cases.

Since the concept of closely related types is only used in the context
of type conversions, the easiest way to allow this kind of type conversion
is to do away with the second requirement in the current definition of
closely related types. This, however, introduces a new issue with type
conversions when the target type is an unconstrained array type. For such
target types, the bounds of the result are obtained by converting the
bounds of the operand to the corresponding index type of the target type.
However, for a target type that does not have closely related index types, 
the above rules for converting bounds are not valid.

One way to resolve this issue is to prohibit type conversion to an
unconstrained target type when the index types are not closely related.
This, however, appears to be too severe a restriction. For example,
you could have signals of the following types:

       signal src : SMRstSLV;   
       signal trgt : std_logic_vector(3 downto 0);

An assignment from src to trgt should be allowed with the appropriate
type conversion. However, the only way this can be done is to use
a target type that is an unconstrained array type.

       trgt <= std_logic_vector(src);

An alternative way to handle this situation would be to define new
rules for computing bounds. The direction of the result could be
defined to be that of the target type, and the left bound of each
index position of the result could be the left bound of the corresponding
target index type. The right bound of each index subtype could then
be computed such that the size along each dimension of the result is the
same as that of the operand.


VASG-ISAC Recommendation for IEEE Std 1076-2002
-----------------------------------------------
No change.


VASG-ISAC Recommendation for Future Revisions
---------------------------------------------

Implement the suggestions from the Analysis section.
Received on Thu Jan 12 17:41:36 2006

This archive was generated by hypermail 2.1.8 : Thu Jan 12 2006 - 17:41:37 PST