Opened 14 years ago
Last modified 14 years ago
#1368 closed defect (fixed)
Zero crossings in algorithms in for loops are generated wrong
Reported by: | Adrian Pop | Owned by: | Adrian Pop |
---|---|---|---|
Priority: | high | Milestone: | White December |
Component: | Simulation Code Generation | Version: | |
Keywords: | Cc: | Adrian Pop, Adrian Pop, Frenkel TUD, Willi Braun |
Description
This is one of the issues with codegen for Modelica.Electrical.Digital.Examples.Multiplexer
.
model X parameter Integer n = 4; parameter Real x[n] = {1, 2, 3, 4}; Real y[n]; algorithm for i in 1:n loop y[i] := if time > x[i] then x[i] else i; end for; end X;
gets you in the C code:
array_alloc_scalar_real_array(&tmp10, 4, (modelica_real)$Px$lB1$rB, (modelica_real)$Px$lB2$rB, (modelica_real)$Px$lB3$rB, (modelica_real)$Px$lB4$rB); ZEROCROSSING(0, Greater(time, (tmp10[(modelica_integer)$Pi])));
which is obviously wrong, you should have 4 zero crossings.
I think that BackendDAECreate.collectZeroCrossings should expand for loops
in algorithms and then collect zero crossings. However, if the for loop range
is not a parameter, and you cannot expand the for loop, then i don't know how
to deal with this. Any suggestions??
Note:
See TracTickets
for help on using tickets.