Commit Graph

693 Commits

Author SHA1 Message Date
Jeff Young 62bec69d8c Migrate field text attrs from legacy fields.
Fixes https://gitlab.com/kicad/code/kicad/issues/13323
2022-12-30 23:41:46 +00:00
Jeff Young d50b3550af Signals header is repetitive. 2022-12-28 10:40:23 +00:00
Jeff Young ef6001bfe6 Use consistent terminology: opposite of Add is Remove.
Note: violating string freeze because this change should ease translation,
not make it harder.
2022-12-28 10:40:23 +00:00
Jeff Young e11d39b0f2 If magnitude or phase is specified, don't add both.
Fixes https://gitlab.com/kicad/code/kicad/issues/13202
2022-12-28 10:40:23 +00:00
Jeff Young 3767716f20 Menu IDs of 0 don't work on Mac. 2022-12-28 10:40:23 +00:00
Jeff Young 572c10b2c4 If we don't recognize a var then it's an error, not 0.0. 2022-12-27 13:50:44 +00:00
Jeff Young 39a23fa9bc Only eval numeric properties.
Fixes https://gitlab.com/kicad/code/kicad/issues/13201
2022-12-27 13:50:44 +00:00
Jeff Young 80f3abe082 Event safety.
Sentry crash probably happens when an update title event fires either
too early or too late to have a simulator or simulator settings.

Sentry issue https://sentry.io/organizations/kicad/issues/3669444623/events/fce0179f7d5e4ff3a7dbb0d90a0570b4/
2022-12-26 20:33:04 +00:00
Jeff Young 424cdf6699 Overflow safety.
Sentry issue https://sentry.io/organizations/kicad/issues/3419671947/events/11212297e66c47c7af7144b5f075e88c/
2022-12-26 20:33:04 +00:00
Jeff Young bf1c4e7bcd Allow translation of simulation error messages. 2022-12-24 11:30:56 +00:00
Jeff Young 6f44468385 Fix more lifetime issues in simulator tuning.
Fixes https://gitlab.com/kicad/code/kicad/issues/13257
2022-12-23 22:03:24 +00:00
Jeff Young 981254543a Allow line-continuations in name=value parameters.
Fixes https://gitlab.com/kicad/code/kicad/issues/13255
2022-12-23 20:05:16 +00:00
Jeff Young 8069e5d5d6 Fix sim bug running a command the first time when no command in doc.
Fixes https://gitlab.com/kicad/code/kicad/issues/11366
2022-12-23 18:21:26 +00:00
Jeff Young bfd3b40672 Bug fixes for tuning.
1) Don't save SCH_ITEM pointers in long-lived structures.  Use KIIDs
   instead.

2) Use the correct sheet for the referenced item, not the current sheet.
2022-12-23 17:40:36 +00:00
Jeff Young 604d7a72d6 Fix bug in tuning when value is stored in Value field. 2022-12-23 17:40:36 +00:00
Jeff Young 3f49fa5361 Don't write sim.params for library model unless we actually have overrides. 2022-12-23 12:46:18 +00:00
Jeff Young cd7be966c0 Fix typo when un-escaping parameter name. 2022-12-23 12:46:18 +00:00
Jeff Young 7f60b87d1d Implement fallback models for SPICE .lib models that we can't parse. 2022-12-22 22:35:09 +00:00
Jeff Young 7abfa46531 Inferred sim value improvements, and a unit test for them. 2022-12-21 17:03:49 +00:00
Jeff Young e64852c833 Clearer naming. 2022-12-21 17:03:46 +00:00
Jeff Young e7e3f3bced SIM_MODEL code simplification.
1) Reduce API surface.
2) Prefer for(int) loops when what we're looking for is the index of
   the item to be found
3) Move "_" escape processing to SIM_MODEL_NGSPICE (which is the only
   model which uses the escape mechanism)
2022-12-21 17:01:58 +00:00
jean-pierre charras 8e4911bba2 Simulation: make a few errors thrown from PEGTL a bit more understandable. 2022-12-20 18:54:14 +01:00
Jeff Young 8db015bc0f Accept thousands separators in inferred values. 2022-12-19 20:05:54 +00:00
Jeff Young 58ce0bb804 Simulation bug fixes.
1) Use C-locale when converting output of parsers to strings.

2) InferSimModel() must run on local copy of fields, not the fields in
the symbol (which might be different if they've already been edited in
the Symbol Properties Dialog, for instance).

