Commit Graph

417 Commits

Author SHA1 Message Date
Mikolaj Wielgus d48ec3aa8c Sim: Slightly simplify grammars 2022-09-17 02:18:23 +02:00
Mikolaj Wielgus 545212eb13 Sim Window: Support dark theme 2022-09-16 06:57:27 +02:00
Mikolaj Wielgus 4ae2225b6d Sim: Replace all wxStrings with std::strings in SIM_VALUE 2022-09-16 06:11:14 +02:00
Mikolaj Wielgus d19b2dbfe4 Sim Model Editor: Display error when failing to set parameter 2022-09-16 05:44:23 +02:00
Mikolaj Wielgus ce3fe46751 Sim Window: Display latest netlist without having to run sim
Fixes https://gitlab.com/kicad/code/kicad/issues/11787
2022-09-16 03:12:28 +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 ba723d36c9 Sim: Don't generate .model line when there's no instance param overrides 2022-09-14 03:16:53 +02:00
Mikolaj Wielgus 0e0d1a34f5 Sim: Spice grammar fixes
- Fix parsing .model lines with model names containingnon-alphanumeric
  characters like - and _,
- Fix parsing libraries in which EOF is not preceded by a newline.

Fixes https://gitlab.com/kicad/code/kicad/issues/12394
2022-09-12 04:05:17 +02:00
Mikolaj Wielgus e56635a02b Sim: Add mutual inductor model 2022-09-11 19:23:01 +02:00
Mikolaj Wielgus 91358dfcac Sim Model Editor: Fix Enable/Disable of parameters
Only SIM_STRING_PROPERTY-based parameters were updated.
2022-09-11 15:24:16 +02:00
Mikolaj Wielgus 1b7ff376b0 Sim: Simplify generated .model cards
One parameter per line instead of wrapping after a certain line width.
Consistent with the formatting in the recently added generation of
.subckt cards from the schematic.
2022-09-10 02:45:48 +02:00
Mikolaj Wielgus 300a1c4144 Add a new schematic exporter to Spice .subckt model
An option to use the current sheet as root is added to both the original
and new (.subckt model) exporters.
2022-09-09 16:18:48 +02:00
Marek Roszko 9f522e1343 Forgot to actually change the fmt specifiers... 2022-09-08 07:17:58 -04:00
Marek Roszko 5b96736059 LOCALE_IO is expensive to hammer, use fmt
Fixes https://gitlab.com/kicad/code/kicad/-/issues/12377
2022-09-08 07:04:45 -04:00
Mikolaj Wielgus 72651dffe8 Sim Model Editor: Fix crash on selecting behavioral models
Accidentally there was an infinite recursion.
2022-09-03 20:06:14 +02:00
Mikolaj Wielgus 70ab5db0e9 Sim Model Editor: Fix crash on selecting tline models
Dereferencing std::optional<T> objects was undefined behavior.

