Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

missing predefined functions returns universal_real #46

Closed
hiyuh opened this issue Feb 25, 2014 · 3 comments
Closed

missing predefined functions returns universal_real #46

hiyuh opened this issue Feb 25, 2014 · 3 comments

Comments

@hiyuh
Copy link
Contributor

hiyuh commented Feb 25, 2014

VHDL-1993 has following predefined functions returns universal_real, but they are missing ATM.

-- function "*" (anonymous: universal_real; anonymous: universal_integer)
-- return universal_real;
-- function "*" (anonymous: universal_integer; anonymous: universal_real)
-- return universal_real;
-- function "/" (anonymous: universal_real; anonymous: universal_integer)
-- return universal_real;

w/ proposed issueY,

entity issueY is
begin
    assert (1.0 * 1 = 1.0);
    assert (1 * 1.0 = 1.0);
    assert (1.0 / 1 = 1.0);
end entity issueY;

architecture a of issueY is
begin
end architecture a;

then i got,

$ NVC_LIBPATH=./lib/std:./lib/ieee:./lib/nvc NVC_CYG_LIB=./src ./src/nvc.exe -a test/regress/issueY.vhd
** Error: no suitable overload for operator "*"(universal real, universal
          integer) return REAL
        File test/regress/issueY.vhd, Line 3
     assert (1.0 * 1 = 1.0);
             ^^^^^^^
** Error: no suitable overload for operator "*"(universal integer, universal
          real) return REAL
        File test/regress/issueY.vhd, Line 4
     assert (1 * 1.0 = 1.0);
             ^^^^^^^
** Error: no suitable overload for operator "/"(universal real, universal
          integer) return REAL
        File test/regress/issueY.vhd, Line 5
     assert (1.0 / 1 = 1.0);
             ^^^^^^^
hiyuh added a commit to hiyuh/nvc that referenced this issue Feb 25, 2014
hiyuh added a commit to hiyuh/nvc that referenced this issue Feb 25, 2014
hiyuh added a commit to hiyuh/nvc that referenced this issue Feb 25, 2014
hiyuh added a commit to hiyuh/nvc that referenced this issue Feb 25, 2014
@hiyuh
Copy link
Contributor Author

hiyuh commented Feb 25, 2014

it just works.
could you mind to check my issue46 branch?

@nickg
Copy link
Owner

nickg commented Feb 26, 2014

The changes above look technically fine, but the problem is they allow things like:

variable r : real;
r := r * 5;

Section 7.5 in the LRM is a bit awkward in that those operators apply only in universal expressions. At the moment NVC has no way of distinguishing universal operators from regular ones, so I've attempted to add this in commit b7dc9bc.

There's now a function sem_declare_universal which declares them and a special case in the overload resolution function that ensures universal parameter types only match arguments with universal integer/real types.

There isn't any code generation for these operators as they should always be constant-folded.

@nickg nickg closed this as completed Feb 26, 2014
@hiyuh
Copy link
Contributor Author

hiyuh commented Feb 26, 2014

ACK, thanks your precise correction!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants