Opened 12 years ago
Closed 11 years ago
#2012 closed enhancement (fixed)
FrontEnd generate wrong record constructor function for records with constants
Reported by: | Jens Frenkel | Owned by: | Mahder Alemseged Gebremedhin |
---|---|---|---|
Priority: | normal | Milestone: | 1.9.0 |
Component: | Frontend | Version: | trunk |
Keywords: | constant record to functions | Cc: | christian.schubert@… |
Description
For the models
Modelica.Electrical.Spice3.Examples.FourInverters
Modelica.Electrical.Spice3.Examples.InvertersApartRecord
Modelica.Electrical.Spice3.Examples.InvertersExtendedModel
Modelica.Electrical.Spice3.Examples.Nor
Modelica.Electrical.Spice3.Examples.Oscillator
Modelica.Electrical.Spice3.Examples.Spice3BenchmarkDifferentialPair
Modelica.Electrical.Spice3.Examples.Inverter
of MSL3.2.1
codegeneration fails to hand over records of constants because the record constructor funktion has no paramater values in declaration
For example the record
record SpiceConstants "General constants of SPICE simulator" extends Modelica.Icons.Record; constant Real EPSSIL = (11.7 * 8.854214871e-12); constant Real EPSOX = 3.453133e-11; constant SI.Charge CHARGE = (1.6021918e-19); constant SI.Temp_K CONSTCtoK = (273.15); constant SI.HeatCapacity CONSTboltz = (1.3806226e-23); // J/K constant SI.Temp_K REFTEMP = 300.15; /* 27 deg C */ constant Real CONSTroot2 = sqrt(2.0); constant Real CONSTvt0( final unit= "(J/K)/(A.s)") = Modelica.Constants.k * Modelica.SIunits.Conversions.from_degC(27) / CHARGE; // deg C constant Real CONSTKoverQ( final unit= "(J/K)/(A.s)")= Modelica.Constants.k / CHARGE; constant Real CONSTe = exp(1.0); // options constant SI.Conductance CKTgmin = 1e-12; constant SI.Temp_K CKTnomTemp = 300.15; constant SI.Temp_K CKTtemp = 300.15; constant SI.Area CKTdefaultMosAD = 0.0; constant SI.Area CKTdefaultMosAS = 0.0; constant SI.Length CKTdefaultMosL = 100e-6; constant SI.Length CKTdefaultMosW = 100e-6; constant Real CKTreltol = 1e-10; constant Real CKTabstol = 1e-15; constant Real CKTvolttol = 1e-10; constant Real CKTtemptol = 1e-3; annotation (Documentation(info="<html> <p>General constants used by SPICE</p> <p>The package Internal is not for user access. There all function, records and data are stored, that are needed for the semiconductor models of the package Semiconductors.</p> </html>")); end SpiceConstants;
get the following record function
Modelica_Electrical_Spice3_Internal_SpiceConstants_rettype omc_Modelica_Electrical_Spice3_Internal_SpiceConstants() { Modelica_Electrical_Spice3_Internal_SpiceConstants_rettype tmp1; struct Modelica_Electrical_Spice3_Internal_SpiceConstants tmp2; tmp1.c1 = tmp2; return tmp1; }
and the call
cc = Mos.mosCalcNoBypassCode( m, m_type, c2, p, C, vp, m_bInit, {G.v, B.v, Dinternal, Sinternal});
with
tmp55 = omc_Modelica_Electrical_Spice3_Internal_SpiceConstants(0.00000000010359431399069999, 0.00000000003453133, 0.00000000000000000016021918, 273.15, 0.000000000000000000000013806226, 300.15, 1.4142135623730951, 2.718281828459045, 0.000000000001, 300.15, 300.15, 0.0, 0.0, 0.0001, 0.0001, 0.0000000001, 0.000000000000001, 0.0000000001, 0.001, 0.025864709055120616, 0.0000861726105451295);
will fail because the elements of tmp55 are not set.
Attachments (1)
Change History (7)
comment:1 by , 12 years ago
Component: | Code Generation → Frontend |
---|---|
Owner: | changed from | to
Status: | new → assigned |
by , 12 years ago
Attachment: | Modelica.Electrical.Spice3.Examples.FourInverters.mos added |
---|
fixed flattened output
comment:2 by , 12 years ago
Summary: | Codegeneration does not handle record of constants to funktions → FrontEnd generate wrong record constructor function for records with constants |
---|
comment:3 by , 12 years ago
Priority: | blocker → normal |
---|---|
Type: | defect → enhancement |
- Further investigations have shown that the division by zero is not because of the handling of constants in recordconstruktor funktions but problems with the initial system solving in the simulation runtime. Hence the issue is less importent and the handling of constants of recordconstruktor funktins is only not conform with the specification.
comment:4 by , 12 years ago
Owner: | changed from | to
---|---|
Status: | assigned → accepted |
comment:6 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | accepted → closed |
According to the Spec.
the Recordconstructor function of SpiceConstants seems not to be fine because the constants are not marked as protected
in addition the function call in Modelica.Electrical.Spice3.Internal.MOS
seems not to be flattend correct because the function call to Modelica.Electrical.Spice3.Internal.SpiceConstants should have no parameter, because all the constants are protected.
Hence it is looks like a FrontEnd issue and not a code generation issue.