[vhdl-200x] numeric_std division problem

From: Graham, Paul <Paul_Graham@mentor.com>
Date: Mon Aug 11 2014 - 13:44:27 PDT
I've hit a problem with the definition of signed division in numeric_std.  With this function:

  function "/" (L: SIGNED; R: INTEGER) return SIGNED is

if L is "100" (that is, -4), and R is 4, then the function returns, not -1, but 0.  This is because:

    if (R_LENGTH > L'LENGTH) then
      QUOT := (others => '0');
      return RESIZE(QUOT, L'LENGTH);
    end if;

The signed_num_bits function says that to represent 4 as a signed value requires 4 bits.  This is correct.  Because R's bit representation is larger than  L's bit represented the function returns zero.

The result of (-4) / 4 should be -1, not 0.  Isn't this a bug in in numeric_std?


This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Mon Aug 11 13:45:36 2014

This archive was generated by hypermail 2.1.8 : Mon Aug 11 2014 - 13:46:32 PDT