Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Convert Matlab floating point function to fixed point

Status
Not open for further replies.

Milruwan

Member level 1
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.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top