Jonathan, The two mechanisms ought to be completely equivalent. Hence, a return statement must update the variable associated with the function name, just like the assignment form. Arturo -----Original Message----- From: owner-sv-bc@eda.org [mailto:owner-sv-bc@eda.org] On Behalf Of Jonathan Bromley Sent: Thursday, March 01, 2007 2:00 AM To: sv-bc@eda-stds.org Subject: [sv-bc] Function return values SV-BC, Please accept my apologies if this has already been answered. In SystemVerilog we have two different ways to return values from a function: <function_name> = <expression>; return <expression>; As far as I can see, both methods can coexist in the same function. This yields an ambiguity for static functions. Does the "return <expression>;" form also, as a side-effect, update the <function_name> variable? Consider the following: module M; // functions in a module are static by default function int F(input bit B, input int I); if (B) return I; endfunction : F initial begin $display(F(0,3)); // displays '0' $display(F(1,5)); // obviously displays '5' $display(F(0,0)); // displays ????? end endmodule : M My understanding is that the implicit function_name variable 'F' is initialised to 0 like any int, hence the function's return value in the first call is reliably 0. But the second call executes a return statement. Does this, or does it not, update F and thereby influence the result of the third call? Thanks -- Jonathan Bromley, Consultant DOULOS - Developing Design Know-how VHDL * Verilog * SystemC * e * Perl * Tcl/Tk * Project Services Doulos Ltd. Church Hatch, 22 Market Place, Ringwood, Hampshire, BH24 1AW, UK Tel: +44 (0)1425 471223 Email: jonathan.bromley@doulos.com Fax: +44 (0)1425 471573 Web: http://www.doulos.com The contents of this message may contain personal views which are not the views of Doulos Ltd., unless specifically stated. -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean.Received on Thu Mar 1 02:15:07 2007
This archive was generated by hypermail 2.1.8 : Thu Mar 01 2007 - 02:15:25 PST