10-10-2019 12:56 AM
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 ?
10-10-2019 01:23 AM
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.
10-10-2019 01:41 AM
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 ?
10-10-2019 01:51 AM
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.
10-10-2019 01:57 AM
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.
10-22-2019 09:43 AM
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,
10-22-2019 11:59 PM
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.
10-23-2019 12:51 AM
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.