The Designer's Guide Community Forum
https://designers-guide.org/forum/YaBB.pl
Design Languages >> Verilog-AMS >> How to handle complex numbers and error function (erf(x))
https://designers-guide.org/forum/YaBB.pl?num=1320399240

Message started by Polux on Nov 4th, 2011, 2:34am

Title: How to handle complex numbers and error function (erf(x))
Post by Polux on Nov 4th, 2011, 2:34am

As far as I know, verilogA does not support equation containing complex numbers and it doesnt work with the error function. I have just started a project simulating a specific FinFet for a company and I need to use equations based on the requiremets mentionated.  Is there any way? or any clue that I could use in order to star my investigation.

Thanks.

Title: Re: How to handle complex numbers and error function (erf(x))
Post by loose-electron on Nov 5th, 2011, 1:44pm

Its not Matlab. More designed for transient analaysis of currents and voltages.

As a work around, consider processing two "signals" one to represent the real component, and the other to represent the imaginary part.

Title: Re: How to handle complex numbers and error function (erf(x))
Post by Geoffrey_Coram on Nov 7th, 2011, 11:18am

I don't even see erf(x) supported in SystemVerilog (some extra features in SystemVerilog trickle down into V-AMS).  I wonder if it's in VHDL-AMS (or one of its packages).

I don't see an easy solution, sorry to say.  Maybe you could create a table and use $table_model ?

Title: Re: How to handle complex numbers and error function (erf(x))
Post by Polux on Nov 11th, 2011, 5:41am

Oook.. thanks for the help.... I will continue researching, if I find solutions I will post it..

Title: Re: How to handle complex numbers and error function (erf(x))
Post by Marq Kole on Nov 13th, 2011, 1:22pm

An example implementation of the error function erf() can be found in the Numerical Recipes in C book. It's relatively easy to turn this C code into Verilog-A. Also C doesn't know a complex number data type and makes do with two real values representing real and imaginary parts as Geoffrey suggested.

Cheers,
Marq

Title: Re: How to handle complex numbers and error function (erf(x))
Post by Polux on Nov 16th, 2011, 1:38am

This is an example of the equations I have to run in VerilogA.. How would be your approach??.. I am still researching and try to find the most efficient solution..

u1v1 = cosh(pi * (xm + 1i*(toxs_t + Tch/2)) / (2 * toxs_t + Tch));

fz_0 = exp(g_0) * ((sqrt(pi) * Tch/2)/ (2 * sqrt(g_0))) * erf(sqrt(g_0))

thanks.

Title: Re: How to handle complex numbers and error function (erf(x))
Post by Geoffrey_Coram on Nov 17th, 2011, 6:05am

For the erf call, I was suggesting something like this:

real erf;

erf = $table_model(sqrt(g_0), "erf.dat", "3E");
fz_0 = exp(g_0) * ((sqrt(pi) * Tch/2)/ (2 * sqrt(g_0))) * erf);

where erf.dat is a text data file containing values generated by C or Matlab or something.

Title: Re: How to handle complex numbers and error function (erf(x))
Post by Polux on Dec 6th, 2011, 5:45am

Thank you very much for your help, implementing the erf(x) using table_models provides an easy way to obtain good results.  Now, I was wondering if you have some extra information about how to implement complex numbers, as other researchers suggest is to separate the signal en their components and work indiviudality, etc. But how to start?

I would really appreciate the help.

thanks in advance.

Title: Re: How to handle complex numbers and error function (erf(x))
Post by Geoffrey_Coram on Dec 14th, 2011, 8:27am

Well, you have cosh(a + bi) in your example.  So, you might start with some trigonometric identities:

cosh(x) = ( exp(x) + exp(-x) ) / 2
cosh(a+bi) = ( exp(a+bi) + exp(-a-bi) ) / 2
exp(iy) = cos(y) + i sin(y)
exp(a+bi) = exp(a) * exp(bi) = exp(a)*(cos(b) + i sin(b))

It gets a little messy; you might want to look at the whole set of equations and figure out if you really need all the parts.

Title: Re: How to handle complex numbers and error function (erf(x))
Post by Polux on Dec 20th, 2011, 5:27am

Thanks again for your help.  I follow your suggestion and others to change the expression of the equation that use complex numbers, and now I have been able to simulate the model in VerilogA, your help has been very usefull.

Title: Re: How to handle complex numbers and error function (erf(x))
Post by Geoffrey_Coram on Dec 20th, 2011, 5:49am

I'm glad to hear it worked out for you.

The Designer's Guide Community Forum » Powered by YaBB 2.2.2!
YaBB © 2000-2008. All Rights Reserved.