Does Xyce allow you to refer to nodes inside subci...
# xyce
m
Does Xyce allow you to refer to nodes inside subcircuits? I don't see references to this in the documentation, but this is a standard feature of spice. If I try to measure a subcircuit signal like this:
Copy code
.meas tran delay_sen0 TRIG v(clk0) VAL=2.5 FALL=1 TD=55.0n TARG v(xsram.s_en0) VAL=2.5 RISE=1 TD=55.0n
I get an error:
Copy code
Netlist error: Function or variable V(XSRAM.S_EN0) is not defined
Are there a set of spice regression tests/examples anywhere? This might be useful for figuring out syntax peculiarities through examples.
Eeep, it requires ":" as the separator? Strange. That is incredibly non-standard...
e
Hah, yes, “:” is the separator.
m
I don't think any spice simulator I've seen uses that...
e
Hmmm. There was a period of time where we weren’t particularly trying to match other simulator syntax. I mean, we started, kind of, from spice3, but then diverged for a while. I think the “:” separator got chosen during that period.
That period was a while ago, like 2005-ish.
m
I'm looking at patching the parser right now 🙂
It is likely easy to accept both
e
The main problem with patching will be that there will be multiple places that need modification. It shouldn’t be that way, but it currently is.
m
Ah, there isn't one netlist parser?
Maybe I'll just add an option to my tool.
e
Expression parsing, for example, is entirely handled (separately from the rest of the netlist parsing) via flex/bison in Xyce/src/UtilityPKG/ExpressionSrc/ExpressionLexer.l and Xyce/src/UtilityPKG/ExpressionSrc/ExpressionParser.yxx
m
Yeah, I was looking at that. We can add a token that is TOK_COLON_OR_PERIOD
e
This is part of the reason we’ve been developing XDM. The plan is to eventually have XDM become the Xyce parser.
m
I spent 30 min trying to compile XDM and gave up 😛
😀 1
e
But for now it is a separate file-translator tool.
Ah.
m
I'll just patch my tool.
e
OK. Sorry!
By the way, you asked much earlier about regression tests. The answer is YES, we have a large test suite. It is in a separate git repository. https://github.com/Xyce/Xyce_Regression
👍 1
Regarding the expression parser, that is easy to modify with a new token. The older netlist parsing code is scattered over many files in the Xyce/src/IOInterfacePKG directory, and is much harder to digest. That code was NOT written using a parser generator and is does not have a compact grammar file. The individual functions aren’t so bad, but they aren’t all in a single compact place.
So, that is actually one reason for switching to XDM. It is written using Boost Spirit parser framework. So, the grammar should be easier to encapsulate.
v
Might I recommend if you start messing with hierarchy separators that you allow more than 2 choices? ":" would not be the only nonstandard separator -- I seem to recall Spectre is partial to "/". I'm thinking a syntax something like
.option hier_separator="."
that allows everyone's favorite punctuation mark, among other potential characters. An allowed list could be provided in the documentation.
Something else I would like to add about colons: There's a thread on the ngspice Sourceforge mailing list archives. Someone created a loop gain simulation with a
.loop
simulation card. To include differential loop gain, he created a balun element, but ran into the problem that we're out of letters for new elements. At the bottom of the thread, the suggested syntax for a new element (and thus, what could be a generalized means of expanding the spice instance syntax) is to indicate the balun with
:balun:<instance-name>
. If anyone has connections to the ngspice developers, it might be worth pointing out xyce's conflicting hierarchy separator syntax. ngspice .loop analysis thread
e
Good point about allowing more than one type of separator. That’s the type of solution that we’ll go with on Xyce. We are currently in the (slow) process of replacing our parser with something that will allow the parser to easily swap out different grammars. That way, switching between Hspice/Spectre/etc compatibility will be a lot easier. For the time being, we have a tool, XDM, which is a stand-alone application for translating the netlists of various other simulators to Xyce. Eventually, that tool will form the basis for the Xyce parser, but we aren’t there yet.
The old Xyce parser (which is still in place), was hand written and doesn’t have a clean grammar file. So, as we worked on that, the easiest way to support compatibility with other simulators was to basically support a “superset” of capabilities. We did that on a case-by-case basis. This was mostly fine, except that of course sometimes the syntax of one simulator conflicts with the syntax of another, and they cannot be made to co-exist.
For unresolvable netlist compatibility issues, we have a command line option that takes care of some of them. It is
Xyce -hspice-ext all netlist.cir <return>
This option forces Xyce to use the “Hspice” method of doing things when there is an unresolvable conflict with Xyce’s standard syntax. One example that is handled by this option is the “atto” unit suffix. In Hspice a number followed by “a” means “atto” which means 1e-18 multiplier. But in many other simulators “a” just means Amps unit. There isn’t an easy way to have the parser figure out which of these two things is intended.
Regarding the running out of letters fo new elements, we had that issue a long time ago on Xyce. The solution we came up with, many years ago, was to parse “y” devices differently. So, Y devices have extra fields which allow many different types of devices to be specified using that syntax. We’ve mostly used it for unorthodox device models that aren’t typically found in other simulators. Examples of this include neuron models, TCAD models, ROM models, reaction-network models, and any models specified via our python API.
Anyway, back to “:” vs “.” for separators. It will be possible to support this, but it may take a bit of work for various reasons. But either way, we’ll get it in there somehow.
Here is a small update on the colon separator. One of my colleagues did some digging. The choice of “:” for a separator dates back to Spice3, which is the code we were primarily using as a reference 20 years ago. If you run spice3 even now, its raw file outputs use a colon. So, we didn’t just make it up, but we never reconsidered it after that, and most codes that are forks of spice3 switched from the colon to the period at some point. That (obviously) includes ngspice, but also includes commercial tools like Pspice. Using colons has made some things more difficult for us, so we should probably just switch to using a period like everyone else. In particular, parsing the ternary operator in expressions gets tricky when the variable names are allowed to include colons, so it would be nice for that issue to go away. Anyway, I am kind of surprised that nobody has complained about this issue before now, but there we are.
m
I think most people are just used to the quirks of different spice variants. However, when you start to use it in automated ways it becomes an issue
e
Yes, that makes sense!