# Counter

Library: | Memory |
Introduced: | 2.3.0
Appearance: |

## Behavior

The counter holds a single value, emitted on the output Q. The value updates on the clock trigger (triangle on the south edge) based on the Load, Enable(ct), and Up Down (UD) inputs.

Load | Enable(ct) | Up Down (UD) | Trigger Action
--- | --- | --- | ---
0 or Z | 0 | X | The counter remains unchanged.
0 or Z | 1 or Z | 1 or Z | The counter increments.
0 or Z | 1 or Z | 0 | The counter decrements.
1 | X | X | The counter loads the value found at the D input.

The Reset input (south edge, labeled R or 0) resets the counter's value to 0 asynchronously. As long as the Reset input is 1, the value is pinned to 0, regardless of the clock or other inputs.

## Pins

The following pin descriptions apply to both the Classic and Logisim-evolution appearances. Note that the Logisim-evolution appearance uses standard IEC/IEEE symbolic notation.

East edge, labeled Q (output, bit width matches Data Bits attribute)
  Outputs the value currently stored by the counter.
East edge, lower pin (output, bit width 1)
  Carry (shown as 3CT=MAX / 4CT=0): This output is 1 whenever the counter is at its maximum value and counting up, or when it is at 0 and counting down. The Load and Enable(ct) inputs do not directly affect this output.
West edge, top pin (input, bit width 1)
  Load (shown as M1): When this is 1, the counter will load the value found at the D input at the next clock trigger, regardless of the Enable(ct) input.
West edge, middle pin labeled D (input, bit width matches Data Bits attribute)
  Data: Input for the value to be loaded when Load is active.
West edge, lower pin labeled ct (input, bit width 1)
  Enable(ct) (shown as G5): When this is 1 or unconnected, the counter increments or decrements on the clock trigger, provided the Load input is 0.
North edge, labeled UD (input, bit width 1)
  Up/Down (shown as M3/M4): When 1 or Z, the counter counts up. When 0, it counts down. This input dictates direction when Load is 0 and Enable(ct) is 1.
South edge, indicated with a triangle (input, bit width 1)
  Clock (shown as C6 / 2,3,5+ / 2,4,5-): Triggered as specified by the Trigger attribute. In the Logisim-evolution symbol, the multiple notations reflect internal dependencies on count/load modes.
South edge, labeled 0 or R (input, bit width 1)
  Reset (shown as R): While this is 1, the counter is asynchronously pinned to 0.

## Attributes

When the component is selected or being added, Alt-0 through Alt-9 alter its Data Bits attribute.

Data Bits
  The bit width of the value emitted by the component.
Maximum Value
  The maximum value, at which point the counter will set its carry output.
Action On Overflow
  The behavior when the counter attempts to increment beyond the maximum value or decrement beyond 0. Possible actions: Wrap around, Stay at value, Continue counting, or Load next value.
Trigger
  Configures how the clock input is interpreted (rising or falling edge).
Label / Label Font
  The text and font associated with the component's label.

## Poke Tool Behavior

Clicking the counter brings keyboard focus, and typing hexadecimal digits will change the value stored in the counter.

## Text Tool Behavior

Allows the label associated with the component to be edited.

Back to Library Reference