[Oberon] FPGA - System Clock advance
joerg.straube at iaeth.ch
Fri Mar 1 21:38:03 CET 2019
It‘s nice to see how you get closer and closer to the solution.
- You added the needed DIVs and the MODs. Great.
- you added the overflow of seconds, minutes, hours. Try to optimize the runtime (hint: nested IFs) Overflow of days months and years to be added.
- The INC(sec) part is not very accurate. Think what happens if you compile a large program or the GC kicks in. Then your DT will not be called once per second. It might be that you will be called in 2 seconds or even longer. Investigate a scheme where you measure the time between two consecutive calls to DT...
> Am 01.03.2019 um 20:05 schrieb Tomas Kral <thomas.kral at email.cz>:
> On Fri, 1 Mar 2019 11:45:59 +0100
> Jörg Straube <joerg.straube at iaeth.ch> wrote:
>> And look into Texts.WriteClock to learn how clock and date is
>> supposed to be encoded in the 32 bits. You will have to adapt your DT
>> to that as well.
> I do this, advances time only, advancing date requires more
> effort, leap year, months of 31,28,31,.. days.
> Currently resolved by TIM broadcast on hourly basis.
> Keeping cumulative time delta `dT' in milliseconds is a challenge
> though, then `dT DIV 1000' would yield the deviation to add?
> PROCEDURE DT; (*advance date time*)
> VAR dt, ymd, hr, min, sec: INTEGER;
> dt := Kernel.Clock();
> ymd := dt DIV 20000H; (*year, month, day*)
> hr := dt DIV 1000H MOD 20H; (*hour*)
> min := dt DIV 40H MOD 40H; (*min*)
> sec := dt MOD 40H; (*sec*)
> INC(sec); (*advance time*)
> IF sec > 59 THEN INC(min); sec := 0 END ;
> IF min > 59 THEN INC(hr); min := 0 END ;
> IF hr > 23 THEN hr := 0 END ;
> (*TIM to advance date `ymd'*)
> dt := ymd*20000H + hr*1000H + min*40H + sec;
> END DT;
> Tomas Kral <thomas.kral at email.cz>
> Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related systems
More information about the Oberon