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!

cancel
Showing results for 
Search instead for 
Did you mean: 
Visitor ismail1293
Visitor
529 Views
Registered: ‎10-10-2019

Fixed Point Matrix Inversion by using XAPP1317

Hi all,

I tried to convert Scalable Floating-Point Matrix Inversion to Fixed Point Matrix Inversion Design by Using Vivado high-Level Synthesis. I tried to change the XAPP1317 Xilinx code. I changed all float datas with fixed point data type. I used ap_fixed library ( ap_fixed<16,3> Word length = 16 , fraction = 13). But, it did'n work. It gives error through C code simulation steps. By the way, I generated test vectors in matlab by using fi() function in matlab. What can be my possible mistakes ? Do you have any suggestions ?  

 

0 Kudos
7 Replies
512 Views
Registered: ‎07-23-2019

Re: Fixed Point Matrix Inversion by using XAPP1317

My suggestion is you share your code and the error message it produces. "it didn't work, it gives an error" is like going to the doctor and saying "pain" and nothing else.

Visitor ismail1293
Visitor
503 Views
Registered: ‎10-10-2019

Re: Fixed Point Matrix Inversion by using XAPP1317

https://www.xilinx.com/content/dam/xilinx/support/documentation/application_notes/xapp1317-scalable-matrix-inverse-hls.pdf 

You can find the code here. It is a bit long code doctor . I just changed the typedef float with typedef ap_fixed<16,3>. My question is that when I changed the data type to fixed point, can I directly multiply or add two different fixed point without rounding or normalizing ?  

For example ; 

3.45 + 3 = 6.45 but it should be equal to 3.99 according to ap_fixed<16,3>. 

Can I do that directly adding two different fixed point Mr. doctor ?

0 Kudos
489 Views
Registered: ‎07-23-2019

Re: Fixed Point Matrix Inversion by using XAPP1317

 

Maths are maths. There is no floats, doubles or fixed point there. These are an invention of engineers who work with computing machines. All these types are representations of numbers, with their limitations (precision, range, etc.). Operations, too, have limitations inherited by the types they operate on.

So, in short, you cannot simply change the types and expect everything else does the job. Sorry, you need to check many other things.

Highlighted
487 Views
Registered: ‎07-23-2019

Re: Fixed Point Matrix Inversion by using XAPP1317

With floats you have a range from -1e38 to +1e38, most of the times your values won't go that far, but with fixed point, you have a very limited range you need to check at every operation. 

Most fixed point systems are devised as to never have overflow by design. for example, values in the 0 to 10 range, worst case three products, so you set up some type in the range 0 to 1000. Many times, different fp types are used for internediate values to maximize accuracy. 

Moderator
Moderator
276 Views
Registered: ‎11-21-2018

Re: Fixed Point Matrix Inversion by using XAPP1317

Hi @ismail1293 

If your question is answered or your issue is solved, please kindly mark the response which helped as solution (click on "Accept as solution" button below the reply).

 

If this is not solved/answered, please reply in the topic giving more information on your current status.

 

Thanks and Regards,

Aoife
Product Application Engineer - Xilinx Technical Support EMEA
**~ Don't forget to reply, give kudos, and accept as solution.~**
0 Kudos
Visitor ismail1293
Visitor
248 Views
Registered: ‎10-10-2019

Re: Fixed Point Matrix Inversion by using XAPP1317

Firstly, I couldn't solve my issue. I added a fixed type defitinion to the code. Then, ı started to change float types with fixed points by debugging the code, but I realized that there are some arrays or data types which iterates every loop. This causes owerflow for the fixed point data type. Finally, I changed only input and outputs type to fixed point to save time for my design. Although matlab mex and C function doesn't gives errors, the rtl simulation does not work properly according to matlab. 

0 Kudos
235 Views
Registered: ‎07-23-2019

Re: Fixed Point Matrix Inversion by using XAPP1317

 

There are whole books and courses on how to use fixed-point numbers. Matlab won't tell you about overflow because it's a runtime event and it's up to you to check you don't feed operands that will overflow and to deal with that if it will. Like a calculator won't complain if you try to multiply 1e60 times 1e60. It's not 9.99e99, is it?  Don't struggle, learn.

 

0 Kudos