All, Sorry for beating this subject to death, but I have an even more exotic application for macros and string parameters which I would like to bring up in this thread. Suppose you want to write a module which is nothing more than a simple voltage source. However, you want to allow the user of this module to pass in the equation to this source as a string parameter. The only restriction is that the string parameter can only contain any valid Verilog-A(MS) syntax. V(n1, n2) <+ expression_passed_in_from_the_calling_line; Well, the string parameter is still a type of string, so even though it is a constant string, it would not be usable in the code of the voltage source as "code text". However, an expanded macro will work, because after expansion, the macro text is "just text", not a string type. `define myEQ (2.0 + 3.0) / 2.0; V(n1, n2) <+ `myEQ; Now comes the big question. What happens if I use an argument for the macro, which is passed in as a string parameter? parameter string EQ_argument = "(2.0 + 3.0) / 2.0"; `define myEQ(EQ_argument) EQ_argument V(n1, n2) <+ `myEQ; Is the EQ_argument still a string type after the macro expansion or is the compiler supposed to flatten it out to "just text"? Pictorially, what is the voltage source line supposed to look like after the expansion: V(n1, n2) <+ "(2.0 + 3.0) / 2.0"; or V(n1, n2) <+ (2.0 + 3.0) / 2.0; I would expect it to be the second one, but I ended up in a heated debate with the vendor on this one... What would the LRM say? Now that I realize that string parameters are constants, evaluated at compile (or elaboration) time, I would expect that the compiler would expand it to "just text" at compile time. Also note that it would be illegal to say: parameter string EQ_argument = (2.0 + 3.0) / 2.0; without the double quotes around the "string" on the right side of the equal sign, so the only way I could pass a string argument into the macro is with the double quotes. Are those double quotes supposed to be retained in the macro when it is expanded at compile time? After all, the quotes are not displayed on the screen if I say: $display("some text to be displayed"); so I wouldn't expect to get quotes when the macro is expanded either... I didn't find an answer to these questions in the LRM. Please help me to figure these details out. Thanks, Arpad =======================================================================Received on Tue Jul 26 10:25:35 2005
This archive was generated by hypermail 2.1.8 : Tue Jul 26 2005 - 10:25:36 PDT