Reputation: 35
I'm trying to create RGB to YUV converter in VHDL.
Y = 0.299 x R + 0.587 x G + 0.114 x B
U = -0.147 x R - 0.289 x G + 0.436 x B
V = 0.615 x R - 0.515 x G -0.100 x B
In this formula I have to use and multiple floating point numbers like 0.299
, 0.587
, etc. How do I create synthesizable VHDL with floating point numbers?
Upvotes: 2
Views: 6343
Reputation: 120
you can this using integer multiplication.
If you have a FPGA with 18 bit multipliers you multiply and then use the upper bits.
E.g. : 0.299, R=20 =>
0.299 * 2^17 = 39191
39191 * 20 then use the result's upper bits ( top downto 17) that is the same as divide by 2^17
Since your application is RGB to YUV I guess this is time critical so the above example is the best choice, otherwise I usually use Instant SoC to implement float algorithms that is not time critical.
Upvotes: 4