Eqntott: Truth Table Generator from Boolean Equations

2750
 

When both the inputs ‘a’ and ‘b’ are zero, the output ‘c’ is zero and ‘d’ is ‘1.’ If either ‘a’ or ‘b’ is ‘1,’ ‘c’ is ‘1’ and ‘d’ is ‘0.’

‘-f’ option allows an input to also be present in the output, and used as though the value was observed at different times. Consider, for example:

[stextbox id=”grey”]NAME = f;
INORDER = a;
OUTORDER = a;
a = !a;[/stextbox]

When you execute the above example as:

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

The output will be:

[stextbox id=”grey”].i 1
.o 1
.na f
.ilb a
.ob a
.p 1
.f 1 1
0 1
.e[/stextbox]

The truth table output is ‘1’ only when the input is ‘0.’ The ‘-s’ and ‘-f’ options are mutually exclusive.

eqntott can attempt to minimise the logic terms in equations. ‘-r’ option will try to reduce the minterms in the output. Consider the example:

[stextbox id=”grey”]NAME = reduce;
INORDER = x y;
OUTORDER = z;
z = x & y | x;[/stextbox]

When you use the above example with ‘-l’ option as:

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

The output will be:

[stextbox id=”grey”].i 2
.o 1
.na reduce
.ilb x y
.ob z
.p 2
1- 1
11 1
.e[/stextbox]

Using ‘-r’ option, eqntott will try to minimise the truth table output:

[stextbox id=”grey”]$ eqntott -l -r reduce.eqn[/stextbox]

The output will be:

 [stextbox id=”grey”].i 2
.o 1
.na reduce
.ilb x y
.ob z
.p 1
1- 1
.e[/stextbox]

The output ‘z’ is ‘1’ whenever ‘x’ is ‘1.’

You can define expressions using ‘define’ keyword. The XOR logic takes two binary inputs, and returns ‘1’ only when either input is ‘1’ but not both. It can be expressed as:

[stextbox id=”grey”]#define xor(a,b) (a&!b | !a&b)
NAME = xor;
INORDER = a b;
OUTORDER = c;
c = xor (a,b);[/stextbox]

On running the example as:

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

The output will be:

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

As a final example, consider generating an odd parity bit for three inputs. The parity bit is set to ‘1’ when the number of ‘1’s’ in the input is even, so as to make the total number of ‘1’s’ odd. We can define the logic using:

 [stextbox id=”grey”]

#define xor(a,b) (a&!b | !a&b)
NAME = parity;
INORDER = x y z;
OUTORDER = p;
p = !( xor (xor(x,y), z) );

[/stextbox]When you run the above example with ‘-l’ and ‘-s’ options as:

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

The output will be:

 [stextbox id=”grey”]

.i 3
.o 1
.na parity
.ilb x y z
.ob p
.p 4
000 1
011 1
101 1
110 1
.e

[/stextbox]You can refer the manual page of eqntott for more documentation. Sources are available from the eqntott webpage.


The author is a free software developer at the Fedora project, and also a blogger. He also
co-maintains the Fedora Electronic Lab project

SHARE YOUR THOUGHTS & COMMENTS

Please enter your comment!
Please enter your name here