3) InferSimModel() should accept a deviceType already set to RLC.

4) Don't output trailing decimal separators if there's no fraction.
2022-12-19 18:14:13 +00:00
Jeff Young cbb70f0da1 Formatting and CLang-Tidy warning reduction. 2022-12-19 13:51:49 +00:00
Jeff Young a3a2e2e5b1 Update demos and legacy qa files SpiceMapping -> Spice_Node_Sequence.
Also removes migration in the code as it will no longer be needed.
2022-12-19 12:04:53 +00:00
Jeff Young 04f50ce687 Generate default pinMap from symbol's pins when we don't know SIM_MODEL's pins. 2022-12-19 11:40:52 +00:00
Jeff Young df8eb59854 Don't use SPICE_MODEL_SUBCKT::CreatePins to crate a default pinMap.
(It creates a fully-unconnected map on the premise that it's easier
to add a pinMap than to edit one.  This is probably no longer true
now that you don't have to un-assign a pin before re-assigning it.)
2022-12-19 11:40:52 +00:00
Jeff Young 1ce6cd6d4d Naming clarity. 2022-12-19 01:51:24 +00:00
Jeff Young 7433322778 Handle a couple more legacy formats found in legacy_sallen_key demo. 2022-12-19 01:47:23 +00:00
Jeff Young b06c245b8f Don't double-add DC parameters.
(Remember that DC's inlineTypeString used to be "".)
2022-12-19 01:19:55 +00:00
Jeff Young 7192c565b8 Add simple VI model inference. 2022-12-18 22:54:12 +00:00
jean-pierre charras a9acb2e215 Fix incorrect format in a wxString::Format() 2022-12-18 20:30:15 +01:00
Jeff Young 8324c0b0cc Fix event order bugs in Sim Model Editor dialog.
onParamGridChanged was firing before CommitPendingChanges which meant
the edited value didn't get saved if the editor was still open when
OK was clicked.
2022-12-17 22:33:00 +00:00
Jeff Young 321de57d7c Bug fixes for simulator.
1) Finish removing pin-count based APIs.  We need to know the pin names
as well, not just the count.

2) Fix a bug in the regexp for SPICE functions to allow both lowercase
and uppercase function names

3) Move CreatePins() overrides to the new API so that we get pins on
raw SPICE models.

Fixes https://gitlab.com/kicad/code/kicad/issues/13190
2022-12-17 20:29:24 +00:00
Jeff Young 6b70c679cf Migrate more V6 SPICE syntax to V7.
Also fixes various bugs if symbols contained non-indexed pin numbers.
We really need to know the actual pin names when creating models, rather
than just assuming 1, 2... etc.

Fixes https://gitlab.com/kicad/code/kicad/issues/13183
2022-12-17 15:23:51 +00:00
Jeff Young dba3c589d0 More bug fixes for escaped model parameters.
Note that this whole escaping thing seems like a bad idea to me, but
I don't fully understand the difference between model parameters and
instance parameters so I don't know if there's a better way to handle
it or not....More bug fixes for escaped model parameters.

Note that this whole escaping thing seems like a bad idea to me, but
I don't fully understand the difference between model parameters and
instance parameters so I don't know if there's a better way to handle
it or not....More bug fixes for escaped model parameters.

Note that this whole escaping thing seems like a bad idea to me, but
I don't fully understand the difference between model parameters and
instance parameters so I don't know if there's a better way to handle
it or not....More bug fixes for escaped model parameters.

Note that this whole escaping thing seems like a bad idea to me, but
I don't fully understand the difference between model parameters and
instance parameters so I don't know if there's a better way to handle
it or not....More bug fixes for escaped model parameters.

Note that this whole escaping thing seems like a bad idea to me, but
I don't fully understand the difference between model parameters and
instance parameters so I don't know if there's a better way to handle
it or not....More bug fixes for escaped model parameters.

Note that this whole escaping thing seems like a bad idea to me, but
I don't fully understand the difference between model parameters and
instance parameters so I don't know if there's a better way to handle
it or not....More bug fixes for escaped model parameters.

Note that this whole escaping thing seems like a bad idea to me, but
I don't fully understand the difference between model parameters and
instance parameters so I don't know if there's a better way to handle
it or not....More bug fixes for escaped model parameters.

