Jan 28, 2014 #1 M Milruwan Member level 1 Joined Jan 20, 2013 Messages 35 Helped 0 Reputation 0 Reaction score 0 Trophy points 1,286 Activity points 1,546 I need to convert a simple floating point function to fixed point in order to generate hdl code. Following is the function. Code: function y = fun(u) %#codegen if(u<0) y=0; else y=u; end How to convert this function to fixed point. Please help me. Last edited by a moderator: Feb 1, 2014
I need to convert a simple floating point function to fixed point in order to generate hdl code. Following is the function. Code: function y = fun(u) %#codegen if(u<0) y=0; else y=u; end How to convert this function to fixed point. Please help me.
Feb 3, 2014 #2 Y yourcheers Member level 1 Joined Jul 18, 2008 Messages 33 Helped 8 Reputation 16 Reaction score 8 Trophy points 1,288 Activity points 1,441 if you just want to check the number is lessthan zero and perform some operations, you can as well check the sign bit of the fixed point number and take some action. if(num[sign_bit] == 1) y = 0; else y = u; hope this helps.
if you just want to check the number is lessthan zero and perform some operations, you can as well check the sign bit of the fixed point number and take some action. if(num[sign_bit] == 1) y = 0; else y = u; hope this helps.