Jump to content
  • 0

Using fixed point on Nexys4DDR


Sven K

Question

I have posted this quesion at the Xilinx forum but without any answers so I hope I have better luck here.

I´m trying to use fixed point in a design for Nexys4 (Artix-7) that started in Vivado and was exported to Vitas for the software part.

The design without fixed point works as expected but as soon as I add the ap_fixed.h file and compile I get the message that this file doesn´t exist. I have tried to add it manually but then new h-files are reported as non-existent and after adding some of them I get the message that some h-files cannot be added to user code.

I have the impression that normally when you create a platform for the design and export it to Vitis then Vitis will be aware of what h-files that are needed. In his case going for fixed point is something I do in Vitis and not in Vivado then these h-files are not included.

How do I make Vitis find those h-files?

Any help apprecierad!

Link to comment
Share on other sites

9 answers to this question

Recommended Posts

Hi @Sven K,

I'm not sure how it will work with Vitis (as a Unified Software Platform) but based on this Xilinx thread, it looks like you may need to change the way you include the library since it appears that ap_fixed.h is part of Vivado HLS rather than SDK/Vitis (and it seems you'll need to make sure it's a c++ project rather than a c project). We haven't used much HLS here at Digilent though so I won't be able to guarantee we have all the answers.

Thanks,
JColvin

Link to comment
Share on other sites

11 hours ago, Sven K said:

I´m trying to use fixed point in a design for Nexys4 (Artix-7) that started in Vivado and was exported to Vitas for the software part.

Either I don't understand what you mean by 'fixed point in a design" or I'm not sure what Vitas or the SDK has to do with it. If you aren't using VIvado HLS you can still do fixed point using VHDL or Verilog. It's really about understanding binary arithmetic and keeping track of the decimal point. Perhaps it's easier in Vivdo HLS. I don't use that tool so I wouldn't know. I strongly suspect that Vivado HLS has it's own limitations. 

I suspect that the key words in you question are "I'm trying to use" suggesting that a partially completed project was thrown onto your lap because you represent the path of least resistance. In those situations I start by careful analysis of what you have, what assumptions were made, and what issues are plaguing the project. If possible, it is often best to just understand what needs to be done and make it your own project based on how you understand how a good solution needs to be designed.

Link to comment
Share on other sites

With using fixed point I mean being able to use numbers that are defined with and integer and a fractional part and these numbers are defined in ap_fixed.h and I´m not being able to use that h-file.

With trying to use I just mean that I am starting up a new project to get the hang of using fixe point so it is not something that has been thrown on me

Link to comment
Share on other sites

3 hours ago, Sven K said:

I mean being able to use numbers that are defined with and integer and a fractional part and these numbers are defined in ap_fixed.h

Again, you don't need to use ap-fixed.h, HSL, a VHDL library or package or anything else to do fixed point in an HDL. You can define any std_logic_vector, signed or unsigned bit array as a fixed point value. You just have to keep track of where the decimal point is. For example a std_logic_vector(15 downto 0 ) could be defined as having 8 integer decimal places and 8 fractional decimal places. You know what the bit values. All of the integer bit weights  are (2^0, 2^1, 2^2... = 1, 2,4...) All of the fractional bit weights are (2^-1, 2^-2, 2^-3... = 1/2, 1/4, 1/8....). It's a bit more complicated but once you define the format you can do addition, subtraction, multiplication and division. It's very common to scale assign a std_logic_vector as all fractional and multiply it with an all integer std_logic_vector as a scaling factor. It's just math.

Read up o some of the old DSP devices like the DSP56000 or ADSP_2100. These are pretty much fixed point ALUs and multipliers with some fancy rounding and normalization hardware. There's nothing to invent here.

Link to comment
Share on other sites

You seem to have missed that since my problems are in Vitis we are talking about C code, not HDL.

ap_fixed.h includes some useful options like using any number of bits for your variables and built in saturation logic.

I can´t see why you wouldn´t want to use this h file unless you for some strange reason want to do everything on your own.

I got rid of the earlier error and ap_fixed.h seems to be recognized when I added a search path to vitis/include but instead I got another error that I can´t interpret, it reads

'cannot find -I-WI,--start-group,lxil.lgcc,-lc,-lstdc++,--end-group'

 

Link to comment
Share on other sites

5 hours ago, Sven K said:

I can´t see why you wouldn´t want to use this h file unless you for some strange reason want to do everything on your own.

Nothing strange about it. You don't need an FPGA platform to do C coding. I guess that I shouldn't have taken this statement so literally: "I am starting up a new project to get the hang of using fixe point". I have a hard time understanding why someone would want to artificially make their project harder by including an FPGA platform if all they want to do is develop some C code. This would be better done on a PC. You could also do it in OCTAVE. I guess that doing a C project in a MicroBlaze on an FPGA could be seen as FPGA development experience. This doesn't make a lot of sense to me.

Why would anyone want to do everything on their own?

  • They could learn a lot more than if they used canned libraries that hid all of the interesting work
  • They might be working on a project in which there is no room in the target FPGA device for extraneous fluff like a soft processor and all of its complexity and resource demands.
  • They might be required to implement a whole design in Verilog or VHDL for a customer

You can probably think of more reasons but I've done quite a few VHDL fixed point projects within a delivery deadline period. It's not a bad skill to have.

 

Link to comment
Share on other sites

On 5/4/2020 at 10:18 PM, Sven K said:

With trying to use I just mean that I am starting up a new project to get the hang of using fixe point so it is not something that has been thrown on me

I'd grab any 64-bit command line C compiler e.g. TDM-GCC and start from a blank sheet. You need neither FPGA nor Xilinx nor any vendor-proprietary tools when it's about basics and learning. 64-bit "unsigned int" is your best friend.

You can do the reference algorithm implementation using double format in the same file and have them always run side-by-side.
For a small project, this methodology goes a long way.
When it grows bigger, expect that managing the testcases becomes as much work as writing the code itself.

Link to comment
Share on other sites

In case there's any confusion about this I do want to point out that I consider the Nexys4 to be a great platform for learning about doing fixed point arithmetic in logic, using an HDL. It's just not a great platform for executing fixed point math in C. A Raspberry Pi is cheaper and better suited to that kind of project, if you must do it on an 'embedded' system. I think that @xc6lx45would agree with this. I certainly agree that gcc on a Linux PC is a fine way to experiment with basic mathematical concepts. Of course @Sven Khasn't really provided much context for discussion.

On 5/4/2020 at 3:28 AM, Sven K said:

I have posted this quesion at the Xilinx forum but without any answers so I hope I have better luck here.

On a positive note we certainly resolved the issue above :)

Link to comment
Share on other sites

5 hours ago, zygot said:

A Raspberry Pi is cheaper and better suited to that kind of project, if you must do it on an 'embedded' system.

+1 on Raspberry ... it's absolutely not a toy but scalable. "Industrial" Linux does not look that much different.

IMHO it's more important than ever, as e.g. PCs and smartphones are much less accessible than they used to be, now that security has high priority, OS-as-a-service changes every few months and Windows tries a support call every time my a.exe segfaults.

BTW, a quick way to a "canned" 64-bit gcc on Windows is to install Octave. Then locate and run the "msys" shell that comes included. Command line "gcc" should work from there but I think it needs an explicit -m64 option, otherwise it would default to 32 bits.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...