- Choose to receive important news and product information
- Gain access to special content
- Personalize your web experience on Xilinx.com

- Xilinx User Community Forums
- Xcell Daily Blog
- General Discussion
- New Users
- General Technical Discussion
- Forum Usage
- Silicon Devices
- Virtex® Family FPGAs
- Spartan® Family FPGAs
- 7 Series FPGAs
- Zynq All Programmable SoC
- CPLDs
- Silicon Devices - Others
- Design Tools
- Vivado TCL Community
- Installation and Licensing
- Design Entry
- HLS
- Simulation and Verification
- Synthesis
- Implementation
- Timing Analysis
- Hierarchical Design
- Design Planning
- Design Tools - Others
- Archived ISE issues
- Embedded Solutions
- Embedded Development Tools
- Embedded Processor System Design
- Embedded Linux
- PicoBlaze
- DSP Solutions
- DSP Tools
- Digital Signal Processing - IP and Algorithms
- Boards and Kits
- Xilinx Boards and Kits
- 3rd Party/Other Boards and Kits
- Intellectual Property
- PCI Express
- Connectivity
- MIG
- System Logic

- Xilinx User Community Forums
- :
- Xilinx Products
- :
- General Discussion
- :
- General Technical Discussion
- :
- Document on Fixed Point arithmetic

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page

0

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

10-13-2013 11:07 PM

Hi ,

I have to do a DSP algorithm with two 16 2's compliment bit numbers A (Q1.15 format ) and B(12.4 format) . I need to have the result in Q1.15 format . Can anyone suggest me a good concrete document on this topic.

With regards

Vintu

0

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

10-13-2013 11:51 PM

Hi Vintu,

very basic and formally you can do it like this:

Expand both numbers to 12.15 fixed format with respect ot the signedness.

Forget about the decimal point and do integer math. (there is no difference)

Snip out the 1.15 Result , which will be the 16 LSBs of the 12.15 number.

Done.

There may be potential to optimize the wordwidth, but you can also leave this to the logic optimization tools.

You have to be carefull if you are using algorithms like CORDIC which might change the decimal point position in the result.

Also in multiplications you have to care about taking the right bits from the result which will have 24.30 format.

Have a nice synthesis

Eilert

0

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

10-14-2013 12:07 AM

Consider the two types of operators you can use on Q numbers: addition/subtraction and multiplication (division is more complicated):

If you add two aligned Q numbers (ie the binary point is at the same location) you just add the regular bit patterns and adjust for growth like you would regular integers ie every N element addition gives you log2(N) extra bits. If numbers are not aligned (ala your example) you need to align them ie 1.15 + 12.4,11'b0 if that makes sense to you (or you need to add 11 zeros to the right of the number in 12.4 number to add it to 1.15 number).

Multiplication is somewhat easier. There is no need to align but the result grows by the sum of the inputs sizes ie:

1.15 x 12.4 = 13.19 ie you add whole sizes and fractional sizes separately. Of course then you have to round it back to your desired output or say you want the result in 1.15. You need to divide the result by 16 (to get rid of the 4 bits at the bottom) and truncate the number to 16 bits. Of course there is no guarantee that the result will fit into 16 bits.

This looks like a nice document: http://courses.cs.washington.edu/courses/cse467/08au/pdfs/lectures/11-FixedPointArithmetic.pdf

If you add two aligned Q numbers (ie the binary point is at the same location) you just add the regular bit patterns and adjust for growth like you would regular integers ie every N element addition gives you log2(N) extra bits. If numbers are not aligned (ala your example) you need to align them ie 1.15 + 12.4,11'b0 if that makes sense to you (or you need to add 11 zeros to the right of the number in 12.4 number to add it to 1.15 number).

Multiplication is somewhat easier. There is no need to align but the result grows by the sum of the inputs sizes ie:

1.15 x 12.4 = 13.19 ie you add whole sizes and fractional sizes separately. Of course then you have to round it back to your desired output or say you want the result in 1.15. You need to divide the result by 16 (to get rid of the 4 bits at the bottom) and truncate the number to 16 bits. Of course there is no guarantee that the result will fit into 16 bits.

This looks like a nice document: http://courses.cs.washington.edu/courses/cse467/08

---------------------------------------------------------------------------------------------

Kindly note- Please mark the Answer as "Accept as solution" if information provided is helpful.

Give Kudos to a post which you think is helpful and reply oriented.

---------------------------------------------------------------------------------------------

Kindly note- Please mark the Answer as "Accept as solution" if information provided is helpful.

Give Kudos to a post which you think is helpful and reply oriented.

---------------------------------------------------------------------------------------------

0

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

10-14-2013 12:03 PM

Thanks for the reference muzaffer.

I've recommended the below reference multiple times. It's written by a DSP guy more angled towards software, but I find the representation he uses is very useful for HW. His paper lists some fundamental rules of fixed-point arithmetic - showing bit growth under common operations, and signedness concerns.

http://www.digitalsignallabs.com/fp.pdf

Regards,

Mark

0

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

10-14-2013 12:07 PM

I like Randy's work a lot. He is active comp.dsp too.

---------------------------------------------------------------------------------------------

Kindly note- Please mark the Answer as "Accept as solution" if information provided is helpful.

Give Kudos to a post which you think is helpful and reply oriented.

---------------------------------------------------------------------------------------------

Kindly note- Please mark the Answer as "Accept as solution" if information provided is helpful.

Give Kudos to a post which you think is helpful and reply oriented.

---------------------------------------------------------------------------------------------