YEDC.
These are two simple 4 bit binary NCB counters. b10 represents the increment bit, and b11 the decrement bit. The value is stored in binary form in b1-b4, with b1 the high bit.
The second counter will not rollover if you try to increment and it's at 1111 or you try to decrement it at 0000.
Yall can see how to extend these to more bits.
These are very slightly more expensive in terms of cron count, because you need the final cron at the end to unset b11 and b10, but you only need one of these reseting crons nomatter how many of these counters you use.
standard Azratax Bidirectional Counter (ABC)
Cron 1:
- EnableOn: ((b10 & (b2 & (b3 & b4)))|(b11 & (!b2 & (!b3 & !b4))))& !(b10 & b11)
- OnStart: ^b1
Cron 2:
- EnableOn: ((b10 & (b3 & b4))|(b11 & (!b3 & !b4)))& !(b10 & b11)
- OnStart: ^b2
Cron 3:
- EnableOn: ((b10 & b4)|(b11 & !b4))& !(b10 & b11)
- OnStart: ^b3
Cron 4:
- EnableOn: (b10 | b11)& !(b10 & b11)
- OnStart: ^b4
Azratax Roll-Over Proof Counter (AzROP)
Cron 1:
- EnableOn: ((b10 & (!b1 & (b2 & (b3 & b4)))) |(b11 & (b1 & !(b2 | (b3 | b4))))) & !(b10 & b11)
- OnStart: ^b1
Cron 2:
- EnableOn: ((b10 & (!(b1 & b2) & (b3 & b4)))|(b11 & (b1 | b2) & !(b3 | b4))) & !(b10 & b11)
- OnStart: ^b2
Cron 3:
- EnableOn: ((b10 & (!(b1 & (b2 & b3)) & b4)))|(b11 & (b1 | (b2 | b3)) & !b4)) & !(b10 & b11)
- OnStart: ^b3
Cron 4:
- EnableOn: ((b10 & !(b1 & (b2 & (b3 & b4)))|(b11 & ! (b1 | (b2 | (b3 | b4)))) & !(b10 & b11)
- OnStart: ^b4
In either case, you need a final reset cron. This one might want to be cron 639 (the last cron that can ever run - cron index number 511).
EnableOn: b10 | b11
OnStart: !b10 !b11
Why do we need that final cron instead of just unsetting the bits in the last of the counter crons and removing the !(b10 and b11) from all the enableon fields?
Wierd stuff will happen if it was told to both increment and decrement.
Enjoy all.
-Az
------------------
It is here. EVNEW Public Beta (url="http://"http://www.aznt.com/EVN/EVNEW")www.aznt.com/EVN/EVNEW(/url)
Stuffit is a piece of .sit.