Opened 9 years ago

Last modified 3 years ago

#3771 closed defect

Wrong clock interval — at Initial Version

Reported by: Niklas Worschech Owned by: Lennart Ochel
Priority: high Milestone: Future
Component: Backend Version:
Keywords: Modelica_Synchronous, synchronous features, cpp runtime Cc: Rüdiger Franke, Bernhard Thiele, Volker Waurich

Description

For the following example it appears the clock interval calculation is not correct

model TestClock
Integer nextInterval(start=1);
Clock c = Clock(nextInterval,210);
equation

when c then

nextInterval = previous(nextInterval) + 1;

end when;

end TestClock;

For the next clock interval the following equation is generated:
_clockInterval[0] =(_$CLKPRE_P_nextInterval / 210.0) * 1.0 / 1.0;

I think to calculate the next clock interval, instead of the previous interval value the current interval value should be used.
In the cpp runtime the next clock interval is calculated after the evaluation of the corresponding clock equations

_$CLKPRE_P_nextInterval = _nextInterval;
nextInterval = (1 + _$CLKPRE_P_nextInterval);

_clockInterval[0] = (_$CLKPRE_P_nextInterval / 210.0) * 1.0 / 1.0;

At time=0 when the clock ticks for the first time, previous(interval)=1 but it should be interval = 2 to calculate the correct next clock interval.

Change History (0)

Note: See TracTickets for help on using tickets.