Skip to content

salahadell/Logic-Simulator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Logic-Simulator

Logic Simulator is a simple C++ application that simulates basic logic gates (AND, OR, NAND, XOR) using nodes and gates. The application reads an input file to set up nodes, gates, and simulate the logic.

Project Structure

Logic-Simulator/

├── CMakeLists.txt

├── include

   └── Node.h
   └── Gate.h
   └── Simulator.h

├── src

   └── CMakeLists.txt
   └── main.cpp
   └── Node.cpp
   └── Gate.cpp
   └── Simulator.cpp

Prerequisites

- CMake (version 3.10 or higher)
- A C++ compiler (e.g., g++)

Building the Project

git clone <repository_url>
cd Logic-Simulator
cmake --build build --target install

Running the Program

./Logic-Simulator <input file>

The program will simulate the logic gates as defined in the input file and print the results. The program will wait for the user to press Enter before closing.

Input File Format

The input file should contain commands in the following format:

SET <node_name> <value> : Set the value of a node.

<gate_type> <input1> <input2> <output> : Add a gate of the specified type (AND, OR, NAND, XOR) with the given inputs and output.

SIM : Simulate the gates.

OUT <node_name> : Output the value of the specified node.

OUT ALL: Output the values of all nodes.

Example

OR A B C
AND C D E
SET A 1
SET B 0
SET D 0
SIM
OUT E
OUT ALL

Output Example

Logic Simulator Output Example

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors