Sophia Evans and Aidan Nowakowski
This tool is designed for manipulating Boolean algebraic functions and digital combinational logic circuits. It provides functionalities for converting Boolean expressions into canonical forms, minimizing them using prime implicants, and more.
User has the option of inputting either:
- A Boolean expression in (variables)(minterms) format (e.g.
(a,b,c)(1,3,4)
) - A digital combinational logic circuit in BLIF format
Example:
.model simple_model
.inputs a b c
.outputs f
.names a b c f
001 1
011 1
100 1
.end
The inputted description is stored as a BooleanExpression
, which contains vectors for variables
, minterms
, and maxterms
.
For a Boolean expression in minterms format, the tool extracts variables and minterms from the input string and stores them in the BooleanExpression object. The vector of maxterms is calculated by determining what possible values (given the number of variables) are not present in the minterms vector.
For BLIF format, the tool generates a truth table based on the number of input variables specified in the .inputs line. It then reads the .names line and the subsequent lines that define the minterms and maxterms of the expression. For each row in the truth table, the function checks if the row matches the minterm or maxterm and adds it to the corresponding vector in the BooleanExpression object.
The user has the option to choose from 12 different functions:
- Return the design as a canonical SOP
- Return the design as a canonical POS
- Return the design INVERSE as a canonical SOP
- Return the design INVERSE as a canonical POS
- Return a minimized number of literals representation in SOP
- Return a minimized number of literals representation in POS
- Report the number of Prime Implicants
- Report the number of Essential Prime Implicants
- Report the number of ON-Set minterms
- Report the number of ON-Set maxterms
- Draw SOP circuit as ASCII
- Draw POS circuit as ASCII
The repository is organized into two main directories: include
and src
.
This directory contains all the header files.
input.h
: Handles parsing of Boolean expressions and BLIF text.program.h
: Contains the main program logic.specs.h
: Contains function prototypes for canonical and minimized forms of Boolean expressions.tools.h
: Contains utility functions for Boolean expressions and terms.
This directory contains the implementation of the functions declared in the header files.
input.cpp
: Implements the functions for parsing Boolean expressions and BLIF text.program.cpp
: Implements the main logic of the application.specs.cpp
: Implements various forms of Boolean expression manipulation, such as constructing canonical and minimized forms.tools.cpp
: Implements utility functions for manipulating the Boolean expressions.
- Main Logic: The
program.cpp
file in thesrc
directory contains the main logic of the application, including handling user input and choices for operations. - Boolean Operations: For understanding how Boolean expressions are manipulated, refer to
specs.cpp
. - Utilities and Input: The
tools.cpp
andinput.cpp
files contain implementations for utility functions and input parsing, respectively.
Use -std=c++20
compile flag for best results.
(to run test.cpp: g++ -std=c++20 ./src/test.cpp ./src/LUT.cpp ./src/tools.cpp -o test) (to run main.cpp: g++ -std=c++20 ./src/main.cpp -o main)
For more information on BLIF:
- https://course.ece.cmu.edu/~ee760/760docs/blif.pdf
- http://bear.ces.cwru.edu/eecs_cad/sis_blif.pdf (slightly more recent version of above)
- https://rw1nkler-vtr-docs.readthedocs.io/en/latest/vpr/file_formats/
ASCII Circuits inspiration: