Peter, Thanks for your reply. I agree fully, the magnitude of the error will change depending on the equations, but that shouldn't make the "eps" function less useful. One just has to propagate the error through the equations rigorously and arrive to the maximum possible error that way. Of course the better way would be if the tools or compilers could take care of this automatically... Is that wishful thinking? I should have told Santa when he came... :-) I would highly recommend to add an "eps" compatible function to VHDL-AMS. Would this have to be a language feature, or can it be provided in a standard library of some sort? Thanks, Arpad =================================================================== -----Original Message----- From: Peter Ashenden [mailto:peter@ashenden.com.au] Sent: Wednesday, December 20, 2006 5:21 PM To: Muranyi, Arpad; vhdl-ams@server.vhdl.org Subject: RE: Floating point related question Arpad, That's a really good question. Currently, there is no such function. As of VHDL-2002 (and hence VHDL-AMS-2007), floating point numbers have to be IEEE double precision or better. So it would be feasible to define a function similar to Matlab's eps function, assuming double precision representation. Might be worth raising it as a requirement for both VHDL and VHDL-AMS. A further issue comes to mind. If you're doing numerical computation, you accumulate error, the magnitude of which depends on the behavior of the algorithm. That means a final result may have greater than eps error compared to some expected value. For example, if you do assert abs(computation(x) - expected_x) < eps; the accumulated error might mean that the result of the computation is more than eps away from expected_x, even though the computation has been performed correctly. Knowing what value to use in place of eps (or how much to scale eps) involves numerical analysis of the computation. Does this make a putative eps function less useful in practice? Cheers, PA -- Dr. Peter J. Ashenden peter@ashenden.com.au Ashenden Designs Pty. Ltd. www.ashenden.com.au PO Box 640 VoIP: sip://0871270078@sip.internode.on.net Stirling, SA 5152 Phone (mobile): +61 414 70 9106 Australia > -----Original Message----- > From: owner-vhdl-ams@server.eda.org > [mailto:owner-vhdl-ams@server.eda.org] On Behalf Of Muranyi, Arpad > Sent: Thursday, 21 December 2006 10:39 AM > To: vhdl-ams@server.vhdl.org > Subject: Floating point related question > > > Hello Everyone, > > We all know that using relational operators between > floating point numbers is a risky proposition. This > code, for example, may never execute, believe it or > not, (I tried it): > > if (0.1+0.2 = 0.3) then > report "Test"; > end if; > > However, there are times when taking care of such > floating point errors may be needed. > > In Matlab there is a function, called "eps" which > can help in incorporating such errors in equations. > http://www.mathworks.com/access/helpdesk/help/techdoc/ref/inde x.html?/ac cess/helpdesk/help/techdoc/ref/eps.html&http://www.google.com/search?hl= en&q=eps+function I would like to find out whether there is a similar function in VHDL-AMS. For a moment I thought I could use the T'succ(x) or related functions, but the problem is that this would only work on discrete or physical types. The type "real" is not one of these. Could someone give me some ideas how to go about this? Thanks, and Happy Holidays... Arpad ========================================================Received on Wed Dec 20 17:28:50 2006
This archive was generated by hypermail 2.1.8 : Wed Dec 20 2006 - 17:29:09 PST