Note that this whole escaping thing seems like a bad idea to me, but
I don't fully understand the difference between model parameters and
instance parameters so I don't know if there's a better way to handle
it or not....More bug fixes for escaped model parameters.

Note that this whole escaping thing seems like a bad idea to me, but
I don't fully understand the difference between model parameters and
instance parameters so I don't know if there's a better way to handle
it or not....

Fixes https://gitlab.com/kicad/code/kicad/issues/13179
2022-12-16 16:34:41 +00:00
Jeff Young 08a8a20794 Sort pins in numeric order before attempting to match to SPICE model.
Fixes https://gitlab.com/kicad/code/kicad/issues/13164
2022-12-16 14:18:44 +00:00
Jeff Young 24786fe0e9 Fix multi-unit symbol bugs.
1) SPICE pins need to include all units
2) Already-seen-unit-x needs to be reset when getting netlist again.

Fixes https://gitlab.com/kicad/code/kicad/issues/13164
2022-12-16 13:57:46 +00:00
Seth Hillbrand 6d5a9153ab Move resolve function to general usage
Libraries are created multiple times, so we need to resolve the library
locations each time

Fixes https://gitlab.com/kicad/code/kicad/issues/13083
2022-12-15 15:34:48 -08:00
Jeff Young a41f27a022 Silence Coverity. 2022-12-15 18:14:19 +00:00
Seth Hillbrand bb7682f913 Resolve using env/project if lib isn't found
Relative include commands resolve in the following order:

1. local to the file from which they are included
2. local to the project
3. local to the SPICE_LIB_DIR directory

Fixes https://gitlab.com/kicad/code/kicad/issues/13083
2022-12-15 09:41:25 -08:00
Seth Hillbrand f0a8182532 Update for wx3.0 compatibility 2022-12-14 16:41:52 -08:00
Jeff Young b2e512bfab We must infer a pinMap when inferring other fields for RLC passives.
Fixes https://gitlab.com/kicad/code/kicad/issues/13162
2022-12-14 23:23:41 +00:00
Jeff Young a2ba9137b8 Use only first letter of prefix for RLC primary value name.
Fixes https://gitlab.com/kicad/code/kicad/issues/13162
2022-12-14 23:23:41 +00:00
Seth Hillbrand 10a3d57193 Add sim_lib callback to resolve embeded libs
Also teach parser to look for include directives in libraries

We get KiCad variable resolution in include pathnames for free.

Fixes https://gitlab.com/kicad/code/kicad/issues/13083
2022-12-14 13:31:41 -08:00
jean-pierre charras cdcf875ec0 sim_model: Fix another not handled exception that fully freeze Eeschema.
Can happens with schematics with old sim parameter syntax.
Fix also another crash in sim_model.
2022-12-14 17:47:20 +01:00
Jeff Young ce6378fed3 Use symbol pin names for left-hand-side of auto-generated pinMaps. 2022-12-14 15:13:29 +00:00
Jeff Young 6abdfc76da Replace 1:1 pin map on legacy conversion now that we can accept indexes.
Fixes https://gitlab.com/kicad/code/kicad/issues/13152
2022-12-14 14:22:35 +00:00
Jeff Young 77998d7c51 Better fix for not selecting all of netlist. 2022-12-14 14:13:25 +00:00
Jeff Young 13d9b061ee Don't select all of netlist when showing it in simulator. 2022-12-14 13:36:29 +00:00
Jeff Young e41b0775db Fix a bug with underscores being appended to spice param names. 2022-12-14 13:36:29 +00:00
Jeff Young 50ccc4e6da Fix issue converting legacy SPICE models.
1) if a legacy model references a library then we need to see if said
   libraray exists and read model from it if so
2) legacy node ordering is by index, not pin name
3) we can't auto-generate a pin map when we don't know the pin names,
   so don't try
