<@U0175T39732> I got sidetracked into a separate i...
# xyce
e
@User I got sidetracked into a separate issue on Monday so I’ve been focusing on that. The short answer is that it is easy to do a “quick fix”, and I’ll probably do that for now. There is a more comprehensive issue that this work has illuminated for me, that I’ll also (eventually) need to fix. I was trying to figure out if I had time to do the comprehensive fix, or the quick one. But I’ll probably just do the quick one for now and revisit this later.
👍 1
r
Out of curiosity what is the "more comprehensive issue" you're referring to?
m
He was talking about the issue of dependent vs independent parameters. They need to solve when and how often to apply the scaling in that case.
r
Ah yes, that does muddy the waters. How does ngspice handle it?
m
No idea, sorry 🙂
e
There’s even more to the comprehensive issue than that, but the details might not be that interesting here. Basically, I want to make sure that the “setup” code in device models is called as little as possible, because those are actually pretty expensive functions. If you naively call them (say) at every time step, then the run time gets like 10x worse, for example. Fortunately, I’m not doing anything that bad. But basically, you only want to execute the setup code on a device if a parameter it depends on actually changes. I completely rewrote expression and parameter handling last year and I don’t have this perfectly optimized yet. So, this issue (with the scale factor) overlaps this larger issue.
I haven’t browsed the ngspice code for this particular issue. My guess is they handle it pretty well.
Another related issue that I need to think about is when using model binning, if L and/or W get changed, then potentially the device has to be re-binned, depending on how large the change was.
Basically, model binning and “scale” are relatively new additions to Xyce, and I don’t think I thought thru how they would interact with sampling very well. But I’ll get it fixed soon.
r
Model setup can absolutely be a pain in the neck. I am interested in what the "dirty fix" for the scale issues is. Have you pushed it to any of the branches?
e
The dirty 2-line fix is simply to hack the BSIM4 setup function to only let it apply the scale factors one time. That will fix this use case, where agauss is being used, but no sampling is being performed. But it will still be broken if sampling is performed and applied to scaled L,W parameters. Unscaled L,W could be sampled just fine. And other parameters could be sampled just fine. The only broken thing would be sampling L,W when “scale” is applied. Then scale has to be correctly applied every time L or W is updated.
So, the dirty fix is dirty enough that I hadn’t decided if I wanted to push it anywhere or not. I mostly did it as an experiment/diagnostic to prove to myself that my theory of the bug was correct.
r
Understandable if you have to play with the Xyce sourcecode itself (breaking sampling for the sake of scaling is...icky). Has anyone had any success unraveling the include trees and manually removing/appropriately applying the the scale factors?
m
@Robert Rogers I don't think anyone is working on that.
r
ngspice's dialect seems relatively compatible with Xyce's barring the scaling issue. performance aside, it'd probably be useful to have a xyce-native branch of the current ngspice netlists. Getting the scaling factors right might end up being a chore though. Has anyone tried to your knowledge?
e
Ultimately, fixing this “the right way” isn’t that hard to do. It just takes a little more typing and testing than I had time for earlier in the week. But I’ll get on it.
r
Are you aware of any tweaks necessary to the netlist codebase in the main branch PDK to make it interpretable by xyce (minus the scaling bit)?
Or maybe there's just a branch i could switch to?
e
If you are talking about Xyce branches (that are public anyway) I think the master branch over on github is as good as it gets the moment.
My goal is to make Xyce as compatible with Sky130 as possible, and to make that happen this summer.
We synchronize our internal master branch with the public github branch roughly once a week, on Mondays. So, if I were to (hypothetically) get this fixed by COB tomorrow (Friday) and push it to our internal develop branch, then (again hypothetically) if our regression testing is clean over the weekend then my fix would get pushed to github on Monday.
The exception to the above schedule (sync on Mondays) is if something goes wrong in testing over the weekend. Or, if the person who normally handles it is on vacation or out sick. Or, if we’re within days of a major code release. But otherwise, if testing is clean, the sync happens.
Note, sometimes “testing going wrong” really means “the Jenkins server crashed” or something like that. It isn’t always because the code broke.
r
I was more referring to the SPICE netlists in https://github.com/google/skywater-pdk-libs-sky130_fd_pr/ To my knowledge those are all in the ngspice dialect which (I believe) has a few syntactical differences vs. Xyce's dialect. I was curious whether anyone had done the translation necessary to get them to run with Xyce (barring the aforementioned scaling bug)
And whether or not those SPICE netlists were sitting on a branch somewhere
e
Ah. Then you might find this comment from @Matthew Guthaus useful, if you haven’t seen it already: https://skywater-pdk.slack.com/archives/C01TLV579C5/p1623177011093000
m
@Robert Rogers i've been working with tim edwards on this in open_pdks https://github.com/RTimothyEdwards/open_pdks/issues/124
heh
😀 2
it's not done yet due to this issue
r
The scaling issue that is?
m
yes
i removed the agauss locally for a quick fix
r
Gotcha. Looks likea few perl oneliners do most of the work. I'll run those on my local copies and then try and unravel the include trees/get the scaling factors down for...probably just an nfet and a pfet. that would be sufficient for my needs. I'll keep an eye out for when the scaling bug gets fixed. Thanks all. I'll review the above links. If you remember any niceties or finicky bits you had trouble with please lmk. Otherwise i'll report back with the results of my "by hand" scaling fix for a small subset of the pdk.
m
And this one gets rid of the scaling problem by removing agauss everywhere:
Copy code
perl -p -i -e "s/\+MC_MM_SWITCH.*\}/\}/" */*/*/*.spice
r
That would be good for now...actually.
If my management wants to see MC stuff before the fix is implemented i'll go back to getting the darn things working by hand. Or if there's interest here in seeing how that goes.
Actually does removing agauss everywhere solve the scaling issues? Won't there be conflicts between
.scales
from different scopes in the include trees?
m
There is only one scale in the libraries
But I don't think you can remove it, because some calculations inside are made assuming it
r
Sorry for my ignorance, but what is it about agauss that throws off the calcs?
Ok, nope I managed to figure it out. nevermind.
m
agauss causes the scale factor to be applied twice
so everything is then too small by orders of magnitude
1e-6 to be precise
r
Yep, i got there eventually.
Once in the parsing the expression and once again in the BSIM setup
Note that the perl fixes here don't address some ngspice vs xyce differences in terms of analysis and output specification. This matters primarily for the "test" netlists provided for all primitives.
If I end up making a patch, i'll be sure to share it here
👍 1
m
@Robert Rogers These were just the changes needed to get a basic transient simulation of transistors working.
You can also comment on that issue in GitHub that I started.
e
@Matthew Guthaus the conflicts between agauss and scale have been fixed in my local branch of Xyce. The fix should appear in the next synchronization we do with the public git repo. Knock on wood, that should be Monday.
🎉 2
r
Thanks for the hard work/making the time!