Forum Discussion

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

LPM_mult : dynamic reduction with signed number

Hello, I’m using a very simple setup configuration with quartus 2 and cyclone III :

full scale analog signal - - > CAN 14 bit -- > DAC 14 bit : OK no distortion

After that I add a LPM_mult function between CAN and DAC .:

full scale analog signal - - > CAN 14 bit - -> LPM_Mult -- > DAC 14 bit

I’d like to be able to perform the same result: full scale signal at the output without distortion.

First I use simple LPM_ mult with fixed input b value: I choose this value to have a full scale signal at the output. Thus, with unsigned value ( I add a converter from unsigned to signed with CAN and DAC) input b is configured with all bits to VCC : It works.

I do the same with signed value : b input is set to 8191 in decimal, during wizard configuration.

The dynamic output is reduced. I have tried to keep all the bits at the output ( 14+ 14 ) and manually choose the bits , not only the MSB…no success.

I’m sure it is a truncation issue with signed number…But I don’t know how simply recover the full dynamic at the output…

Thank’s for your help. I will put the snapshot solution.

4 Replies

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

    I think I have understood what you are attempting but I'm not 100% sure so here goes...

    You may be losing a bit when you convert your unsigned quantity to signed. You should assume your input to be signed rather than actually converting it.

    i.e. unsigned range is 0..16383, but if you assume it to be signed as it arrives then you can interpret it to represent -8192..8191 without any form of manipulation.

    However, that having been said, 8191 for the B input represents something just short of 1.0 i.e. the range of multiplication is -1.0 <= x < 1.0

    This can be corrected by appropriate scaling - google fixed point arithmetic.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    I suggest to play around with a pocket calculator to understand the problem and possible solutions. To get exact factor 1 multiply, you need an extra bit in scaling factor.

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

    After many tests , and pratical results , the solution :

    LPM_Mult with signed binary.

    Input A [13..0] Input B [13..0]. Keep output with defined width [27..0]

    But!! need to use : [26..13] to have the same range on output DAC.

    It works :-)

    --- Quote Start ---

    I suggest to play around with a pocket calculator to understand the problem and possible solutions. To get exact factor 1 multiply, you need an extra bit in scaling factor.

    --- Quote End ---

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

    By discarding the MSB, you get an overflow for -8192*-8192. If this A,B combination doesn't occur in your application, you can ignore it, otherwise you need to handle it explicitely.