Reputation: 19
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.
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;
}
Upvotes: 1
Views: 6517
Reputation: 1992
You can import a "C" function in the Verilog, by using PLIs.
Include following header file with the C function:
#include <svdip.h>
Now in the Verilog module:
module top;
import "DPI-C" context function shortreal fuzzify_MF(shortreal x, shortreal a, shortreal b, shortreal c, shortreal d);
shortreal t;
initial
begin
t = fuzzify_MF(<Arguments>);
end
endmodule
You can read more on this topic in the link : DPI Tutorial
Upvotes: 0
Reputation: 587
You can use PLI to solve this, but if you want to look cool and still solve it, use DPI of SystemVerilog.
http://www.project-veripage.com/dpi_tutorial_1.php
Upvotes: 0