A logic circuits simulator program through textual description, in Python3.
- You need to translate the visual circuit to textual;
- You need to run the main.py file.
Visual Circuit Example:
To translate to text, you need create a .txt file in the folder descriptions, following the format below:
n_inputs,[number of inputs],[input name1],[...],[input nameN]
n_outputs,[number of outputs],[output name1],[...],[output nameN]
n_gates,[number of gates],[gate name1],[...],[gate nameN]
[gate name1],[type gate],[output name],[input name1],[...],[input nameN]
[...]
[gate nameN],[type gate],[output name],[input name1],[...],[input nameN]
*Obs¹: Gate types supported: And, Nand, Or, Nor, Xor, Xnor, Not.
So, the example of visual circuit above, in text is:
n_inputs,3,Cin,A,B
n_outputs,2,S,Cout
n_gates,5,g1,g2,g3,g4,g5
g1,xor,y1,A,B
g2,xor,S,y1,Cin
g3,and,y2,y1,Cin
g4,and,y3,B,A
g5,or,Cout,y2,y3
To run the program, you need to install the Python3 in your machine. After you ran the main.py file, the .txt truth table file, with all input test cases, will be genereted in the folder truth tables. For the visual example used, it will be like:
| Cin | A | B | S | Cout |
|-------+-----+-----+-----+--------|
| 0 | 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 1 | 0 |
| 0 | 1 | 0 | 1 | 0 |
| 0 | 1 | 1 | 0 | 1 |
| 1 | 0 | 0 | 1 | 0 |
| 1 | 0 | 1 | 0 | 1 |
| 1 | 1 | 0 | 0 | 1 |
| 1 | 1 | 1 | 1 | 1 |
*Obs²: All the files in the folder descriptions, will have their respective truth tables, in the folder, truth tables.
- Fork it (https://github.com/rafaelalmeida2909/Logic-Circuits/fork)
- Create your feature branch (
git checkout -b feature/fooBar
) - Commit your changes (
git commit -am 'Add some fooBar'
) - Push to the branch (
git push origin feature/fooBar
) - Create a new Pull Request