boolcalc

Description

boolcalc is a simple RPN (reverse polish notation) boolean calculator. It allows the four main boolean operators: AND, OR, XOR, and NOT, as well as very simple support for D-latches and JK flip-flops. After reading the expression, it prints out a truth table for it.

This program is placed in the public domain. It uses pretty standard techniques, so I did not feel the necessity to put any licence on it. Feel free to modify the program in any way you see fit. Copy it, redistribute it, and use it in any way you want -- I don't care, as long as it's all honest and legal. (Of course, it's always nice to acknowledge your sources ;-) )

Disclaimer

The usual stuff: I'm not responsible for anything that happens to your computer as a result of running boolcalc. I'm only distributing the source files, so by compiling it, you agree to be fully responsible for any results of the program.

Requrements

Your compiler should at least have support for the STL stack, and should be able to handle exceptions. If you compiler supports ISO-standard C++ (I have yet to find one that does), it should be fine.

Usage

boolcalc takes no command line arguments. It reads from stdin and writes to stdout, so you can easily type expressions into text files, redirect the input to the file, and then redirect the output to another file.

The input has the following format:

For example, the following input: "3 A B + C * '\n' A C! + B! ^ '\n'" would result in the functions f1=(A+B)*C and f2=(A+(!C))^(!B).

The expressions must be in RPN notation. That is, the operands come first, and then the operator. eg. ABC+* -> A*(B+C) To check that you got it right, boolcalc will print out the expression in `normal' format. Note that, as far as boolcalc is concerned, + has higher precedence than ^ so if it prints out A^B+C, it means A^(B+C).

After it prints out the expression, it prints out a truth table. On the left side are the inputs, and on the right side are the results of the espressions. This should be fairly self-explanatory.

`Bugs'

No, there aren't really any bugs, at least that I'm aware of. Just some shortcuts that I made that might cause some problems if you're not aware of them. I assume that you're all intelligent people, and so you can properly formulate an RPN expression with the proper number of gates, so there shouldn't be any problems. But just in case you mess something up and you want to know what's wrong...

To come...

Revision History

v.0.10 - Nov 7, 1998 v.0.02 - Oct 15, 1997 v.0.01 - Oct 3, 1997

The Author

You can e-mail me at hubert@cs.ualberta.ca, or if that address is invalid (ie. I'm graduated), you can try my alternate address. Send me comments or criticism.

My home page (the one that you'll be able to find boolcalc) is here.
[ Back ]
Last updated November 9, 1997. <><