Re: compiler directive with formal arguments

From: Geoffrey.Coram <Geoffrey.Coram_at_.....>
Date: Fri Nov 03 2006 - 06:31:39 PST
Mantis 1119 looks to address a related issue.  If I have

   `define FOO BAR

and then later have 

   $strobe("here I want `FOO\n");

Does the `FOO get replaced or not?  That's macro substitution
in a string, whereas Marq was asking about macro formal
argument substitution (and there's no ` in his string).

-Geoffrey




"Bresticker, Shalom" wrote:
> 
> Hi, I will get back to you on this Saturday nite or Sunday.
> At first glance, though, Mantis 1119 does address this.
> 
> Shalom
> 
> > -----Original Message-----
> > From: owner-verilog-ams@server.eda.org [mailto:owner-verilog-
> > ams@server.eda.org] On Behalf Of Geoffrey.Coram
> > Sent: Friday, November 03, 2006 3:24 PM
> > To: Marq Kole
> > Cc: verilog-ams
> > Subject: Re: compiler directive with formal arguments
> >
> > Marq -
> > I had a look in mantis and see that Shalom is assigned a few related
> > items, but I don't see your question addressed in 1119, 1053, nor
> 1333.
> >
> > I'm not sure what the bit about identifiers means, but one could
> > twist it to mean that the formal arguments are not replaced in a
> > string, just as
> >   parameter real mypar = 1.0;
> >
> >   $strobe("mypar = ", mypar);
> >
> > doesn't give you 1.0 = 1.0, because the identifier is not replaced
> > inside the string.
> >
> > -Geoffrey
> >
> >
> >
> > Marq Kole wrote:
> > >
> > > All,
> > >
> > > At least one simulator has a different interpretation of a compiler
> > directive with formal arguments than any of the others (known to me)
> do.
> > Consider the macro definition:
> > >
> > > `define UPDATE_XML_ELEMENT(file,param,value,delta) \
> > > if (delta) \
> > > $fwrite(file, " <instance name=\"%M\">\n  <parameter name=\"%s\"
> > value=\"%1.8g\" delta=\"%1.8g\"/>\n </instance>\n", param, value,
> > delta);
> > >
> > > Now I would expect that a call
> > >
> > > `UPDATE_XML_ELEMENT(update_file, "vth0", Vth, -delta_vth)
> > >
> > > to be expanded to:
> > >
> > > if ( -delta_vth) \
> > > $fwrite(update_file, " <instance name=\"%M\">\n  <parameter
> > name=\"%s\" value=\"%1.8g\" delta=\"%1.8g\"/>\n </instance>\n",
> "vth0",
> > Vth,  -delta_vth);
> > >
> > > Instead this tool expands it to:
> > >
> > > if ( -delta_vth) \
> > > $fwrite(update_file, " <instance name=\"%M\">\n  <parameter
> > name=\"%s\" Vth=\"%1.8g\"  -delta_vth=\"%1.8g\"/>\n </instance>\n",
> > "vth0", Vth,  -delta_vth);
> > >
> > > So it replaces also the occurrences of "value" and "delta" inside
> the
> > format string of the $fwrite system task.
> > >
> > > The weird thing is that the LRM 2.2 standard according to section
> > 11.3.1 only states that the scope of formal arguments extends to the
> end
> > of the line and that a formal argument can be used in the same manner
> as
> > an identifier. It nowhere exempts the contents of strings from formal
> > argument replacement. It is my feeling that this should be added to
> the
> > text.
> > >
> > > Then, on the other hand the text in 1364-2005 (section 19.3.1) is
> > exactly the same. Should we take the lead here?
> > >
> > > Marq Kole
Received on Fri Nov 3 06:31:56 2006

This archive was generated by hypermail 2.1.8 : Fri Nov 03 2006 - 06:31:57 PST