Skip to content

Features

Harith-Y edited this page Dec 14, 2024 · 2 revisions

Features

Interactive User Input:

The program uses a menu-driven interface to guide users through creating and managing circuits.

Supported ICs:

  • AND Gate IC
  • OR Gate IC
  • NOT Gate IC
  • XOR Gate IC
  • NAND Gate IC
  • NOR Gate IC
  • XNOR Gate IC

Dynamic Circuit Design:

Users can:

  • Create new ICs.
  • Set pin values for ICs.
  • Connect power to the ICs.
  • Connect ICs with wires.
  • Simulate the circuit and observe the output.

IC Manipulation:

Set and retrieve pin values, connect ICs to each other, and use logic gates.

Operator Overloading:

Use operators for pin manipulation, IC comparison, and power connections.

Error Handling:

The program handles invalid inputs and operations gracefully.

Virtual Functions:

Define a simulate() function for IC-specific behavior and execute digital logic. Simulate INDIVIDUAL ICs and view pin states after simulation.

Usage

  • Create IC objects: Instantiate various IC objects, e.g., ANDGateIC, ORGateIC.
  • Connect Power: Connect VCC and GND to the ICs to simulate power supply.
  • Simulate: Call the simulate() function on each IC to execute its digital logic.

Classes and Their Functions

Class IC

The template-based Base class for all simulating all ICs.

  • Constructor: Initializes the IC with pins, VCC, GND, and a name.
  • getTotalPins(): Returns the total number of pins.
  • connectVCC(): Connects the IC to the power (VCC) rail.
  • connectGround(): Connects the IC to the ground (GND) rail.
  • setPin(int pin, T value): Sets a specific pin's value.
  • getPin(int pin): Retrieves a specific pin's value.
  • operator[](int pinNumber): Accesses pin values using the [] operator (0-indexed).
  • operator()(int pinOut, IC& otherIC, int pinIn): Connects an output pin to another IC's input pin.
  • operator+=(const string& connection): Connects the IC to VCC or GND.
  • operator==(const IC& other): Compares two ICs for equality.
  • operator!(): Resets all pin values to 0.

Class Wire

The Wire class connects IC pins to simulate signal flow between them.

  • Constructor: Initializes the wire with the source IC and pin, as well as the destination IC and pin.
  • Destructor: Safely disconnects the wire, resetting the connection to prevent dangling pointers.
  • connect(): Connects the source IC's pin to the destination IC's pin and transfers the signal.
  • disconnect(): Disconnects the wire, resets the destination IC's pin value, and prevents dangling pointers.
  • getSourceIC(): Returns a pointer to the source IC.
  • getDestinationIC(): Returns a pointer to the destination IC.
  • getSourcePin(): Returns the source pin number.

Logic Gate ICs

Each gate IC (ANDGateIC, ORGateIC, NOTGateIC, NORGateIC, NANDGateIC, XORGateIC, XNNORGateIC) inherits from IC and overrides the simulate() method to perform specific logic operations.

Follow the on-screen menu to:

  • View ICs.
  • Create ICs.
  • Set pin values.
  • Connect ICs with wires using the Wire class.
  • Simulate the circuit.
  • Connect Power & Ground to the ICs
  • View IC pin states.

Sample Workflow

  • Step 1: Create an AND Gate IC.
  • Step 2: Set input pin values to 1 and 0.
  • Step 3: Simulate the IC to view the output.
  • Step 4: Connect the output of the AND Gate to another IC's input using a wire.

Exit the Program

To exit the simulator, choose the Exit option from the menu.