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
Did you mean:
Observer
277 Views
Registered: ‎06-11-2019

## Conversion of floating-point to fixed-point in verilog

Hello

I want to convert 0.707 into fixed point value for my verilog code.Can u please explain how is conversion of floating-point value to fixed-point value done in verilog .

Thanks

Regards

Neha

1 Solution

Accepted Solutions
Highlighted
Scholar
259 Views
Registered: ‎04-26-2015

## Re: Conversion of floating-point to fixed-point in verilog

If you just want to code it in as a constant, then there's no need to do the conversion in the Verilog code - you can do the conversion externally and just code the result.

The process is very simple: just multiply your input number by 2^F where F is the number of fraction bits in your fixed-point value. For example, if you've got a 16-bit fixed-point value with 10 fraction bits, then:

0.707 * 1024 = 723.968, rounded to 724

724 in binary = 0000001011010100

Putting the binary point in there at the appropriate point (ie ten digits from the right, because there are ten fraction bits) we have 000000.1011010100. Converting back to decimal gives you 0.707031, which is as close as you can get with that fraction length.

3 Replies
Highlighted
Scholar
260 Views
Registered: ‎04-26-2015

## Re: Conversion of floating-point to fixed-point in verilog

If you just want to code it in as a constant, then there's no need to do the conversion in the Verilog code - you can do the conversion externally and just code the result.

The process is very simple: just multiply your input number by 2^F where F is the number of fraction bits in your fixed-point value. For example, if you've got a 16-bit fixed-point value with 10 fraction bits, then:

0.707 * 1024 = 723.968, rounded to 724

724 in binary = 0000001011010100

Putting the binary point in there at the appropriate point (ie ten digits from the right, because there are ten fraction bits) we have 000000.1011010100. Converting back to decimal gives you 0.707031, which is as close as you can get with that fraction length.

Observer
247 Views
Registered: ‎06-11-2019

## Re: Conversion of floating-point to fixed-point in verilog

Thank you so much
Scholar
235 Views
Registered: ‎09-16-2009