2022-12-14 13:36:28 +00:00
jean-pierre charras bbdb30135e sim_model: Fix a not handled exception that fully freeze Eeschema.
Can happens with schematics with old sim parameter syntax.
2022-12-13 11:15:02 +01:00
Jeff Young ca5c0e2ac5 Fix typo.
Fixes https://gitlab.com/kicad/code/kicad/issues/13137
2022-12-12 14:42:45 +00:00
Jeff Young 419fe236ad Fix logic error in parsing sim command, and DC source types in dialog.
Fixes https://gitlab.com/kicad/code/kicad/issues/9064
2022-12-11 23:12:55 +00:00
Jeff Young b2498f5673 Coding standards & formatting. 2022-12-11 23:12:55 +00:00
jean-pierre charras bdf13ade7a Fix a compil issue on linux, round 2 2022-12-11 20:43:10 +01:00
jean-pierre charras 32995a31c6 Fix a compil issue 2022-12-11 20:19:56 +01:00
Jeff Young 5c53daadb0 Mostly coding standards, but also quote codemodel names before passing to spice.
Fixes https://gitlab.com/kicad/code/kicad/issues/12687
2022-12-11 18:42:57 +00:00
Jeff Young 9c129ed03f More dialog adjustments for wx 3.2. Also renames files to match dialog. 2022-12-11 15:49:29 +00:00
Jeff Young 56aae7a147 Reduce compiler warnings. 2022-12-11 13:39:59 +00:00
Jeff Young 3581a9773f Move simulator settings disposal earlier so it happens before parent.
Fixes https://gitlab.com/kicad/code/kicad/issues/12370
2022-12-11 01:32:20 +00:00
jean-pierre charras be8f99e8fe Another fix to avoid conflict names issues with mingw + pegtl.
Fixes #13118
https://gitlab.com/kicad/code/kicad/issues/13118
2022-12-10 14:28:05 +01:00
jean-pierre charras e74654a20f Minor fix to avoid conflict names issues with mingw + pegtl. 2022-12-10 08:21:35 +01:00
Jeff Young 1599490197 Formatting. 2022-12-09 22:25:14 +00:00
Jeff Young 1baec20cf6 Handle SPICE <-> SI conversions in inferred models.
Fixes https://gitlab.com/kicad/code/kicad/issues/13112
2022-12-09 22:02:52 +00:00
Jeff Young 60c937186a When migrating simulation models update value to a reference. 2022-12-09 20:24:25 +00:00
Jeff Young 05b9836f60 Remove ugly hack of passing SCH_SYMBOL as parent of LIB_FIELD array.
Also adds simulation model inference to Symbol Editor's Simulation Model
Editor, and adds write-back from both Simulation Model Editors to their
parent Symbol Fields Editor dialogs.

Fixes https://gitlab.com/kicad/code/kicad/issues/12505
2022-12-09 20:24:25 +00:00
Jeff Young 3ae404f764 Move model inference to SIM_MODEL so it can also be used for behavioral models.
Fixes https://gitlab.com/kicad/code/kicad/issues/12505
2022-12-09 20:24:25 +00:00
Jeff Young 8931e55dd2 Templatize MigrateSimModel() so it can be used on LIB_SYMBOLs as well.
Fixes https://gitlab.com/kicad/code/kicad/issues/13080
2022-12-08 23:57:43 +00:00
Jeff Young e8980e9024 Centralize SPICE lib path resolution and support SPICE_LIB_DIR.
Fixes https://gitlab.com/kicad/code/kicad/issues/13081
2022-12-08 23:57:42 +00:00
Jeff Young bb6544914e Bring simulator file menu commands more in line with rest of Kicad. 2022-12-08 23:57:42 +00:00
Jon Evans 5251ea6f27 Prevent crash on exit due to simulator settings being double freed 2022-12-07 21:04:49 -05:00
Jeff Young b15913bd53 Support env variables in spice library paths.
Also removes a bunch of std::string stuff from the file handling in the
simulator.  All our file handling, env variable expansion, project path,
etc. stuff is wxString based, and jumping through std::string in between
just makes it more complex and increases the potential bug surface.

Also fixes a bug where you'd get two error messages when a spice model
library wasn't found.

Also fixes a bug where you'd get a spice model library not found error
when the text field was empty.

Also fixes a bug where we'd try to absolutize a path starting with an
unresolved text or environment variable.  If the path starts with a
variable it's probably absolute, and tacking on the project path in the
error message just obfuscates things.

