Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#1922 closed defect (fixed)

Codegeneration does not handle extended records

Reported by: Jens Frenkel Owned by: Martin Sjölund
Priority: high Milestone: 1.9.0
Component: Code Generation Version: trunk
Keywords: extended records Cc: Jens Frenkel

Description

For the Models of MSL3.2.1

Modelica.Electrical.Spice3.Examples.FourInverters.mos
Modelica.Electrical.Spice3.Examples.Inverter.mos
Modelica.Electrical.Spice3.Examples.InvertersApartRecord.mos
Modelica.Electrical.Spice3.Examples.Nand.mos
Modelica.Electrical.Spice3.Examples.Nor.mos
Modelica.Electrical.Spice3.Examples.Spice3BenchmarkDifferentialPair.mos
Modelica.Electrical.Spice3.Examples.Spice3BenchmarkMosfetCharacterization.mos
Modelica.Electrical.Spice3.Examples.Spice3BenchmarkRtlInverter.mos

The codegeneraton does not handle

record Mos1Calc "Further mosfet variables (for level 1)"

extends Mos.MosCalc;

end Mos1Calc;

Modelica.Electrical.Spice3.Examples.FourInverters_functions.c:1013: error: incompatible type for argument 4 of 'omc_Modelica_Electrical_Spice3_Internal_Mos_mosCalcDEVqmeyer'

Modelica.Electrical.Spice3.Examples.FourInverters_functions.c:579: note: expected 'struct Modelica_Electrical_Spice3_Internal_Mos_MosCalc' but argument is of type 'struct Modelica_Electrical_Spice3_Internal_Mos1_Mos1Calc'

Change History (5)

comment:1 by Martin Sjölund, 12 years ago

Status: newassigned

This is due to the frontend accepting different records as subtypes of each other without adding a cast. Should a doable fix.

comment:2 by Martin Sjölund, 12 years ago

The fix works well until you reach the backend in some MSL 3.2 code that uses the Complex package.

IndexReduction.differentiateEqns failed for eqn 25:
/*Complex*/ComplexOutput(voltageSource.V.re, voltageSource.V.im) = Complex(V.k * cos(phi.k), V.k * sin(phi.k))

That is, left side is a cast from one kind of record to another... And backend doesn't know how to differentiate. Since left and right sides are record constructors, this could have been scalarized to:

voltageSource.V.re = V.k * cos(phi.k);
voltageSource.V.im = V.k * sin(phi.k);

I wonder if that's what was done before and the backend just does not know what to do about the cast...

comment:3 by Martin Sjölund, 12 years ago

Resolution: fixed
Status: assignedclosed

Fixed in r13881. Backend needs improvements to handle scalarization of complex equations like:

/*Complex*/ var = ComplexVoltage(1,2);

For example by using Expression.splitRecord on lhs and rhs instead of trying to match all combinations of crefs and calls that are possible to split.

comment:4 by Jens Frenkel, 12 years ago

now only one model does not pass the backend (Modelica.Electrical.Spice3.Examples.Spice3BenchmarkMosfetCharacterization.mos)

all the other pass the backend but the frontend miss some parameter bindings like for

Modelica.Electrical.Spice3.Examples.Nor.mos

final parameter Real mn2.c1.m_vds(quantity = \"ElectricPotential\", unit = \"V\") \"Vds, Drain-Source voltage\";

final parameter Mos1.Mos1Calc c1 = Mos.mosCalcInitEquations(

p,
C,
vp,
m) "Precalculated parameters";

Because of that all models cannot simulate (Division by Zero because Default StartValue is Used)

comment:5 by Jens Frenkel, 12 years ago

Modelica.Electrical.Spice3.Examples.Spice3BenchmarkMosfetCharacterization.mos fails also because a final parameter lost there bound expression.

Note: See TracTickets for help on using tickets.