Re: [vhdl-200x] Bugzilla 289: Context declaration requirements are not uniform

From: Daniel Kho <daniel.kho@gmail.com>
Date: Sat Nov 02 2013 - 07:04:22 PDT
Typo corrected.


On 2 November 2013 22:00, Daniel Kho <daniel.kho@gmail.com> wrote:

> Hi all,
>
> In Section 13.2, the LRM states that:
> "A given implementation shall provide some mechanism to associate a
> library logical name with a host-dependent library. Such a mechanism is not
> defined by the language."
>
> I think this means that the same logical name should map to a unique
> host-dependent physical library, even if there are multiple repeated
> mentions of the same library clause. This leaves the design library unique
> for the same library logical name.
>
> I.e., the following _library_ clauses:
> lib lib1;
> lib lib1;
> should point to the same physical design library "lib1".
>
> Is there anywhere in the LRM that restricts such repeated library clauses?
>
> regards, daniel
>
>
>
> On 2 November 2013 17:52, Daniel Kho <daniel.kho@gmail.com> wrote:
>
>> Resending, as I believe the previous message wasn't registered.
>>
>>
>> ---------- Forwarded message ----------
>> From: Daniel Kho <daniel.kho@tauhop.com>
>> Date: 2 November 2013 02:52
>> Subject: [vhdl-200x] Bugzilla 289: Context declaration requirements are
>> not uniform
>> To: "vhdl-200x@eda.org" <vhdl-200x@eda.org>
>>
>>
>> Hi all,
>>
>> The submitter points us to Section 13.4 of the LRM:
>> "It is an error if, during analysis of a design unit, there is a library
>> clause in the expanded context clause of the design unit that occurs as
>> part of a replacement of a context reference, and a logical name in that
>> library clause denotes a different design library from the design library
>> denoted by the logical name during analysis of the context declaration from
>> which the library clause was expanded."
>>
>> After reading this over and over a few times, I too have a few questions.
>>
>> 1) What is meant by "...from which the library clause was expanded."?
>> I'm guessing this may be a typo, and what was meant was indeed: "...from
>> which the context clause was expanded."
>> Or am I missing something?
>>
>> 2) Another thing that isn't very clear to me is this clause: "if...there
>> is a library clause in the expanded context clause of the design unit that
>> occurs as part of a replacement of a context reference..."
>> My view is that a library clause in the expanded context clause couldn't
>> possibly _replace_ a context reference. Even if the library clause
>> "replaces" part of the expanded context clause (taken from the context
>> declaration denoted by the selected name of the context reference in
>> question), it should not have any impact on the analysis of the design unit.
>>
>> The same section of the LRM also mentions:
>> "NOTE 1—The rules given for use clauses are such that the same effect is
>> obtained whether the name of a library unit is mentioned once or more than
>> once by the applicable use clauses, or even within a given use clause."
>>
>> I'm not sure if a similar rule applies to library clauses, but this seems
>> to imply so. If for example, the same library logical name is mentioned
>> more than once, the effect should be the same as if the library was only
>> mentioned once.
>>
>> Consider the following example:
>>
>> -- contexts c1 and c2 are compiled into the lib1 library:
>> context c1 is
>>     library lib1;
>>     context lib1.c2;
>>     ...
>> end context c1;
>>
>> context c2 is
>>     library lib1;
>>     library lib2;
>>     ...
>> end context c2;
>>
>> -- User design:
>> library lib1;
>> context lib1.c1;
>>
>> The equivalent expanded context clause should look like this (repeated
>> library logical names are explicitly written as well):
>> library lib1;
>> library lib1;    -- [c1.lib1]: no issues, as this refers to the same
>> design library lib1.
>> library lib1;    -- [c2.lib1]: should also not be an issue? This should
>> also refer to the same design library lib1.
>> library lib2;    -- [c2.lib2]
>> ...
>>
>>
>> I am guessing that what was really intended by the LRM was to say:
>> "if...there is a _use_ clause in the expanded context clause of the design
>> unit...".
>> The reason for my belief comes from my reasoning in 3).
>>
>> 3) The same sentence in the LRM goes on to say: "...and a logical name in
>> that library clause denotes a different design library from the design
>> library denoted by the logical name during analysis of the context
>> declaration..."
>> I'm not sure how two library clauses that have the same logical name can
>> possibly denote different design libraries? The library logical name has to
>> be unique, as far as I know.
>> Perhaps what was meant by the LRM was this:
>> "...and a selected name in that use clause denotes a different design
>> library from the design library denoted by the selected name during
>> analysis of the context declaration..."
>>
>> This seems to support my reasoning in 2) that the LRM requires an error
>> to be issued when a use clause tries to replace part of the expanded
>> context clause for a design unit, AND the selected names for the
>> conflicting use clauses are referring to different design libraries.
>>
>> For example, the following would result in an error (I'm just showing the
>> expanded context clause for more clarity):
>> library ieee, lib1;
>> use lib1.std_logic_1164.std_ulogic;
>> context lib1.ctx;    -- assume that the corresponding context declaration
>> contains "use ieee.std_logic_1164.std_ulogic"
>> entity someDesign is port(q:out std_ulogic); end entity someDesign;
>>
>> This should result in an error, because although the selected name of the
>> use clauses are the same, they refer to different design libraries.
>>
>> I suggest we re-word the LRM to the following:
>> "It is an error if, during analysis of a design unit, there is a use
>> clause in the expanded context clause of the design unit that occurs as
>> part of a replacement of a context reference, and a selected name in that
>> use clause denotes a different design library from the design library
>> denoted by the selected name during analysis of the context declaration
>> from which the context clause was expanded."
>>
>> Or am I missing something else here?
>>
>>
>> The submitter also mentions:
>> "Consequently, the same context clause can refer to completely different
>> declarations."
>>  I think it is fine for the same context clause to refer to different
>> declarations. If the same context clause is used in different designs, I
>> believe it is fine for the context clause to refer to different
>> declarations, it that is what is intended by the design?
>>
>> For the submitter's case, if we want Design 2 to have y refer to l1.x.y,
>> we would need to specify the library l1 explicitly in the context
>> declaration:
>> context c2 is
>>     library l1;
>>     use l1.x.y;
>> end context c2;
>>
>> I think this is not a problem. If we want every design unit to have
>> context clauses that always point to the same declarations, then we should
>> explicitly specify the library clause within the context declaration.
>>
>> Otherwise, if we want to allow different designs to use different
>> libraries for the same declaration, then we need not specify the library
>> clause in the context declaration. Different designs can then use the same
>> context reference in their context clauses, but each of those context
>> clauses could possibly refer to different design libraries.
>> I don't see an issue with this, or am I missing something?
>>
>>
>> I believe this is pretty similar to the following example:
>>
>> -- Say we compiled our non-standard std_logic_1164 package into the
>> "my_lib" library:
>> package std_logic_1164 is
>>     type std_ulogic is ('a', 'b', 'c', 'd', true, false);
>> end package std_logic_1164;
>>
>> package body std_logic_1164 is end package body std_logic_1164;
>>
>>
>> -- This context declaration is also compiled into the "my_lib" library:
>> context c1 is
>>     use std_logic_1164.std_ulogic;
>> end context c1;
>>
>> -- Design 1:
>> library ieee;
>> use ieee.std_logic_1164;
>> context my_lib.c1;    -- equivalent to "use
>> ieee.std_logic_1164.std_ulogic;"
>> entity design1 is port(q:out std_ulogic); end entity design1;
>>
>> -- Design 2:
>> library my_lib;
>> use my_lib.std_logic_1164;
>> context my_lib.c1;    -- equivalent to "use
>> my_lib.std_logic_1164.std_ulogic;"
>> entity design2 is port(q:out std_ulogic); end entity design2;
>>
>> Both designs use the same type names, but they are actually different
>> types that came from different libraries.
>> This could be intended by a real design as well, where a designer could
>> explicitly write the expanded context clauses in place of the context
>> clauses that contains context references (as in the comments above).
>>
>> Comments?
>>
>> Best regards,
>> Daniel
>>
>>
>

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Sat Nov 2 07:05:10 2013

This archive was generated by hypermail 2.1.8 : Sat Nov 02 2013 - 07:05:10 PDT