Appearance

Counter (edit) Counter (simulation)

Behavior

The Counter counts up or down between 0 and a configurable maximum value, wrapping at either end. It starts at 0 when simulation begins. On each active clock edge, it either counts one step or loads the value at the data inputs, provided EN is asserted. When EN is not asserted, clock pulses are ignored and the stored value is held. Reset takes priority over loading and counting.

When space permits, the title shows the cycle length (maximum value + 1). For example, "CTR 10" counts from 0 to 9. During simulation, the current value is displayed in the control block and its parts in the data blocks.

Pins

CLK

Input "Clock": Triggers counting or loading. By default, the active edge is the rising edge.

EN

Input "Input Enable": By default, 0 allows clock pulses to count or load; 1 inhibits counting and loading. Reset remains active and the data outputs retain the stored value when OE is asserted.

OE

Input "Output Enable": By default, 0 enables the data outputs; 1 sets them to high impedance. Counting, loading and CO remain active.

Up/Down

Input "Direction": By default, 0 selects counting up and 1 selects counting down.

LD/CNT

Input "Load/Count": By default, 1 loads the data inputs and 0 counts on the active clock edge.

R

Input "Reset": A value of 1 resets the counter to 0 asynchronously, independent of the clock and other inputs.

CO

Output "Carry Out": Has the value 1 when the counter equals the maximum value, otherwise 0.

Data inputs

The pins on the left of the data blocks supply the value to load. Their labels indicate the lowest bit position of each block, starting with bit 0 at the top.

Data outputs

The pins on the right output the counter value using the same grouping as the data inputs.

Properties

"Bit Width" and "Fan Out" can only be changed while all data pins are unconnected. Control pins may remain connected.

Bit Width

The total number of bits of the counter, from 1 to 64.

Fan Out

The number of data blocks. Each block contains an input and an output with "Bit Width" / "Fan Out" bits.

Maximum value

The inclusive upper counting limit, entered as an unsigned decimal number within the bit width. Defaults to the largest value supported by the bit width. Set to 9 for a decade counter.

Representation

The number format used to display the title and simulation values.

CLK logic

Positive logic triggers on the rising edge; negative logic on the falling edge.

LD/!CNT logic

Positive logic loads at 1 and counts at 0; negative logic reverses these values.

Up/!Down logic

Positive logic counts up at 1 and down at 0; negative logic reverses these values.

Input enable (EN) logic

Positive logic enables counting and loading at 1; negative logic enables them at 0 (default). An unconnected EN is treated as 0.

Output enable (OE) logic

Positive logic enables the data outputs at 1; negative logic enables them at 0 (default).

Master/Slave

If set, counting or loading is buffered on the active clock edge while EN is asserted and transferred to the counter and outputs on the opposite edge. Once sampled, the buffered value is transferred even if EN changes before the opposite edge. Reset clears both stages immediately.