On 23 Dec 2013, at 8:40 pm, tging...@free.fr wrote:

> I think that ghdl is compliant with VHDL 1993 and 2002. That's modulo
> bugs, but I think that all features are implemented.  If not, do not
> hesitate to raise issues.

The issue isn't features (syntax), it's compliance (semantics).


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

entity tb_test0 is end;

architecture arch_tb of tb_test0 is
   signal i_s : integer := -1;
   --
   signal v_s : unsigned(7 downto 0);

begin
   -- Here it won't have any error during simulation, but it should
   v_s <= to_unsigned(i_s, 8);
   --
end architecture arch_tb;

david_koontz@Macbook: ghdl -a tb_test0.vhdl
david_koontz@Macbook: ghdl -e tb_test0
david_koontz@Macbook: ghdl -r tb_test0
david_koontz@Macbook: ghdl --version
GHDL 0.31dev (20132311) [Dunoon edition]
 Compiled with GNAT Version: GPL 2013 (20130314)
 GCC back-end code generator
Written by Tristan Gingold.

This is a noncompliant VHDL design description (yet it ran without error):

>From numeric_std:

  -- Id: D.3
  function TO_UNSIGNED (ARG, SIZE: NATURAL) return UNSIGNED;
  -- Result subtype: UNSIGNED(SIZE-1 downto 0)
  -- Result: Converts a non-negative INTEGER to an UNSIGNED vector with
  --         the specified SIZE.

Section 3
Types

 ...
A type is characterized by a set of values and a set of operations. The set of 
operations of a type includes the explicitly declared subprograms that have a 
parameter or result of the type. The remaining operations of a type are the 
basic operations and the predefined operators (see 7.2 ). These operations are 
each implicitly declared for a given type declaration immediately after the 
type declaration and before the next explicit declaration, if any.

A basic operation is an operation that is inherent in one of the following:

-- An assignment (in assignment statements and initializations)

-- An allocator

-- A selected name, an indexed name, or a slice name

-- A qualification (in a qualified expression), an explicit type conversion, a 
formal or actual part in the form of a type conversion,  or an implicit type 
conversion of a value of type universal_integer or universal_real to the 
corresponding value of another numeric type


 ----

The implicit type conversion of universal integer to natural should fail.

 ----
 7.3.5 Type conversions

 ...

If the type mark denotes a subtype, conversion consists of conversion to the 
target type followed by a check that the result of the conversion belongs to 
the subtype.

...

In certain cases, an implicit type conversion will be performed. An implicit 
conversion of an operand of type universal_integer to another integer type, or 
of an operand of type universal_real to another floating point type, can only 
be applied if the operand is either a numeric literal or an attribute, or if 
the operand is an expression consisting of the division of a value of a 
physical type by a value of the same type; such an operand is called a 
convertible universal operand. An implicit conversion of a convertible 
universal operand is applied if and only if the innermost complete context 
determines a unique (numeric) target type for the implicit conversion, and 
there is no legal interpretation of this context without this conversion. 

 ----

So the check that the result of the conversion belongs to the subtype isn't 
performed.  (And this is a run time check).

(And there is no TO_UNSIGNED (ARG: INTEGER; SIZE: INTEGER/NATURAL) defined in 
package numeric_std, leaving no legal interpretation without implicit 
conversion.  The inner most context is defined by the interface declaration 
used for the association list for the arguments to TO_UNSIGNED.)

Further, during simulation of the equivalent process statement for the 
offending concurrent signal assignment statement, the TO_UNSIGNED subprogram 
call involves the elaboration of the parameter interface list of corresponding 
subprogram declaration (See 12.5 Dynamic elaboration).

And this one of those issues of the category that the standard does not convey 
clearly, the information being spread among multiple clauses.

https://sourceforge.net/p/ghdl-updates/tickets/4/
Subtype compatibility check of an implicitly converted universal integer not 
performed during dynamic elaboration

I find these using ghdl as a reference when checking other VHDL tools.  I'll 
dig around I might have 3 or 4 more stuck in mailboxes.  All in all ghdl 
acquits itself quite favorably.

There's also around 190 compliant test cases that fail and some number of 
non-compliant tests cases that also fail.  And every last one of them needs a 
bout of VHDL lawyering to determine the validity of the test cases and results. 
 (Although those with access to say Modelsim can usually at least tell whether 
something should fail or not, just not why without the research).



_______________________________________________
Ghdl-discuss mailing list
Ghdl-discuss@gna.org
https://mail.gna.org/listinfo/ghdl-discuss

Reply via email to