Devices << VirtualDevices << LogicDevices << SequentialLogicDevices Software Overview  |  Sitemap  |  Downloads  |  Developers  |  Forums
 Home Devices FAQs How-Tos Projects Tutorials Recipes

# Sequential (Stateful) Logic Devices

Sequential Logic Devices contain state, and they use both their input terminals and their state to create their overall functions. Common Sequential Logic Devices are registers, counters, and memory Devices.

## Counter Device

Counters perform a binary incrementing function. When a Counter reaches its maximum value, it "wraps" back to its starting value. Counters rely on a digital "clock", which is a wire which oscillates between an `on` and an `off` value. Each time a Counter sees an `off` to `on` clock transition, it will increase its count by one.

Counters have a user defined set of inputs and outputs. The outputs perform the counting function. The inputs serve as a reference for a Counter output called "eq". The "eq" output will turn `on` when the value at the Counter inputs equals the value at the Counter outputs. If the inputs are not all defined (defined means having a value of either `on` or `off`), the "eq" output will never turn `on`.

Counters have two dedicated inputs called "reset" and "sync_reset". Both are used to set a Counter to its lowest value (outputs all will be `off`), or to "clear" the Counter. "reset" will cause the Counter to clear the moment it becomes active. "sync_reset" will clear the Counter when the Counter is clocked. The Counter will stay cleared until both "reset" and "sync_reset" are `off`.

A simple way to get a Counter to count to a user defined value is to place the desired value on the Counter's user defined inputs and connect the Counter's "eq" output to the Counter's "sync_reset" input. Each time the Counter's outputs equal the Counter's inputs, the counter will clear and start counting again.

The "clk" input provides the clocking for the Counter. Each time the "clk" input sees an `off` to `on` transition, it will cause the Counter to increment.

Counter Devices are created by running the Counter Script with the following parameters:

• `inputs : a set of input names for the Counter Device`
• `outputs : a set of output names for the Counter Device`

Running the Counter Script with the parameters listed below will create an 4 bit counter with four inputs (D1, D2, D3, D4) and four outputs (Q1, Q2, Q3, Q4).

`id: "my_counter"`
`inputs: "D1,D2,D3,D4"`
`outputs: "Q1,Q2,Q3,Q4"`

## Debouncer Device

The Debouncer Device removes noise from signals on wires. If a wire usually has the right value, but occasionally jumps to an incorrect value and back to the right value, the incorrect value is referred to as noise. The Debouncer Device removes noise from signals.

The Debouncer Device will only pass a signal from its input to its output terminal when the signal is stable for a user definable period of time. If, for example, a signal occasionally went to an incorrect value for 5 seconds or less, the Debouncer Device could be set to only pass signals that were stable for 6 seconds, and the noise would be removed from the signal.

The Debouncer Device has a "clk" input, which it uses to measure the time a signal on its input is stable. Every time the "clk" input transitions from `off` to `on`, the Debouncer Device checks to see if its input had the same value for the 2 previous "clk" transitions. If it has, the Debouncer Device will pass its input to its output.

A simple way to set up a Debouncer Device is to wire an Oscillator Device output to a Debouncer Device's "clk" terminal. Using the less than 5 seconds of noise example above, one could set the Oscillator period to 3 (seconds), and that would guarantee that the Debouncer would only pass signals which were stable for 6 seconds or more.

The Debouncer Device has one or more inputs, matched with one or more outputs, with each input/output pair providing a debouncing function.

Debouncer Devices are created by running the Debouncer Script with the following parameters:

• `inputs : a set of input names for the Debouncer Device`
• `outputs : a set of output names for the Debouncer Device`

Running the Debouncer Script with the parameters listed below will create 2 debouncing functions, one with the input and output "1" and "1S", and the other with input and output "2" and "2S".

`id: "my_two_debouncers"`
`inputs: "1,2"`
`outputs: "1S, 2S"`

## Register Device

The Register Device is a storage Device, each Register output holding a single `on` or `off` value. Values are stored in Registers by "clocking" them with a "clk" input terminal. When a Register "clk" input sees an `off` to `on` transition, it stores the values at its inputs.

Registers have a user defined set of inputs and a matched set of user defined outputs. A register input is clocked to its paired output on every `off` to `on` transition on the "clk" input.

Registers have a "reset" input terminal. When the "reset" terminal is `on`, all the output terminals on the Register will be forced to `off`, regardless of clock transitions or the values on the user defined inputs.

Register Devices are created by running the Register Script with the following parameters:

• `inputs : a set of input names for the Register Device`
• `outputs : a set of output names for the Register Device`

Running the Register Script with the parameters listed below will create a register which stores 2 values, one with the input and output terminals "D1" and "Q1", and the other with input and output terminals "D2" and "Q2".

`id: "my_two_registers"`
`inputs: "D1,D2"`
`outputs: "Q1, Q2"`