**UPGRADE YOUR BROWSER**

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

- Community Forums
- Xcell Daily Blog
- Vivado Expert Series Blog
- About Our Community
- Announcements
- Welcome & Join
- General Technical Discussion
- Programmable Devices
- UltraScale Architecture™
- 7 Series FPGAs
- Virtex® Family FPGAs
- Spartan® Family FPGAs
- Xilinx Boards and Kits
- Configuration
- Serial Transceivers
- Design Tools
- Installation and Licensing
- Synthesis
- Simulation and Verification
- Implementation
- Design Entry
- Timing Analysis
- Vivado TCL Community
- HLS
- Design Methodologies and Advanced Tools
- SDAccel
- Design Tools - Others
- Embedded Systems
- Embedded Development Tools
- Embedded Processor System Design
- Embedded Linux
- Zynq All Programmable SoC
- SDSoC Environment and reVISION Stacks
- OpenAMP
- Intellectual Property
- PCI Express
- Networking and Connectivity
- MIG
- DSP and Video
- BRAM/FIFO

turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

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

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- 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

- 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

- 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/08au/pdfs/lectures/11-FixedPointArithmetic.pdf

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

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

- 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

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

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

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