Project blog‎ > ‎

Builtin library code posted

posted Jan 26, 2010, 12:34 AM by Gregory Kiesel   [ updated May 21, 2010, 3:15 AM ]
I've added the built-in library feature.  The existing microstrip, stripline, and lumped element components now have compiled versions of themselves.  Code seems to be running 30% to 35% faster depending on the run.  I still need to tweak the code to make folding the primitive XML files into compiled code easier, but that's on my list.  Specifically, the way I generate primitives off of a combination of existing primitives needs to be updated (following the new rules for primitive XMLs) and I need to cut out some of the redundant paths in the network diagram.

There is a difference between the built-in (pre-compiled) components and the XML (compiled at run-time into byte code) components.  I expected some differences in the outputs due to precision, while the same math is used the numbers are processed differently. The differences are indeed both small and not the result of a bug.

The next efficiency to be had is from the port impedance transform for using non-50 ohm ports.  This doesn't effect circuits that use only 50-ohm ports, but does take something like 10% to 20% of the run time for non-50 ohm runs.  When the transform code was written I was just trying to get it correct and quick, so I suspect I can get it going a lot faster.  Again, I don't want to fold in an existing library that makes cross-platform compiling difficult.

Writing new primitive files is still fairly simple, just a few constraints have been added to make compilation possible:
  1. Use pow(x,y) instead of (x^y)
  2. Don't use integers: write "1.0" instead of "1", "50.0" instead of "50", etc.
  3. Remember variables are inherently complex numbers, so comparisons have to be in the form of: "real(length) > 0" and not "length > 0"
These are not important considerations until the XML file gets folded into builtin, but have some consideration for future compatibility.  Finally, please avoid using "log", prefer to use "ln" or "log10"- it makes your math much less ambiguous.  Probably the next time I'm in the code and remember it, I'm going to remove "log" as a valid function.

Comments