05-14-2015 05:38 PM
am using Vivado for Zedboard. I have my custom IP contains 8 bit input .I need to do some arithmetic operation with fixed point number too. But this fixed point number shall be sent from SDK to FPGA part. So my question is how to represent float_value = 0.2 as fixed point in SDK ? So that fixed point number shall be sent to my FPGA.
PS: I don't need to use Floating Point IP in design, as it will take float value and then sent to FPGA by converting fixed point . I need fixed point value to send to FPGA:
Can anyone please tell that what can be the conversion factor for 8 bits ? If I set 8 bit representation for fixed point numbers then what would be the formula then to convert float to fixed point ? I want to do conversion in C code.
I have read that : If your fixed point numbers have 23 bits of fraction, f = n * (1.0 / 0x800000)
Let me take an example: Float number = 0.2 . Then what can be the fixed point value for 0.2 in 8 bits ?
PS: I want to give fixed input from C code which will go to my FPGA . FPGA take that fixed point value as 8 bits . So this is my question I am actually asking !! I am using unsigned (7 downto 0 ) input in FPGA . so that port is expecting unsigned input 8 bits.
data : input unsigned (7 downto 0) ;
Kindly clarify my confusion , that would be appreciated . thanks –
05-15-2015 12:23 AM
05-15-2015 11:33 AM
As i have wriiten above that my Ip is receiving 8 bits unsigned numbers. So in SDK, i have wriiten
*((u32*) constant) = 0b0001000; i am assuming last 4 are fractional. so this value is supposed to be 0.5.
Now my FPGA has code :
signal out : unsigned (39 downto 0) ;
signal in : unsigned (32 downto 0);
signal constant : unsigned (7 downto 0):
out <= constant * in;
So the vhdl code will treat constant as the value = 8. but actually i am supposed to send 0.5.
i hope you get my point. So how to multiply actually 0.5 as fixed point using such circumstances.
05-15-2015 12:03 PM
05-15-2015 02:02 PM
i guess. you took it wrong.
in is my unsigned (31 downto 0) and i am sending value from SDK :
TX = 0x01010101 ; which will go to in.
and constant is unsigned ( 7downto 0) which is constant = 0b00000001:
so multiply basicaly those two values .
05-15-2015 03:04 PM
05-21-2015 08:52 PM
@muzaffer yes i understood your point completely but do i need to manually truncate for every input ? Ok I choose the 8 bits according to my required answer 2.5 for (00101000) . so again manually round off this ?