BOOLEAN Primitive

Custom logic definition using equations or truth tables.

PROGRAMMABLE

Model

I[1] I[n] BOOLEAN Q[1] Q[m]

Usage Syntax

The BOOLEAN primitive allows you to define custom logic using equations or truth tables. All equations must be specified within a single BOOLEAN keyword-field:

BOOLEAN=<boolean_block>

where <boolean_block> is a BEGIN/END block of the form:

BEGIN; equation; equation; ... ; END;

Boolean Part

A boolean part is a SNL PART statement that references the BOOLEAN built-in primitive (TYPE=BOOLEAN):

p=<part_name> t=boolean i=<input_list> $
    o=<output_list> state=<state_list> $
    boolean=<boolean_block>

Boolean Type

A boolean type is a SNL TYPE statement that includes boolean equations (BOOLEAN=) or explicitly declares the statement as a boolean type (COMPOSITION=BOOLEAN):

t=<type_name> i=<input_list> $
    o=<output_list> state=<state_list> $
    boolean=<boolean_block>

All instances of the same boolean type will have the same functionality.

Note: The continuation character, $, is used to continue equations over multiple lines.

Boolean Equations

Each boolean equation within the <boolean_block> is a four-valued (0, 1, X, Z) unidirectional assignment of the form:

<variable> == <expression>;

or

<variable> := <expression>;

Assignment Operators

Variables

A variable on the left-hand-side of an equation must be either:

The right-hand-side expression may contain any combination of:

Boolean Operators

Supported operators in order of precedence (highest to lowest):

Operator Operation Precedence
( ) Grouping Highest
^ Unary Complement (NOT) 1
= , ^= EQUAL, NOT-EQUAL Comparison 2
* AND 3
+ , @ , ^@ OR, Exclusive-OR, Exclusive-NOR 4
:= , == Assignment Lowest

Operator Notes

Example - Evaluation Order:

^a + b @ c * d

is evaluated as:

((^a) + b) @ (c * d)

Example - Tri-state Buffer:

out := (en * d) + (^en * 'z');

Boolean Tables

Tables allow defining complex logic in a compact grid format using the { } braces.

{ inputs : outputs :=
    entries
}

Table Entry Values:

Example:

{ in1, in2 : out := 
    0  0  1 ;
    1  ?  0 ;
    ?  1  0 ;
}

X-Handling

Value Updates

Understanding how values are updated is critical for proper boolean element behavior:

Initialization

At the beginning of simulation (time = 0, test = 1):

Complete Example - D Flip-Flop

The following TYPE statement defines a master-slave positive-edge triggered D flip-flop. The reset (nr) and set (ns) asynchronous inputs are active-low. On the falling edge of clock (c), the state of the d input is transferred to the master rank. On the rising edge of clock, the state of the master rank is transferred to the slave rank.

TYPE=dffe I=nr,ns,c,d O=q,nq $ STATE=prev_c,prev_r,prev_s,m BOOLEAN= $
BEGIN; $

clk_rise == c*^prev_c; $

clk_fall == ^c*prev_c; $

tm == (d*clk_fall + m*^clk_fall)*nr + ^ns; $
tq == (m*clk_rise + q*^clk_rise)*nr + ^ns; $
rs_race == (prev_r = '0')*(prev_s = '0')* $
           (nr = '1')*(ns = '1'); $

m == tm*^rs_race + 'X'*rs_race; $

q == tq*^rs_race + 'X'*rs_race; $

nq == ^tq*^rs_race + 'X'*rs_race; $

prev_c == c; $

prev_r == nr; $

prev_s == ns; $

END;

State Variables in This Example:

Partial Variables in This Example:

Instantiating This Type:

A typical PART statement that instantiates this dffe is:

PART=df1 TYPE=dffe I=re,se,cl,da O=q,notq

Note: State-variables are not referenced in the PART statement, which specifies signal/pin connections, since state-variables are internal to the dffe.

Modifying Boolean Types at Run Time

When debugging a design, it is useful to be able to modify a BOOLEAN definition during the simulation session. This is accomplished with the CLAMP command in one of the following formats:

CLAMP TYPE=<type_name> BOOLEAN=<boolean_block>

or

CLAMP PART=<part_name> BOOLEAN=<boolean_block>

Modifying All Instances

If all instances of a BOOLEAN definition are to be changed, use the CLAMP TYPE form:

Example:

Type=buf I=a O=b
Part=q I=a O=b BOOLEAN=BEGIN;b == a; END;

In this case, <type_name> would be buf.q. The CLAMP TYPE command will replace all instances of this type with the new equations.

Modifying a Specific Instance

If only a specific instance of a BOOLEAN type requires modification, use the CLAMP PART form, where the PART keyword-field specifies the BOOLEAN's instance name.

Important: The number of inputs, outputs, or state-variables cannot be changed with the CLAMP command. This requires a change in the network description and a subsequent re-compilation of the circuit.

Notes