Commit Graph

30 Commits

Author SHA1 Message Date
Jeff Young a126d961d8 More dead code removal and a bit of formatting and const& for strings. 2023-02-22 10:45:27 +00:00
Jeff Young 68fe146861 Remove most of SIM_VALUE in favour of good old wxString.
This allows us to save the user's intent, including units, formatting,
and crucially variable references.
2023-02-22 10:45:27 +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 3836ec481f Add fixups for legacy syntax used during 7.0 development. 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
Mikolaj Wielgus e7c43ca20a Sim: Remove inference from Reference and Value 2022-11-18 08:39:15 +01:00
Mikolaj Wielgus 490069c5e6 Move (de)serialization of models into fields to new SIM_SERDE class 2022-11-11 03:08:32 +01:00
Mikolaj Wielgus aa0e3666d1 Sim: Skip param name when writing primary param in model's Value field 2022-10-26 09:03:02 +02:00
Mikolaj Wielgus 9b6cc6c505 Sim: Fix tuners 2022-10-24 11:04:47 +02:00
Mikolaj Wielgus 2475a703d6 Sim Model Editor: Checkbox for toggling inference 2022-10-16 05:10:57 +02:00
Mikolaj Wielgus c3d5b3b3e5 Sim: Only store device type in reference, not full model type
Instead of Reference="VSIN1", Value="dc=1 ampl=2 f=3", it's now
Reference="V1", Value="SIN dc=1 ampl=2 f=3".
2022-10-15 19:36:26 +02:00
Mikolaj Wielgus d9eb76eae0 Sim: Refactor SPICE_GENERATOR methods to accept a single SPICE_ITEM 2022-10-11 02:22:59 +02:00
Mikolaj Wielgus e4865ce543 Excise wxString from simulation 2022-09-22 07:41:52 +02:00
Mikolaj Wielgus 907ad27e7f Sim: Move SPICE_GENERATOR class to a new file 2022-09-15 05:26:23 +02:00
Mikolaj Wielgus e4c5bc6c66 Sim: Refactor Spice code generation to a new SPICE_GENERATOR class 2022-09-14 09:36:49 +02:00
Mikolaj Wielgus 3b3131ad74 Create class for voltage and current -controlled switches
Unfortunately, along the way it turned out that Ngspice's .probe alli
breaks current-controlled switches. So they won't work in that case for
now.
2022-08-29 03:49:41 +02:00
Mikolaj Wielgus 8a6a0ff7dc Allow inferred voltage/current sources to have a single float in Value
Update Opamp test to use this feature.
2022-08-24 06:19:38 +02:00
Mikolaj Wielgus 6fad25f8ed Allow mapping sim model pins to arbitrary string symbol pin numbers
This change removes the incorrect assumption that symbol pin numbers are
integers and are the same as indexes in the vector storing the symbol
pins.

"~" is now used to denote a floating sim model pin.
2022-08-22 08:13:26 +02:00
Roberto Fernandez Bautista 3e11506fa2 Fix a few unused variable warnings on msvc 2022-08-15 20:47:21 +01:00
Mikolaj Wielgus 0040ffc567 Convert strings to UTF8 before they are input to PEGTL
Otherwise there are QA failures under non-UTF-8 locales.
2022-08-10 14:20:52 +02:00
Mikolaj Wielgus 67476c330e Fix broken PEGTL include path 2022-08-08 17:50:42 +02:00
Mikolaj Wielgus 5096f5d8a9 Sim: Fix inference of RLC models with garbage suffixes
Garbage suffix is e.g. the "F" in "100uF".
2022-08-08 17:06:50 +02:00
Mikolaj Wielgus 7cf5138c63 Sim: Bugfixes, mostly for MS Windows compilation errors
Unfortunately, Windows headers define a lot of macros for common words,
so we had to rename some enums to not collide.

We also fix some of the many bugs related to the new simulation
architecture and the Spice Model Editor dialog.
2022-07-30 02:25:34 +00:00
Mikolaj Wielgus 739b9255d9 Sim Model Editor improvements
- Tab-switching,
- Automatic expansion of categories on tab-switch,
- Various minor simulation improvements,
- Various new simulation-related bugfixes.
2022-07-30 02:25:34 +00:00
Mikolaj Wielgus 6984f63af8 Sim: Transmission line models
Implement transmission line models and perform some adjustments to
the current models. Add some QA tests.
2022-07-30 02:25:34 +00:00
Mikolaj Wielgus fe38c622a9 Sim: Improvements to model serialization
Don't serialize parameters in certain models for default values. Infer
models from Value field for some kinds of models. Resolve synonyms when
loading models from Spice libraries.
2022-07-30 02:25:34 +00:00
Mikolaj Wielgus 6450ec6b85 Sim: Spice netlist exporter rewrite
Rewrite the spice exporter to work with the new simulation model
architecture and data model, with many bugfixes related to the latter
two along the way.
2022-07-30 02:25:34 +00:00
Mikolaj Wielgus ce84a48037 Sim: Implement loading Spice library files
Implement parsing and loading Spice libraries into KiCad. This is done
without any involvement of Ngspice -- we create our own in-tree parser
using PEGTL -- because Ngspice doesn't offer any intermediate output we
could plug ourselves into. We don't parse everything -- just the library
content, so this won't be that much effort.

We implement some basic Spice code preview to give the user a hint what
Spice code eir model will correspond to.
2022-07-30 02:25:34 +00:00
Mikolaj Wielgus 978f01553b Sim Model Editor: Serialize models in fields
Implemented serialization and deserialization of models in symbol fields
through the SIM_VALUE class. We don't carry the Spice legacy of
case-insensitive suffixes, instead we conform to the SI standard (i.e. M
is Mega, not milli, P is peta, p is pico).

Parameter grid value validation is implemented by simply not allowing
any characters that will make the value invalid (instead of highlighting
the field in a red color). This will likely be changed at some point in
the future.
2022-07-30 02:25:34 +00:00
Mikolaj Wielgus c5a256291e Sim Model Editor: Display model parameters
This commit adds parameter display functionality, via a wxPropertyGrid
widget, to the Sim Model Editor. To faciliate that, a SIM_VALUE class is
created to serialize, deserialize, and validate numeric values in the
new parameter grid.

SPICE_MODEL is renamed to SIM_MODEL and split into several subclasses
that correspond to different model kinds.
2022-07-30 02:25:34 +00:00