Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
9 years ago

integer overflow

Can anyone explain me why ModelSim Intel Starter Edition 10.5b does not complain about integer overflows, i.e. why the following code

process
    variable n : integer;
begin
    n := 0;
    report integer'image(n);
    for i in 1 to 1000 loop
        n := ((10 * n) + 3);
        report integer'image(n);
    end loop;
    wait;
end process;

generates that:

--- Quote Start ---

0

3

33

333

3333

33333

333333

3333333

33333333

333333333

-961633963

-1026405035

-1674115755

438711637

92149077

921490773

624973141

1954764117

-1927195307

-2092083883

553997653

1245009237

-434809515

-53127851

-531278507

-1017817771

-1588243115

1297438037

89478485

894784853

357913941

-715827883

1431655765

1431655765

1431655765

...

--- Quote End ---

Thanks,

- Julien

2 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Interesting - it could possibly be a bug - BUT

    It could be that integer implementation in VHDL is tool dependent, and not defined in the VHDL LRM. So you cannot check the range of the 32 bit integer if it goes over 32 bits!

    Raise a ticket with mentor and see what they say.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    I can see the very same behavior with Vivado Simulator 2016.4.

    If it is not defined in the LRM, then I agree it is not really a bug.

    Thanks!

    - J