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. Advertisements

  2. Troels Smit

    Troels Smit Guest

    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, Jul 1, 2003
    #2
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.