below is the code in C that is used to fuzzify an input. I have been trying to convert it to verilog syntax but i am having a lot of problem regarding the data types and such. The errors keep on piling. Any guidance would be appreciated.Thanks
Code:
float fuzzify_MF(float x,a,b,c,d) //x=crisp input
{
float dom;
if ( x >a && x <b)
{ dom=(x-a)/(b – a); }
else if (x>c && x<d)
{ dom=(d-x)/(d-c); }
else if (x>=b && x<=c)
{dom=1.0; }
else
{ dom=0; }
return dom;
}
your code cannot be converted *directly* to usable Verilog. However, you can do one of the following:
- convert the data types from float to your definition of a fixed-point datatype. Then, you can compare these directly
- if float is mandatory, you have to perform "approximate" comparisons within an "epsilon" range