Change some forgotten SIM_VALUE_INST<T> usages to their corresponding
typedefs.
2022-09-03 19:52:24 +02:00
Mikolaj Wielgus f6b1ff821b Sim Model Editor: Improve raw model code preview
- Show whole file below the item line for reference
- Fix pin sequence in item line (was not displayed)
2022-09-03 16:20:41 +02:00
Mikolaj Wielgus cfdf6c097d Sim: Fix crash due to accessing param 0 of TYPE::NONE model 2022-09-02 20:21:09 +02:00
Mikolaj Wielgus 94bbb2e267 Sim: Skip NC pins of raw Spice models when generating netlist
Unconnected pins were erroreously placed in raw Spice item
instantiations, resulting in passing more pins than model had.
2022-09-01 11:41:43 +02:00
Mikolaj Wielgus 748324f4cd Sim: Use O-devices to simulate all tlines (much faster than T-devices) 2022-08-31 15:50:11 +02:00
jean-pierre charras f679400e91 simulator: fix a issue when the simulation ends, but ngspice is still running.
For instance if a lot of simulation results must be written to a file (using wrdata).
In this case the tools in simulator frame toolbar were never enabled.
2022-08-31 12:07:05 +02:00
Mikolaj Wielgus 39ac58ea33 Use the PEGTL grammar for detecting .control and .subckt text directives 2022-08-30 17:27:58 +02:00
Marek Roszko ae637296cd Fix MSVC compile 2022-08-30 07:24:58 -04:00
Mikolaj Wielgus 2bcfe5e42c Fix Spice subcircuit parsing
When parsing a subcircuit, the parser was incorrectly identifying
parameters of models inside it as belonging to the subcircuit.
2022-08-30 12:09:10 +02:00
Mikolaj Wielgus bd6c153ad9 Sim: Implement "enum" model parameters for switches
Displayed in Sim Model Dialog parameter grid as a dropdown
(wxEnumProperty).
2022-08-30 09:45:49 +02:00
Mikolaj Wielgus 716b60c20d Commit forgotten sim_model_switch.{cpp,h} files 2022-08-29 04:28:56 +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 963900ab83 Sort sim model pins by symbol pin number in sim model dialog 2022-08-26 04:36:48 +02:00
Seth Hillbrand f1261e71d4 Replace boost::optional with std::optional 2022-08-25 15:50:47 -07:00
Mikolaj Wielgus a0400791c0 Fix exporting Spice instance lines for multi-part symbols
Only pins from the current symbol part were used: the rest was
incorrectly set to Not Connected.

Also slightly change generation of names for Not Connected nets.
2022-08-25 08:47:31 +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 ffab57ffd0 Fix default pin assignment for subcircuit sim models
Instead of using a linear order that incorrectly starts from 0, have all
pins unassigned by default.
2022-08-24 00:09:05 +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
jean-pierre charras 34b38eb95b Sim: on parameters parsing error, give a better info than tao::pegtl::eof error. 2022-08-17 11:11:36 +02:00
Roberto Fernandez Bautista 3e11506fa2 Fix a few unused variable warnings on msvc 2022-08-15 20:47:21 +01:00
Seth Hillbrand 35ac39844f Clean up some auto usage
Don't make new copies of shared_ptr if we can use references.  Keep auto
usage down to hard-to-type-out sequences
2022-08-15 11:29:45 -07:00
Wayne Stambaugh 898ec0d094 Fix wxWidgets 3.1 and later deprecated build warnings.
wxWidgets 3.1 has deprecated wxPATH_NORM_ALL when normalizing file
paths when calling wxFileName::Normalize().  This change keeps the
existing behavior except in places where our own internal
ExpandEnvVarSubstitutions() to expand environment variables.
2022-08-15 08:00:40 -04:00
jean-pierre charras 488a53e71b Fix a few minor Coverity warnings 2022-08-12 10:51:36 +02:00
Mikolaj Wielgus 6d59fef9a5 Sim: Fix reading the legacy Spice_Node_Sequence field (2nd attempt)
bd809bf31c was botched and broke QA tests,
this will fix the problem.
2022-08-11 15:50:16 +02:00
Mikolaj Wielgus bd809bf31c Sim: Fix reading the legacy Spice_Node_Sequence field 2022-08-11 02:42:16 +02:00
Mikolaj Wielgus a1a99b1ec2 Sim QA: Check NGSPICE's LoadNetlist() and Run() status code 2022-08-10 17:54:28 +02: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 24e7a8ac41 Commit missing eeschema/sim/sim_model_ngspice_data.cpp 2022-08-05 18:51:52 +02:00
Mikolaj Wielgus c9f3507ff7 Sim: Don't require ngspice.h for SIM_MODEL_NGSPICE 2022-08-05 18:26:09 +02:00
jean-pierre charras d667d9b464 Do not include and use sharedspice.h when KICAD_SPICE = OFF 2022-08-04 17:01:29 +02:00
Mikolaj Wielgus a14d3e74a8 Remove generate_ngspice_models.bash script 2022-08-02 14:50:02 +02:00
Mikolaj Wielgus 5d64fc12a1 Attempt to fix GCC MSYS2 build crash
Initialize ngspice_models.cpp structures at runtime on demand. Use
a sequence of std::vector::emplace_back() instead of
brace-initialization.
2022-08-02 14:47:28 +02:00