Analog Design

Kevin Aylward B.Sc.

XSpice State Machine


Back to Contents

XSpice Digital State Machine

The XSpice digital state machine allows arbitrary complex digital state machines to be constructed. Its main characteristics are:

1 An arbitrary number of inputs.

2 A clock input.

3 A reset input.

4 An arbitrary number of outputs.

Its generic spice netlist is in the following format, however, SuperSpice requires this model to be wrapped up in a .subckt definition.

The basic format is [input node list] clk reset [output node list] model_name, e.g.

a4 [2 3 4 5] 1 12 [22 23 24 25 26 27 28 29] state1 
.model state1 d_state(clk_delay=1.0e-9 reset_delay=1.0e-9 state_file=newstate.txt reset_state=2 reset_load=1p input_load=1p clk_load=1p) 

The first set of [] contains the list of input node connections. Immediately following the first [] is the clock node connection, following this is the reset node connection, followed by the list of input node connections enclosed in []. The last string is the name of the state machine model. The .model parameters are self explanatory, d_state being the xspice model type, the loads being capacitive loads which in general can be ignored.. The state_file parameter points to the file that contains the state machine description.

Note: If the file name contains spaces, the name must be in single quotes, e.g. 'c:\Program Files\AnaSoft\SuperSpice\System\Counter.txt'. Other XSpice simulation engines may or may not support spaces in file names as this is a SuperSpice extension to the XSpice code.

An example .subckt is shown here:

.subckt 4BitProgramableCounter_XN _ssi_pin_clk reset in1 in2 in3 in4 out1 out2 out3 out4
*
a1 [in1 in2 in3 in4] _ssi_pin_clk reset [out1 out2 out3 out4] state1 
.model state1 d_state(clk_delay=1.0e-9 reset_delay=1.0e-9 state_file=C:\SoftwareDevelopment\SuperSpice\Debug\System\4BitProgrmableCounter.txt reset_state=1) 
.ends 

Note the addition of the _ssi_pin_ string to one pin name in order to prevent SuperSpice automatically inserting pin current probing 0V sources. 

Note: You may have to disable the "OP" operating point calculation for state machines and digital logic.

State Machine Description File

The state machine description file specifies the behavior the d_state model.

This file consist of lists of text lines of two types.

1 A header line.

2 One or more continuation lines for the header line.

A header line is of the following format.

[current state number] [current output list with output type] [current input list] -> [next output state number]

e.g.

3 0s 1s 0 0 1 -> 4

This line says that current state 3, has 2 outputs with current values 0s 1s, with 3 inputs with values 0 0 1 that transitions to state 4. The letters after the logic values determines the output type, described in the output type bit codes description. 

Continuation lines are of the following format type.

0 1 0 -> 5
1 0 0 -> 6
1 1 0 -> 3

These lines say that when the inputs are 0 1 0, the state specified by its prior header transitions to state 5. When the inputs are 1 0 0, the state specified by its header transitions to state 6. etc.

A typical file might look like:

0 0s 0s 0 0 -> 1
            0 1 -> 3
            1 0 -> 2
            1 1 -> 0
*
1 0s 1s 0 0 -> 4
            0 1 -> 5
            1 0 -> 7
            1 1 -> 6
*
2 1s 0s 0 0 -> 4
            0 1 -> 6
            1 0 -> 2 
            1 1 -> 0
*
3 1s 1s 0 0 -> 1
            0 1 -> 0
            1 0 -> 2
            1 1 -> 3
*
4 0s 0s 0 0 -> 2
            0 1 -> 3
            1 0 -> 0
            1 1 -> 1

etc...

Note that any white space separates text fields. "*" lines are ignored. The "->" can be any two character string.

Output Type Bit Codes

The output type of the state machine outputs are given by:

0s bit_value = 0
1s bit_value = 1
Us bit_value = 2
0r bit_value = 3
1r bit_value = 4
Ur bit_value = 5
0z bit_value = 6
1z bit_value = 7
Uz bit_value = 8
0u bit_value = 9
1u bit_value = 10
Uu bit_value = 11
*
bit_value = 0
out->state = ZERO;
out->strength = STRONG;
*
bit_value = 1
out->state = ONE;
out->strength = STRONG;
*
bit_value = 2
out->state = UNKNOWN;
out->strength = STRONG;
*
bit_value = 3
out->state = ZERO;
out->strength = RESISTIVE;
*
bit_value = 4
out->state = ONE;
out->strength = RESISTIVE;
*
bit_value = 5
out->state = UNKNOWN;
out->strength = RESISTIVE;
*
bit_value = 6
out->state = ZERO;
out->strength = HI_IMPEDANCE;
*
bit_value = 7
out->state = ONE;
out->strength = HI_IMPEDANCE;
*
bit_value = 8
out->state = UNKNOWN;
out->strength = HI_IMPEDANCE;
*
bit_value = 9
out->state = ZERO;
out->strength = UNDETERMINED;
*
bit_value = 10
out->state = ONE;
out->strength = UNDETERMINED;
*
bit_value = 11
out->state = UNKNOWN;
out->strength = UNDETERMINED;


Kevin Aylward 2013

All rights reserved

The information on the page may be reproduced

providing that this source is acknowledged.

Website last modified 30th August 2013

www.kevinaylward.co.uk