Fixes https://gitlab.com/kicad/code/kicad/issues/13082
2022-12-07 15:07:25 +00:00
Jeff Young 4872dd7238 Don't put empty lines in the workbook.
Fixes https://gitlab.com/kicad/code/kicad/issues/12299
2022-12-07 11:39:47 +00:00
Jeff Young 69448afb47 Don't run simulation twice when the sim command is overridden.
Fixes https://gitlab.com/kicad/code/kicad/issues/12731
2022-12-07 01:34:56 +00:00
Jeff Young 3836ec481f Add fixups for legacy syntax used during 7.0 development. 2022-12-06 16:01:18 +00:00
Jeff Young 39ad7c8205 Formatting and Kicad naming conventions. 2022-12-06 16:01:18 +00:00
Jeff Young 38906397d2 Move V6->V7 sim model migration from sheets to screens.
Also moves passive RLC inference out from migration to just-in-time
creation for the simulator or netlisting.

Also fixes a version guard mismatch because the spice migration was
done inside UpdateSymbolInstances (which has its own version guard).

Also changed UpdateSymbolInstances to UpdateSymbolInstanceData so
someone else in the future doesn't think it's a general-purpose symbol
instance updater.
2022-12-06 16:01:18 +00:00
Jeff Young f8e0a272c0 Remove a bunch of 'auto'. 2022-12-06 16:01:18 +00:00
Fabien Corona 4c76082f77 "Sim Params/Settings" -> "Sim Command"
The window only really sets the simulation command.
In the future, we might want a simulation setting window with things such as SPICE optimizations.
2022-12-05 23:12:04 +00:00
Jeff Young 8e4cd1e1a6 Check for sheet directive changes when running simulations.
Fixes https://gitlab.com/kicad/code/kicad/issues/10486
2022-12-05 20:03:42 +00:00
Jeff Young 7e1fecaf2e Formatting. 2022-12-05 20:03:42 +00:00
Jeff Young b7d41e0e56 Update simulator with NUMERIC_EVAL, decimal separator processing, etc.
Also includes fixes for instance data and resolving of textvar
references.

Also includes virtual d'tors for IBIS parser to get rid of all the
compile warnings on CLang.

Fixes https://gitlab.com/kicad/code/kicad/issues/12357
2022-12-05 12:40:29 +00:00
Jeff Young 1855885d1e Gracefully handle spice models not recognized by KiCad.
Fixes https://gitlab.com/kicad/code/kicad/issues/12689
2022-12-04 21:06:35 +00:00
Jeff Young f29f0c5c0a Don't push a model that didn't load.
Fixes https://gitlab.com/kicad/code/kicad/issues/12689
2022-12-04 21:06:35 +00:00
Jeff Young 672927e183 Clearer error message. 2022-12-04 21:06:35 +00:00
Jeff Young bed22272e5 Supply default values for random uniform voltage sources.
Fixes https://gitlab.com/kicad/code/kicad/issues/12861
2022-12-04 21:06:35 +00:00
jean-pierre charras 8ab8a48657 fix order of includes to avoid conflicts with a Windows header. 2022-12-03 10:59:46 +01:00
Fabien Corona bd235048f9 sim GUI: remove "Adjust value" checkbox.
We had a change in notation and this checkbox became useless.
2022-12-03 08:28:43 +00:00
Fabien Corona 6e45987005 fix build warning 2022-12-01 20:33:51 +00:00
Mikolaj Wielgus f38c5d8cd0 Sim: Add virtual destructor to SIM_SERDE 2022-12-01 17:18:55 +01:00
Mikolaj Wielgus 4ec7ea376e Sim Ibis: Minor code style changes 2022-12-01 17:13:37 +01:00
kliment 0f09172902 Eeschema: ibis_parser - Fix undefined behavior due to pointer aliasing in isNumberNA 2022-12-01 15:44:38 +00:00
Mikolaj Wielgus d2adcdfde0 Sim: Add "number of bits" parameter to KIBIS PRBS model and some more fixes
The other fixes:

- PRBS's `m_bits` should be an integer.
- Fix some references to outdated parameter names.
2022-12-01 09:19:41 +01:00
Mikolaj Wielgus 7d207c5d2f Sim Ibis: Change some strings for consistency 2022-11-30 17:38:09 +01:00
Mikolaj Wielgus e39c0b20ea Sim: Universally initialize enum parameters with their default values 2022-11-30 12:45:59 +01:00
Mikolaj Wielgus 39cd9f8980 Sim: Fix Sim.Params field generation logic
Don't generate the first parameter (e.g. for KIBIS it was 'vcc=""') when
it is empty in models without primary value.
2022-11-30 12:45:58 +01:00
jean-pierre charras f3aff63726 Fix minor compil warnings 2022-11-29 20:05:58 +01:00