Conversion 1QN -> 2'Complement

Discussion in 'VHDL' started by Troels Smit, Jun 30, 2003.

  1. Troels Smit

    Troels Smit Guest

    Hi all,

    I have to convert a 1QN number into a 2' complement number both 20 bit
    wide.

    1QN define numbers between -1 and 1-(2^-n) with a binary point after 2
    first bits.
    i.e:
    +1 : 0100 0000 ...
    -1 : 1100 0000 ...
    pi/8 : 0011 0010 ...
    -pi/8 : 1100 1101 ...

    The 2'complement number is between 1 and -1, where 7FFFF define 1 and
    8FFFF define -1.
    i.e:
    +1 : 0111 1111
    -1 : 1000 0000
    +1/8 : 0000 1111
    -1/8 : 1111 0001

    Does anyone have an idea of how to convert between these two formats ?
    It is the 1Qn that has to be converted into the 2'complement number.
    Troels Smit, Jun 30, 2003
    #1
    1. Advertising

  2. Troels Smit

    Troels Smit Guest

    Re: Conversion 1QN -> 2'Complement ( Cordic )

    On page 5 at this address:
    http://www.xilinx.com/ipcenter/catalog/logicore/docs/cordic.pdf

    They write:
    Pout : "0000101011" => 00.00101011 =>-0.168
    PHASE_IN : "0001100100" => 000.1100100 => 0.781

    Now, both numbers are describe as 2QN numbers ... but they have
    different fixed point, and one is negative .... I can't seem to
    decipher what's going on :-/
    Can anyone explain it ? (to me it seems like the line Pout... is
    wrong)

    As to the 1QN format I asked about yesterday ... Im using the cordic
    to generate sin/cos output and therefore the x_out and y_out in 1QN
    format will never use its 2. MSB (data > 1) and a sll performed on the
    lower part of the data (keeping msb) make data usable for the DAC (I
    think).

    /Troels

    (Troels Smit) wrote in message news:<>...
    > Hi all,
    >
    > I have to convert a 1QN number into a 2' complement number both 20 bit
    > wide.
    >
    > 1QN define numbers between -1 and 1-(2^-n) with a binary point after 2
    > first bits.
    > i.e:
    > +1 : 0100 0000 ...
    > -1 : 1100 0000 ...
    > pi/8 : 0011 0010 ...
    > -pi/8 : 1100 1101 ...
    >
    > The 2'complement number is between 1 and -1, where 7FFFF define 1 and
    > 8FFFF define -1.
    > i.e:
    > +1 : 0111 1111
    > -1 : 1000 0000
    > +1/8 : 0000 1111
    > -1/8 : 1111 0001
    >
    > Does anyone have an idea of how to convert between these two formats ?
    > It is the 1Qn that has to be converted into the 2'complement number.
    Troels Smit, Jul 1, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mantorok Redgormor

    sign magnitude, ones complement, two's complement

    Mantorok Redgormor, Oct 5, 2003, in forum: C Programming
    Replies:
    8
    Views:
    8,570
    Glen Herrmannsfeldt
    Oct 8, 2003
  2. sarathy

    1's complement and 2's complement

    sarathy, Aug 1, 2006, in forum: C Programming
    Replies:
    20
    Views:
    2,170
    Bo Persson
    Aug 2, 2006
  3. sarathy
    Replies:
    22
    Views:
    2,314
    Bo Persson
    Aug 2, 2006
  4. Ross Ridge
    Replies:
    18
    Views:
    555
    George Sakkis
    Apr 22, 2008
  5. Roberto Waltman

    2's complement vs. 1's complement vs. ...

    Roberto Waltman, Jun 9, 2011, in forum: C Programming
    Replies:
    4
    Views:
    1,337
    Michael Press
    Jun 14, 2011
Loading...

Share This Page