Thursday, November 30, 2023

# Eqntott: Truth Table Generator from Boolean Equations

This tutorial demonstrates the use of eqntott software with some code examples

Shakthi Kannan

eqntott (short for ‘equation to truth table’) is a software tool that can generate truth tables from Boolean equations, which can be used for programmable logic array (PLA) programming. It was initially written at Berkeley, and ported to work on GNU/Linux. It is released under the new BSD licence.

Consider a simple AND example:

[stextbox id=”grey”]NAME = and;
INORDER = a b;
OUTORDER = c;
c = a & b;[/stextbox]

Here NAME refers to the name of the PLA, and is called ‘and’. INORDER lists the input order of elements, while OUTORDER has the list of outputs in the truth table. Copy this example in a text editor and save it as ‘and.eqn.’

To run the above example, use ‘cd’ command in order to go to the directory where the example is saved. Now run the following command:

[stextbox id=”grey”]\$ eqntott and.eqn[/stextbox]

You will get the output as:

[stextbox id=”grey”].i 2
.o 1
.p 1
11 1
.e[/stextbox]

’.i’ in the output refers to the number of inputs defined, which refers to ‘a’ and ‘b’ in the above example. ’.o’ corresponds to the number of output variables, which is ‘c.’ ’.p’ is the number of product terms. The truth table generated shows that the output is ‘1’ when both the inputs are ‘1’.

You can use ‘-l’ option with eqntott to output the PLA name, input and output elements:

[stextbox id=”grey”]\$ eqntott -l and.eqn[/stextbox]

The output will be:

[stextbox id=”grey”].i 2
.o 1
.na and
.ilb a b
.ob c
.p 1
11 1
.e[/stextbox]

The name of the PLA is mentioned next to ’.na’ in the output. The order of inputs and outputs in the truth table is also listed.

The following expressions are allowed in the equations for eqntott:

 Expression Meaning & Logical AND operation | Logical OR operation ! Logical NOT operation ZERO or 0 False or the value zero ONE or 1 True or the value one ( ) To enclose any expression ? Don’t care condition name Any input/output in the expression

The half adder circuit adds two binary digits, and produces a sum and a carry. It can be implemented as follows:

[stextbox id=”grey”]

INORDER = a b;
OUTORDER = s c;
c = a & b;
s = (!a & b) | (a & !b);[/stextbox]

When the above equation is run with eqntott:

The output will be:

[stextbox id=”grey”].i 2
.o 2
.ilb a b
.ob s c
.p 3
01 1 0
10 1 0
11 0 1
.e[/stextbox]

The sum is represented by ’s’ and carry with ‘c.’ When either the sum or carry is ‘1,’ the sum is ‘1’ and carry is ‘0.’ When both the sum and carry are ‘1,’ the sum is ‘0’ and carry is ‘1.’

The output of eqntott can be customised using ‘-.key’ argument. The default option is the string ‘iopte.’ A few key code options with their output meaning are given below:

 Character Output e .e f .f output-number input-number h Human readable format i .i number of inputs l Truth table with PLA name, inputs and outputs o .o number of outputs p .p number-of-product-terms v eqntott version number S PLA connectivity summary

If the half adder example is run with the following key options:

The output will be:

.ilb a b
.ob s c
2 inputs, 2 outputs, 3 product terms.
s !a b
s a !b
c a b
.p 3
01 1 0
10 1 0
11 0 1
eqntott 9.0[/stextbox]

The PLA connectivity summary can be displayed using ’-.S’ key code option. When used with ‘and.eqn’ example as:

[stextbox id=”grey”]\$ eqntott -.S and.eqn[/stextbox]

The output will be:

[stextbox id=”grey”]PLA Connectivity Summary
#pterms input
1 b
1 a
#pterms output
1 c
#out #in product term expression
1 2 a & b[/stextbox]

‘-s’ option allows you to use an output variable in another expression. Consider, for example:

[stextbox id=”grey”]NAME = s;
INORDER = a b;
OUTORDER = d;
c = a | b;
d = !c;[/stextbox]

When you run the above example with ‘-s’ option as:

[stextbox id=”grey”]\$ eqntott -l -s s.eqn[/stextbox]

The output will be:

[stextbox id=”grey”].i 3
.o 2
.na s
.ilb a b c
.ob d c
.p 3
00- 1 0
-1- 0 1
1– 0 1
.e[/stextbox]