Truth2circuit is a project mainly written in Haskell, it's free.
Automatically create logic circuits from truth tables
Basically, truth2circuit turns truth tables first into boolean expressions corresponding to the result column of the truth table and then into a drawing of a logic circuit implementing these expressions.
Input:
000 0
001 0
010 0
011 1
100 0
101 1
110 1
111 1
Output:
================================================================================
The truth table is generated by the following expressions:
--------------------------------------------------------------------------------
g = (a b + a c + b c)
================================================================================
Subdivided into variable bindings implementable by logic gates:
--------------------------------------------------------------------------------
a = a
b = b
c = c
d = a b
e = a c
f = b c
g = (d + e + f)
============
type number
------------
2xAND 3
3xAND 0
2xOR 0
3xOR 1
NOT 0
------------
total 4
================================================================================
The corresponding circuit looks like this:
--------------------------------------------------------------------------------
____ d ___ g
.------| - | .------\ -. |
a >------* | )^---' .-----) >^-
| .----|____- | .--/___-'
| | ____ e | |
'-+----| - | | |
b >--------* | )^-----' |
| .--|____- |
| | ____ f |
'-+--| - | |
c >----------* | )^-------'
'--|____-
Tested with GHC; may or may not work with other Haskell compilers/interpreters, since it uses some non-standard language features.
Optionally, install Cabal for building and installing.
Also optionally (only required for building gtruth2circuit), Gtk2Hs can be used for drawing "proper" (non-ASCII-art) graphics.
Using GHC:
ghc -isrc --make src/truth2circuit.hs -o truth2circuit
ghc -isrc --make src/gtruth2circuit.hs -o gtruth2circuit
This just builds the executable in the current path. If you also want an automated installation (only the executables at the moment), you can use Cabal:
sudo cabal install --prefix=/usr/local
The executable truth2circuit
acts a filter, i.e. it expects the truth table to be supplied on its
STDIN and writes results to STDOUT. For example:
cat examples/simple.tt | truth2circuit
The gui/gtk variante gtruth2circuit works the same way, except that it opens a window displaying the result instead of writing anything to STDOUT.
cat examples/simple.tt | gtruth2circuit