﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
3771	Wrong clock interval	Niklas Worschech	Lennart Ochel	"For the following example it appears the clock interval calculation is not correct
 {{{#!mo
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.

"	defect	new	blocker	Future	Backend			synchronous features, cpp runtime	Rüdiger Franke Bernhard Thiele
