From ad529541bf54d9a4339a7371208b7d328c0a449a Mon Sep 17 00:00:00 2001 From: Alex AUVOLAT Date: Tue, 5 Nov 2013 18:38:25 +0100 Subject: Deleted useless debug output ; coded working 60/60/24 clock. --- tests/clockHMS.mj | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'tests') diff --git a/tests/clockHMS.mj b/tests/clockHMS.mj index a25a85c..4575c58 100644 --- a/tests/clockHMS.mj +++ b/tests/clockHMS.mj @@ -55,14 +55,21 @@ and_each(a, b:[n]) = (o:[n]) where end if end where -count_mod(in:[n]) = (out:[n]) where - (incr, carry) = adder(in, 1 . repeat(0), 0); - neq = not (equal(incr)); - out = and_each(neq, incr) +count_mod(in:[n], op) = (out:[n], reset) where + (incr, carry) = adder(in, op . repeat(0), 0); + reset = equal(incr); + neq = not reset; + out = and_each(neq, incr); end where -main() = (out:[4],next:[4]) where - next = count_mod<4, 12>(out); - out = reg_n<4>(next) +main() = (count_sec:[6],count_min:[6],count_hour:[5],next_day) where + (count_sec, aug_min) = count_mod<6, 60>(save_sec, 1); + save_sec = reg_n<6>(count_sec); + + (count_min, aug_hour) = count_mod<6, 60>(save_min, aug_min); + save_min = reg_n<6>(count_min); + + (count_hour, next_day) = count_mod<5, 24>(save_hour, aug_hour); + save_hour = reg_n<5>(count_hour) end where -- cgit v1.2.3