home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / vhdl / 630 < prev    next >
Encoding:
Text File  |  1993-01-07  |  4.4 KB  |  99 lines

  1. Newsgroups: comp.lang.vhdl
  2. Path: sparky!uunet!clsi!daniel
  3. From: daniel@clsi.COM (Daniel S. Barclay)
  4. Subject: Re: Overload Resolution (Was: type conversion and configuration)
  5. In-Reply-To: beihl@ncrcol.ColumbiaSC.NCR.COM's message of Tue, 05 Jan 93 15:12:54 GMT
  6. Message-ID: <DANIEL.93Jan6115749@algol.clsi.COM>
  7. Sender: usenet@clsi.COM
  8. Organization: CAD Language Systems Inc.
  9. References: <1992Dec30.130712.5464@phcomgw.seri.philips.nl>
  10.     <1993Jan4.225957.26359@viewlogic.com>
  11.     <1993Jan05.101254.26831@ncrcae.ColumbiaSC.NCR.COM>
  12. Date: 6 Jan 93 11:57:49
  13. Lines: 84
  14.  
  15. beihl@ncrcol.ColumbiaSC.NCR.COM (Gary Beihl) writes:
  16.  
  17. > In article <1993Jan4.225957.26359@viewlogic.com> sunder@viewlogic.com (Sunder Singhani) writes:
  18. > >
  19. > >The above IS ambiguous. Explanation follows -
  20. > IMHO, there is NO ambiguity.  Sufficient information is available.
  21. >  
  22. > >-- 4    FUNCTION To_X01  ( b : BIT_VECTOR        ) RETURN  std_logic_vector;
  23. > >-- 5    FUNCTION To_X01  ( b : BIT_VECTOR        ) RETURN  std_ulogic_vector;
  24. > > 
  25. > >Of these you are choosing 4, 5 explicitly by using type qualification -
  26. > >ie bit_vector'("00"). 5 returns std_logic_vector and 4 returns std_ulogic_vector.
  27. > So far, so good.  Yes, there are two candidates with the same parameter and
  28. > result profile.
  29. > >The first one when indexed gives you an element of std_ulogic, and the latter
  30. > >gives std_logic. Now, std_logic is a subtype of std_ulogic, which implies
  31. > >both have the same base type which is std_ulogic. Hence, you end up
  32. > >with two interpretations, which is erroneous. The final type qualification
  33. > Not so fast.  Just because the parameter/result profiles match doesn't mean
  34. > the declaration is ambiguous.  According to LRM 10.5 (The Context of Overload
  35. > Resolution) there is a list of rules to be considered along with syntax and
  36. > scope/visiblity rules.  The first of these is:
  37. >   "1. Any rule that requires a name or expression to have a certain type,
  38. >       or to have the same type as another name or expression."
  39. > Since this is a constant declaration with a default expression, the following
  40. > rule for interface objects (LRM 4.3.3) seems applicable:
  41. >   "...The type of a default expression must be that of the corresponding
  42. >    interface object."
  43. > This narrows the search down to a single choice.  Unless I've missed 
  44. > something, Model Technologies appears to be doing the right thing here.
  45.  
  46. You didn't include the declaration containing the reference, so I have to infer
  47. things from some of your statements:
  48.  
  49. * I assume that the type mark of the constant is std_logic or std_ulogic.
  50.  
  51. * I assume that the initial-value expression consisted of an indexed name whose
  52.     prefix was a function call.
  53.  
  54. Then:
  55.  
  56. I think the reference is ambigious because the overload resolution rules 
  57. don't apply to indexed names.
  58.  
  59. Section 10.5 begins with "Overloading is defined for subprograms and for
  60. enumeration literals."  The next paragraph reinforces that overload resolution
  61. determines the meaning of occurences of operators and enumeration literals,
  62. but not indexed names, slice names, etc.
  63.  
  64. The rules about "Any rule that requires a name or expression..." is involved
  65. here, but not enough to resolve the function reference.  The expression must 
  66. be of the same base type as the constant, but that only constrains the result 
  67. type of the indexed name.  A known indexed name result type does not constrain
  68. the indexed name prefix type (many array types could have the same element 
  69. type).
  70.  
  71. Also, you said, "This narrows the search down to a single choice."  Again, I 
  72. can't see the original code, but even if resolution address indexed names, 
  73. would it make a difference?  Aren't Sunder's comments correct:
  74.  
  75.     "The first one when indexed gives you an element of std_ulogic, and 
  76.     the latter gives std_logic. Now, std_logic is a subtype of std_ulogic,
  77.     which implies both have the same base type which is std_ulogic."
  78.  
  79. What seemed to "narrow the search to a single choice"?
  80.  
  81. (By the way, in VHDL 1992, overload resolution applies to the "basic 
  82. operations" of indexing, slicing, aggregation, assignment, etc., so an
  83. analyzer will be able to resolve more cases.)
  84. --
  85. ------------------------------------------------------------------------------
  86. Daniel S. Barclay                    --who's still searching for a good 
  87. CAD Language Systems, Inc.           signature, not liking any of his recent
  88. Suite 101, 5457 Twin Knolls Rd.      feeble attempts to improve on the whiny:
  89. Columbia, MD  21045  USA             Why can't _I_ think of a good signature?
  90.  
  91.