Commit Graph

159 Commits

Author SHA1 Message Date
Jeff Young 1c62fc868d Fix more SPICE case-insensitivity bugs.
Fixes https://gitlab.com/kicad/code/kicad/-/issues/14793

(cherry picked from commit 03486443c7)
(cherry picked from commit e5d5335701)
2023-05-28 19:38:27 +02:00
Mark Visser f9c2f03a44 fix bug whereby spice params with capital letters no longer cause an error and data loss
Spice parameters were converted to lower-case before comparison. This is incorrect, as it
is legal and common for spice parameters to contain capital letters (e.g. potentiometers
typically use Rt and SET as their parameters).
Spice parameters are not case sensitive, so the correct behaviour is to instead do a
case-insensitive comparison on the parameter name.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/14793

(cherry picked from commit 0d235ac64b)
(cherry picked from commit 888a35bbde)
2023-05-28 19:38:27 +02:00
Seth Hillbrand 248de56fb0 Revert "fix bug whereby spice params with capital letters no longer cause an error and data loss"
This reverts commit 888a35bbde.
2023-05-24 08:54:16 -07:00
Seth Hillbrand 89349c1084 Revert "Fix more SPICE case-insensitivity bugs."
This reverts commit e5d5335701.
2023-05-24 08:54:16 -07:00
Jeff Young e5d5335701 Fix more SPICE case-insensitivity bugs.
Fixes https://gitlab.com/kicad/code/kicad/-/issues/14793

(cherry picked from commit 03486443c7)
2023-05-23 09:40:32 +01:00
Mark Visser 888a35bbde fix bug whereby spice params with capital letters no longer cause an error and data loss
Spice parameters were converted to lower-case before comparison. This is incorrect, as it
is legal and common for spice parameters to contain capital letters (e.g. potentiometers
typically use Rt and SET as their parameters).
Spice parameters are not case sensitive, so the correct behaviour is to instead do a
case-insensitive comparison on the parameter name.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/14793

(cherry picked from commit 0d235ac64b)
2023-05-23 09:40:32 +01:00
Jeff Young e28b50e8d6 Fix a bunch more issues with sheetpaths and allowExtraText.
A sheetpath is required to correctly resolve text variables.
Depending on currentSheet is rife with bugs.

There are many places where we do *not* want to be prepending
field names to the field values, such as netlisting,
building PDF hypertext menus, etc.

Also, Find/Replace needs to work on unresolved text, as
that's what we're going to display (and if replace nuked
your variable references you wouldn't be happy).

(cherry picked from commit b41d446f58)
2023-05-05 18:02:59 +01:00
Jeff Young 999cd8cd11 Simulator fixes.
1) Don't read libraries multiple times
2) VDMOS default is nchan if not specified
3) In the absence of a workbook default to LTSpice compatability
4) Don't attempt to write out a model line for a subckt; it never has
a baseModel
2023-04-24 13:55:34 +01:00
jean-pierre charras ea95d8604a Ensure we do not use a non existing pin in SIM_MODEL::MigrateSimModel()
From master branch
Fixes #14522
https://gitlab.com/kicad/code/kicad/issues/14522
2023-04-12 09:41:07 +02:00
Jeff Young d4a312d6cb Move separation of model name from params earlier in the process.
We need just the model name when we look for a match in the library file.

(cherry picked from commit 60aadfee40)
2023-03-25 15:37:57 +00:00
Jeff Young 7026cfe140 Split name from additional params only when model is a library reference.
(cherry picked from commit b8cf7cc080)
2023-03-22 14:12:42 +00:00
Jeff Young 1614dc975a Separate legacy model name from parameters.
Fixes https://gitlab.com/kicad/code/kicad/issues/13988

(cherry picked from commit 39a801423e)
2023-03-21 13:31:20 +00:00
Jeff Young fb02e55424 Don't pass a REPORTER when checking for overrides.
It fails the unit tests (as it generates a message whenever no override
is found).
2023-03-17 15:30:24 +00:00
Jeff Young 70e86434ef Manual cherry-pick of much of 6d296038f3 2023-03-17 14:12:58 +00:00
Wayne Stambaugh 9e1fd16329 Coverity fixes and code cleaning.
(cherry picked from commit 4e99812145)
2023-03-10 11:21:19 -05:00
Jeff Young 3a95826b42 Move only-write-model-if-it-contains-overrides up to base class.
It's necessary to keep us from writing out model lines for included
models and fall-backs of included models.

