Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
15 years ago

Float to Fixed Point in FPGA

Hi there.

I have DSP code in C with floating point, now I try to convert to FPGA to use fixed point. Can you guys show me how to do it?

I did little research document from http://www.vhdl.org/fphdl/ with fixed_pkg_c.vhdl. But I don't know how to start.

example in C:

i_sample = 0.7071;

q_sample = 0.2487;

How do I take this floating point to convert to fixed point or hex value?

Thank you guys,

Sean

11 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    you need to scale according to your target range. If a signal is swinging say +/-1 then to scale it for 10 bit signed you need the max value of 1 = 511 and so on:

    value = round(511*signal/max(abs(signal)));

    You may go lower for any other reason.