Forum Discussion

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

ModelSim "out of range" issue

I have the following code:


Library IEEE; 
  use IEEE.Std_Logic_1164.all;
  use IEEE.numeric_std.all;
  use IEEE.Math_real.all ;
  ...
  WIDTH_DQ  :  natural  :=  9 ;
  X  :  in  integer range -(2 ** (WIDTH_DQ - 1)) to 2 ** (WIDTH_DQ - 1) - 1 := 0 ;
  Y  :  in  integer range -(2 ** (WIDTH_DQ - 1)) to 2 ** (WIDTH_DQ - 1) - 1 := 0 ;
  ...
  signal  lxn  :  integer range -(2 ** (WIDTH_DQ - 1)) to 2 ** (WIDTH_DQ - 1) - 1 := 0 ;
  ...
  lxn <= X - Y / (2 ** RANK) ;

During RTL simulation at RANK = 2 in time X = 226 and Y = -113. I'd expect lxn to become 254 and well within range. But ModelSim tells:

--- Quote Start ---

# ** Fatal: (vsim-3421) Value 261 for lxn is out of range -256 to 255.

# Time: 88 ns Iteration: 3 Process: /tp_cordic_vhd_tst/i1/genel(3)/regel/genpure/line__252 File: C:/qdesigns/bv5fpga/c-cam/bb/arithmetic/TP_cordic/cordicelement/cordicelement.vhd

# Fatal error in Process line__252 at C:/qdesigns/bv5fpga/c-cam/bb/arithmetic/TP_cordic/cordicelement/cordicelement.vhd line 294

--- Quote End ---

It looks like ModelSim is taken the representation of -113 as 'unsigned' and added 1/4 of that giving a result of 261.

Any clues?

21 Replies