(cherry picked from commit f5edcf82f2)
2023-03-01 13:44:26 +00:00
Jeff Young 42efd2d005 Make substrate and thermal junction nodes optional.
Fixes https://gitlab.com/kicad/code/kicad/issues/14083

(cherry picked from commit 1fdc81e68d)
2023-02-28 14:21:12 +00:00
Jeff Young d32e13daee Clear model name when switching to internal model.
Also fixes a bug to ensure that a modelLine gets written when using
an internal model.

Fixes https://gitlab.com/kicad/code/kicad/issues/14083

(cherry picked from commit 2e5bf0210a)
2023-02-28 14:21:12 +00:00
Jeff Young f604bcb557 Only write included models if they have overridden parameters.
Fixes https://gitlab.com/kicad/code/kicad/issues/13953

(cherry picked from commit 5a12e5ee76)
2023-02-24 20:47:22 +00:00
Jeff Young 5e7cc30564 Don't mess up user formatting if eval'ing didn't actually change value.
Fixes https://gitlab.com/kicad/code/kicad/issues/13989

(cherry picked from commit 8059edff0e)
2023-02-24 20:47:22 +00:00
Jeff Young f942b4c657 Don't allow extra text in Sim.* fields.
(In particular, the field name.)

Fixes https://gitlab.com/kicad/code/kicad/issues/13996

(cherry picked from commit 71df3f9edb)
2023-02-24 20:47:22 +00:00
Jeff Young 7f6cb9b07b 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.

(cherry picked from commit 68fe146861)
2023-02-24 20:47:22 +00:00
Jeff Young 38e5da724d Remove dead and redundant code.
(cherry picked from commit 90adc26b73)
2023-02-24 20:47:22 +00:00
Jeff Young 962b2d45ef Implement default levels for JFETs, MOSFETs and MESFETs.
(cherry picked from commit fe2679d965)
2023-02-22 18:04:23 +00:00
Jeff Young 7894b41277 Don't allow 0 field text size.
Fixes https://gitlab.com/kicad/code/kicad/issues/13987

(cherry picked from commit cb71ea872b)
2023-02-22 18:04:23 +00:00
Jeff Young d1f6ba77e8 Better error reporting, and don't infer models with library references. 2023-02-04 20:55:52 +00:00
Graham Keeth a51dc8c9de HiSIM_HV MOSFET models are *not* the default type
The ngspice manual does not indicate that there is any default
model type. This change ensures we get a `level=xy` written out to the
.model line when we select a HiSIM_HV model.
2023-02-04 00:03:25 +00:00
Graham Keeth 41c4ee2245 ngspice requires J prefix for JFETs in netlist
Fixes: https://gitlab.com/kicad/code/kicad/-/issues/13774
2023-02-04 00:03:25 +00:00
Jeff Young 8b03c093f9 Move potentiometer pin model to r0, wiper, r1, and remove flipping code.
Fixes https://gitlab.com/kicad/code/kicad/issues/13741
2023-02-02 16:22:13 +00:00
Jeff Young c939b1ef76 Followed-by-3-digits doesn't guarantee a thousands separator.
Fixes https://gitlab.com/kicad/code/kicad/issues/13708
2023-01-30 21:22:48 +00:00
Seth Hillbrand 00f93db2ff Convert wide chars before reading model
The PEGTL parser used by KiCad for SPICE models only handles ASCII
characters.  Despite the docs stating that you can, in theory, parse a
UTF-8 character by reading the base string, in pratice this does not
work as the UTF-8 string is represented by unsigned chars and the PEGTL
string is based on signed char.

To work around this, we need to convert micro and mu to the ASCII 'u'
equivalent

