Description

Bicolor Example

The ‘counter’ logic gate allows you to generate a sequence of values from 0 to N.

Usage

I/Os:

  1. clock
  2. max (optional)
  3. power
  4. output

The max value (N) can be specified using a datablock or using the optional input 2 (max).

The output value will change each time the clock goes from state 1 to 0.
If the output is < N it will increase by 1, otherwise it will revert to 0.

For example if N is 7, the generated sequence will be 0 1 2 3 4 5 6 7.

Using a datablock

If N is constant it can be specified using a datablock under the counter so you don’t need to use the optional input 2.

It’s easier to use and more compact.

If you are in building mode you can use this command to create a datablock directly under the mouse (you can change 10 by any value from 0 to 255):

/db 10


Important: if the datablock is changed you need to replace the counter or reload the game to update it’s max value (the datablock is read when creating the counter for optimization purposes).

Using an input

If N is variable you can directly use the readonly input 2.
Nothing complex here.

Alternatives

When you need only values from 0 to 7 you can use a 8-byte ROM reader linked to itself.

8-byte Rom driver example
Example of a 8-byte ROM blocks used as an
analog clock that output data from 0 to 7.


CENTeNrtlM0JwkAQhd/8RCTYgGWIBA/2pQfFg1ZhBWnAg2gHVmEFHkU8ZJ2ZGBLwokchS+bjzfB2A49
lCwCZ1cBqtyQgpayilFZARRXd6E6d9kHPpm19Hyq56vE9jsDConepjCbKt2KolTdrmOxalGPQ2vswf0
/+4rlvMZmmDYqZjf/4m/slwhgse0YONYK0ZLtcEpqDrkdExiGckPBoreHkoAbBJxZ7JtxPWelzP5mk1
jFnZ84amq7+l9grcvaT5cCMer0AFvFAuA==