Question
I need guidance completing this milestone. It would help to get me started so finishing it completely is not necessary. This is a C# program
I need guidance completing this milestone. It would help to get me started so finishing it completely is not necessary. This is a C# program that should utilize linked lists (doesnt matter which). I have pasted the code for my gate logic header file and C# file below
**{{GATE FUNCTIONS C# FILE}}**
#define _CRT_SECURE_NO_WARNINGS
#include
#include
#include "gates.h"
void CIRCUIT1()
{
printf(" ");
printf(" A \t B \t | \t x ");
printf(" -------------------------- ");
for (int i = 0;i
{
for (int j = 0; j
{
printf(" %d \t %d \t | \t %d ", i, j, OR(AND(i, j), NAND(!i, !j)));
}
}
}
void CIRCUIT2()
{
printf(" ");
printf(" A \t B \t | \t x ");
printf(" -------------------------- ");
for (int i = 0; i
{
for (int j = 0; j
{
printf(" %d \t %d \t | \t %d ", i, j, OR(AND(!i, j), AND(!i, j)));
}
}
}
int NBITAND(int A[], int B[], int sizeA)
{
int falseCheck = 1;
for (int i = 0; i
{
if (A[i] == 0)
{
falseCheck = 0;
}
}
for (int j = 0; j
{
if (B[j] == 0)
{
falseCheck = 0;
}
}
return falseCheck;
}
int NBITOR(int A[], int B[],int sizeA)
{
int falseCheck = 0;
printf("size %d", sizeA);
for (int i = 0; i
{
if (A[i] == 1)
falseCheck = 1;
}
for (int j = 0; j
{
if (B[j] == 1)
falseCheck = 1;
}
return falseCheck;
}
int AND(int A, int B)
{
return(A && B);
}
void and() //Print AND Truth Table
{
printf("a \t b \t | \t x ");
printf("------------------------- ");
printf("0 \t 0 \t | \t 0 ");
printf("0 \t 1 \t | \t 0 ");
printf("1 \t 0 \t | \t 0 ");
printf("1 \t 1 \t | \t 1 ");
}
int NAND(int A, int B)
{
return(!(A&&B));
}
void nand()
{
printf("a \t b \t | \t x ");
printf("------------------------- ");
printf("0 \t 0 \t | \t 1 ");
printf("0 \t 1 \t | \t 1 ");
printf("1 \t 0 \t | \t 1 ");
printf("1 \t 1 \t | \t 0 ");
}
int OR(int A, int B)
{
return(A || B);
}
void or ()
{
printf("a \t b \t | \t x ");
printf("------------------------- ");
printf("0 \t 0 \t | \t 0 ");
printf("0 \t 1 \t | \t 1 ");
printf("1 \t 0 \t | \t 1 ");
printf("1 \t 1 \t | \t 1 ");
}
int NOR(int A, int B)
{
return(!(A || B));
}
void nor()
{
printf("a \t b \t | \t x ");
printf("------------------------- ");
printf("0 \t 0 \t | \t 1 ");
printf("0 \t 1 \t | \t 0 ");
printf("1 \t 0 \t | \t 0 ");
printf("1 \t 1 \t | \t 0 ");
}
int XOR(int A, int B)
{
return((A == B) ? 0 : 1);
}
void xor()
{
printf("a \t b \t | \t x ");
printf("------------------------- ");
printf("0 \t 0 \t | \t 0 ");
printf("0 \t 1 \t | \t 1 ");
printf("1 \t 0 \t | \t 1 ");
printf("1 \t 1 \t | \t 0 ");
}
int XNOR(int A, int B)
{
return((A == B) ? 1 : 0);
}
void xnor_print()
{
printf("a \t b \t | \t x ");
printf("------------------------- ");
printf("0 \t 0 \t | \t 1 ");
printf("0 \t 1 \t | \t 0 ");
printf("1 \t 0 \t | \t 0 ");
printf("1 \t 1 \t | \t 1 ");
}
void nota()
{
printf("a | x ");
printf("------------ ");
printf("0 | 1 ");
printf("1 | 0 ");
}
int NOT(int Input)
{
return(!Input);
}
void notb()
{
printf("b | x ");
printf("------------ ");
printf("0 | 1 ");
printf("1 | 0 ");
}
void MultiGate()
{
char userInput;
int X, Y;
while (1) // Infinite loop until user enters Q
{
printf(" Would you like to simulate circuit A or circuit B? Enter Q to exit. ");
scanf(" %c", &userInput);
if (userInput == 'q' || userInput == 'Q')
{
printf(" Exiting the program. ");
break; // breaks while loop
}
else
{
switch (userInput) //switch declaration
{
case 'A':
case 'a':
case 'B':
case 'b':
printf(" Enter 1 for true and 0 for false. ");
printf("A and B are the logical inputs for the gates. ");
while (1) //while loop that only allows 1 or 0 input
{
printf(" Enter true or false for A. ");
scanf(" %d", &X);
if (X == 1 || X == 0)
{
break;
}
else
{
printf(" Please only enter 1 or 0. ");
}
}
while (1) //Infinite loop to check if B is true or false
{
printf(" Is B true or false? ");
scanf(" %d", &Y);
if (Y == 1 || Y == 0)
{
break;
}
else
{
printf(" Please only enter 1 or 0. ");
}
}
break;
default:
printf(" Error. Try again ");
}
switch (userInput) //switch initialization to ask for which circuit to simulate
{
case 'A':
case 'a':
printf(" The result is: %d ", OR(AND(X, Y), NAND(NOT(X), NOT(Y))));
CIRCUIT1();
break;
case 'B':
case 'b':
printf(" The result is: %d ", OR(AND(NOT(X), Y), AND(NOT(Y), X)));
CIRCUIT1();
break;
default:
continue;
}
}
}
system("pause");
}
**{{GATE LOGIC LIBRARY}}**
int AND(int A, int B); void and();
int NBITAND(int A[], int B[],int sizeA); int NBITOR(int A[], int B[],int sizeA);
int NOT(int Input); void notb(); void nota();
int NAND(int A, int B); void nand();
int OR(int A, int B); void or ();
int NOR(int A, int B); void nor();
int XOR(int A, int B); void xor();
int XNOR(int A, int B); void xnor_print();
void CIRCUIT1(); void CIRCUIT2();
void MultiGate();
o-assignment-1 - ECE-321L-001-Intro to Software Engr Lab circuits. You may need to declare additional variables in order to separate the bits of the signals and calculate the output 2.3 Milestone 3: Generic description of the circuit-DEMONSTRATION: Wednes- The goal of this milestone is to enhance the simulator and the library that you created in Milestone day April 18h 1 in order to handle complex circuits that are described in a separate file. In this Milestone, we ill consider only circuits with a single output composed of AND, OR, XOR and NOT gates. Each gate has at most two inputs, but it can have many outputs. Circuit inputs and outputs will be treated like gates. We will use a file to describe the topology of the circuit. The first line (line 0) contains the number of gates n in the circuit. This number includes the inputs and the single output of the circuit. Each next line is used to describe the properties of each gate. The remaining lines contain information for one circuit input, logic gate, or circuit output as described below. All gates are identified by their line number in the file. Each line consists of the following fields: . Field 0: the index i of the gate, followed by a colon. . Field 1: the letter A', O', X','N, 'I', or 02'. This designates the gate as an AND gate, an OR gate, an XOR gate, a NOT gate, a circuit input, or a circuit output, respectively . Field 2: two gate indices. These represent the two gates that are directly wired as inputs to gate i. We use the value 0 to denote gate inputs that are not used. For example, AND, OR and XOR gates always use both gate inputs, NOT gates uses only one gate input; circuit inputs do not use any gate inputs; circuit output use only one gate input. You should consider that the circuit is topologically ordered (a gate cannot use a signal that has not appeared in the file before it). Once the simulator has read in the circuit description, it asks the user to enter a value (0 or 1) for each of the circuit inputs In order to calculate the output, you have to create a linked list (e.g. FIFO, stack, double linked list) that contains the gates. For each gate in the list you should calculate the output value based on the values of the previous nodes. An example of a file and the corresponding circuit is given below 1: I00 2: I 0 0 3: N2 0 4: A 1 3 5: O 1 4 6: X5 3 7: 6 0 o-assignment-1 - ECE-321L-001-Intro to Software Engr Lab circuits. You may need to declare additional variables in order to separate the bits of the signals and calculate the output 2.3 Milestone 3: Generic description of the circuit-DEMONSTRATION: Wednes- The goal of this milestone is to enhance the simulator and the library that you created in Milestone day April 18h 1 in order to handle complex circuits that are described in a separate file. In this Milestone, we ill consider only circuits with a single output composed of AND, OR, XOR and NOT gates. Each gate has at most two inputs, but it can have many outputs. Circuit inputs and outputs will be treated like gates. We will use a file to describe the topology of the circuit. The first line (line 0) contains the number of gates n in the circuit. This number includes the inputs and the single output of the circuit. Each next line is used to describe the properties of each gate. The remaining lines contain information for one circuit input, logic gate, or circuit output as described below. All gates are identified by their line number in the file. Each line consists of the following fields: . Field 0: the index i of the gate, followed by a colon. . Field 1: the letter A', O', X','N, 'I', or 02'. This designates the gate as an AND gate, an OR gate, an XOR gate, a NOT gate, a circuit input, or a circuit output, respectively . Field 2: two gate indices. These represent the two gates that are directly wired as inputs to gate i. We use the value 0 to denote gate inputs that are not used. For example, AND, OR and XOR gates always use both gate inputs, NOT gates uses only one gate input; circuit inputs do not use any gate inputs; circuit output use only one gate input. You should consider that the circuit is topologically ordered (a gate cannot use a signal that has not appeared in the file before it). Once the simulator has read in the circuit description, it asks the user to enter a value (0 or 1) for each of the circuit inputs In order to calculate the output, you have to create a linked list (e.g. FIFO, stack, double linked list) that contains the gates. For each gate in the list you should calculate the output value based on the values of the previous nodes. An example of a file and the corresponding circuit is given below 1: I00 2: I 0 0 3: N2 0 4: A 1 3 5: O 1 4 6: X5 3 7: 6 0Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started