Convert Matlab floating point function to fixed point

Status
Not open for further replies.

Milruwan

Member level 1
Joined
Jan 20, 2013
Messages
35
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Visit site
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:

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.
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…