Question: PLEASE HELP to Finish the code. Need to finish Half adder / Full adder / Multiplexer. #include #include #include #include using namespace std; // Enumeration

PLEASE HELP to Finish the code. Need to finish Half adder / Full adder / Multiplexer.

#include #include #include #include

using namespace std;

// Enumeration for the type of gate enum GATE_TYPE { NOT, AND, OR, NAND, NOR, HALF_ADDER, FULL_ADDER, MULTIPLEXER, EXIT };

// Function to implement the NOT gate int not_gate(int p) { return !p; }

// Function to implement the AND gate int and_gate(int p, int q) { return p && q; }

// Function to implement the OR gate int or_gate(int p, int q) { return p || q; }

// Function to implement the NAND gate int nand_gate(int p, int q) { return !(p && q); }

// Function to implement the NOR gate int nor_gate(int p, int q) { return !(p || q); }

// Function to implement the half adder void half_adder(int p, int q, int& sum, int& carry) { sum = nor_gate(p, q); carry = and_gate(p, q); }

// Function to implement the full adder void full_adder(int p, int q, int c, int& sum, int& carry) { int s1, s2, c1, c2; half_adder(p, q, s1, c1); half_adder(s1, c, s2, c2); sum = s2; carry = c1 || c2; }

// Function to implement the multiplexer int multiplexer(int s1, int s0, vector inputs) { return inputs[s1*2 + s0]; }

int main() { int choice, p, q, c, s, carry; vector inputs(4);

do { cout > choice;

switch(choice) { case NOT: cout

case AND: cout

Below is the requirement.

Write a C++ menu-driven program that prompts the user to select the type of gate and determine the output for the given inputs. Build the truth table for all inputs for the variable(s). For example, for a single variable q, there are two truth values, true/false or 1/0 respectively.

* The program should be a menu-based program that continuously tests any operation until the user decides to exit the program.

Basic Digital Logic Gates ========================= 1 - NOT gate 2 - AND gate 3 - OR gate 4 - NAND gate 5 - NOR gate 6 - Half-adder (see diagram) 7 - Full-adder (see diagram) 8 - Multiplexer 4 to 1 (2 switch variables as selectors for 4 inputs and 1 output; see diagram) 9 - Exit

Hint: The gates are equivalent to symbols, ,, which we have talked about in class.

Basic Digital Gates:

PLEASE HELP to Finish the code. Need to finish Half adder /

Diagram for Half-adder:

Full adder / Multiplexer. #include #include #include #include using namespace std; //

Diagram for Full adder:

Enumeration for the type of gate enum GATE_TYPE { NOT, AND, OR,

Diagram for Multiplexer 4 inputs to 1 output; and 2 selectors

NAND, NOR, HALF_ADDER, FULL_ADDER, MULTIPLEXER, EXIT }; // Function to implement the

Requirements

Create a function for each of the gate operations

Use an enumeration to specify the type of gates

The inputs are the truth values from the truth table

An input value is either 0 or 1. Value 0 implies false and value 1 implies true

Use "#include to format the output as rows and columns

To demonstrate, your program needs to test each gate operation and display the input/output table as above (half/full adder).

Hints:

- Start with the truth table

- enum GATE_TYPE { NOT, AND, OR, ...}

- You may use either array or vector to store the truth values.

output example(output is missing menu 3 and 8)

NOT gate int not_gate(int p) { return !p; } // Function to

EXCLUSIVE NOR EXCLUSIVE OR HALF-ADDER Innut/OutputTable FULL-ADDER Input/Output Table Enter choice:1 Not Gate p10p01 Enter Choice: 2 And Gate p1010q0110pq0010 Enter Choice: 4 Nand Gate p1010q0110(pq)1101 Enter Choice: 5 Nor Gate Enter Choice: 7 Full Adder p qrpqpq(pq)(pq)r c1vc2 Carryfinal 000111100110011010101010011110001000011100101101110100101010111101010101

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!