State Machine

In this Topic Hide

Netlist entry

Axxxx [ in_0 in_1 .. in_n ] clk reset [ out_0 out_1 .. out_n ] model_name

Connection details

Name Description Flow Type Vector bounds
in Input in d, vector none
clk Clock in d n/a
reset Reset in d n/a
out Output out d, vector 1 - no upper bound

Model format

.MODEL model_name d_state parameters

Model parameters

Name Description Type Default Limits
clk_delay Delay from CLK real 1nS none
reset_delay Delay from reset real 1nS none
state_file State transition specification file name string none none
reset_state Default state on RESET & at DC integer 0 none
input_load Input loading capacitance (F) real 1pF none
clk_load Clock loading capacitance (F) real 1pF none
reset_load Reset loading capacitance (F) real 1pF none
family Logic family string UNIV none
in_family Input logic family string UNIV none
out_family Output logic family string UNIV none

File Syntax

The following is a formal description of the state machine file syntax using Backus-Naur form (BNF). '{' and '}' mean "zero or more" of the enclosed items.

state_machine_def :: state_def { state_def }

state_def :: header_line { continuation_line }

header_line :: STATENUM outputs inputs SEPARATOR STATE_DEST

continuation_line :: inputs SEPARATOR STATE_DEST

outputs :: OUTPUT_VALUE { OUTPUT_VALUE }

inputs :: INPUT_VALUE { INPUT_VALUE }

STATENUM :: 0 based integer indicating state number.

SEPARATOR :: Any sequence of characters but not whitespace. '->' is conventional

STATE_DESTINATION :: integer indicating state number.

OUTPUT_VALUE :: two digit sequence to define one of the 12 output states. First character can be 0, 1 or U. Second character can be s, r, z or u for 'strong', 'resistive', 'high-z', and 'undefined' respectively.

INPUT_VALUE :: 0, 1, x, or X

The idea is to have N state_def's where N is the number of states. Each state_def has one header_line and a number of following continuation_lines. Both define the destination state for a given combination of inputs. The header_line additionally defines the state being defined and the output value for that state. Header lines and continuation lines are distinguished by counting the tokens. The system does currently not appear to fail gracefully if this is wrong. A header_line should have (num_inputs+num_outputs+3) tokens and a continuation_line should have (num_inputs+2).

The number of inputs and outputs is defined in the netlist line which is in the form:

Axxx [ inputs ] clk reset [ outputs ] modelname

Notes

Currently this model is unsupported as it has not undergone testing or analysis. It is part of the original XSPICE system and should be compatible with other implementations but this cannot be guaranteed.

The following is an example of a state transition specification file

* This is a simple example of a state machine state file
* It is a 2 bit up down counter with synchronous reset
*Present Outputs Inputs State destination
*State for state (reset, up/down)
0 0S 0S 0 0 -> 3
0 1 -> 1
1 0 -> 0
1 1 -> 0
1 0S 1S 0 0 -> 0
0 1 -> 2
1 0 -> 0
1 1 -> 0
2 1S 0S 0 0 -> 1
0 1 -> 3
1 0 -> 0
1 1 -> 0
3 1S 1S 0 0 -> 2
0 1 -> 0
1 0 -> 0
1 1 -> 0

See Examples/Digital_Devices/state_updown.sxsch