Fixes https://gitlab.com/kicad/code/kicad/issues/13642
2023-01-23 15:23:41 -08:00
Jeff Young 959e20f52c A fall-back model for FOO should supply FOO's pin names.
Fixes https://gitlab.com/kicad/code/kicad/issues/13589
2023-01-19 12:14:50 +00:00
Jeff Young d839f11d49 Rip out parsing of SPICE libraries for netlisting.
We only need to parse the libraries for the Sim Model Editor dialog
(so that we can determine the models to put in the popup).  Doing it
for netlisting just opens us up to incorrectly parsing the SPICE, and
returns no value.

This also means that a SIM_LIB_MGR manages a single library, and
never multiple libraries.

This also allows the tidying-up of some error reporting structures to
better inform the user what went wrong.

Fixes https://gitlab.com/kicad/code/kicad/issues/13431
2023-01-12 14:51:03 +00:00
Jeff Young c43050b91b Remove safety around reading default parameter from Value field.
This should be OK now because we should be writing out all parameters
now (even if they're default value).

But perhaps more to the point, if we have the safety in there then
we miss cases where we really can't parse the model (value of "{VCC}")
and we need to fall back to a raw spice model.

Fixes https://gitlab.com/kicad/code/kicad/issues/13444
2023-01-09 15:24:45 +00:00
Jeff Young d65cf1b457 Check parameters before assuming we can handle the model.
Fixes https://gitlab.com/kicad/code/kicad/issues/13444
2023-01-08 18:00:22 +00:00
Jeff Young 7af718f1a5 Don't use std::string for things with wxString APIs.
It's too bug-prone.

Fixes https://gitlab.com/kicad/code/kicad/issues/13380
2023-01-05 14:16:39 +00:00
Seth Hillbrand cbe6cd3048 Don't move local vars
Copy ellision allows optimization if we don't explicitly move a local
variable in the return
2023-01-03 10:20:18 -08:00
Jeff Young baa13b885f Don't add Sim.Params unless it contains data, and update sallen key demo. 2023-01-03 17:20:23 +00:00
Jeff Young 9583b28063 Fix store-in-value bugs.
1) Always honour the dialog checkbox value.
2) Don't expect the absence of the primary parameter in Sim.Params to
   mean that Value stores it.  It might be the default parameter value.
3) Update spiceTypeInfo when matching legacy data to an internal model.
4) Initialize the store-in-value checkbox depending on whether or not
   we found the primary parameter in the Value field.
2023-01-03 17:20:23 +00:00
Jeff Young 9b9795a87d Reduce reliance on exception processing -- it's waay too bugy at present.
This moves some stuff to REPORTER APIs.  Moving more stuff would be good,
but it probably too high-risk at present.  We'll wait for 8.0 for that....

Fixes https://gitlab.com/kicad/code/kicad/issues/13359
2023-01-03 17:20:23 +00:00
Jeff Young fdc8f9c59d Fix accidental deletion in "TEXT_ATTRIBUTES" commit. 2023-01-03 01:23:18 +00:00
Jeff Young 7f35323416 Re-enable sim model ERC testing. 2023-01-03 00:59:14 +00:00
Jeff Young 277cd73204 TEXT_ATTRIBUTES doesn't hold the position.
Fixes https://gitlab.com/kicad/code/kicad/issues/13350
2023-01-02 17:36:21 +00:00
jean-pierre charras e8114dc49a Minor compil and Coverity warnings fixes. 2023-01-02 10:21:42 +01:00
Jeff Young 55b8f0bc00 Gracefully fall back to raw spice when we can't parse the data.
Fixes https://gitlab.com/kicad/code/kicad/issues/13329
2022-12-31 18:52:26 +00:00
Jeff Young 77b361a077 Add reference material to SPICE model pin assignment tab.
Fixes https://gitlab.com/kicad/code/kicad/issues/13309
2022-12-31 18:52:26 +00:00
Jeff Young 5deee405da Fill in built-in-model-type (which might not be the same as initial spice type).
Fixes https://gitlab.com/kicad/code/kicad/issues/13324
2022-12-31 01:07:46 +00:00
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 424cdf6699 Overflow safety.
Sentry issue https://sentry.io/organizations/kicad/issues/3419671947/events/11212297e66c47c7af7144b5f075e88c/
2022-12-26 20:33:04 +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