Question: I am not quite understanding how to do this problem the only parts needed are the student provides missing code in the SDL file. Please
I am not quite understanding how to do this problem the only parts needed are the student provides missing code in the SDL file. Please explain the solution, i really want to understand this! Answers are upvoted.
Problem
Create a circuit that compares the 4-bit, unsigned, binary integers A and B for equality (EQ) and not-equality (NE). Use the attached SDL file Problem28Part1.sdl and the attached driver program Problem28Part1.cpp.
SAMPLE OUTPUT
$-----------------------------------------------------------
$ Problem28Part1.sdl
$-----------------------------------------------------------
COMPONENTS
Student provides missing component definitions
ALIASES
A3 = IN#1
A2 = IN#2
A1 = IN#3
A0 = IN#4
B3 = IN#5
B2 = IN#6
B1 = IN#7
B0 = IN#8
EQ = OUT#1
NE = OUT#2
CONNECTIONS
Student provides missing connections
END
//----------------------------------------------------
// Problem28Part1.cpp
//----------------------------------------------------
#include
#include
#define ONSTRING "1"
#define OFFSTRING "0"
#define UNKSTRING "?"
#include "SDLS.h"
FILE *OUTFILE;
//----------------------------------------------------
int main()
//----------------------------------------------------
{
try
{
CIRCUIT circuit;
OUTFILE = fopen("Problem28Part1.out","w");
circuit.Load("Problem28Part1");
fprintf(OUTFILE," A B EQ NE ");
fprintf(OUTFILE,"---- ---- -- -- ");
printf(" A B EQ NE ");
printf("---- ---- -- -- ");
for (STATE A3 = OFF; A3 >= ON; A3 = Predecessor(A3))
for (STATE A2 = OFF; A2 >= ON; A2 = Predecessor(A2))
for (STATE A1 = OFF; A1 >= ON; A1 = Predecessor(A1))
for (STATE A0 = OFF; A0 >= ON; A0 = Predecessor(A0))
for (STATE B3 = OFF; B3 >= ON; B3 = Predecessor(B3))
for (STATE B2 = OFF; B2 >= ON; B2 = Predecessor(B2))
for (STATE B1 = OFF; B1 >= ON; B1 = Predecessor(B1))
for (STATE B0 = OFF; B0 >= ON; B0 = Predecessor(B0))
{
circuit.SetIN("A3",A3);
circuit.SetIN("A2",A2);
circuit.SetIN("A1",A1);
circuit.SetIN("A0",A0);
circuit.SetIN("B3",B3);
circuit.SetIN("B2",B2);
circuit.SetIN("B1",B1);
circuit.SetIN("B0",B0);
circuit.SimulateLogic();
fprintf(OUTFILE,"%1s%1s%1s%1s %1s%1s%1s%1s %1s %1s ",
StateString(A3),StateString(A2),StateString(A1),StateString(A0),
StateString(B3),StateString(B2),StateString(B1),StateString(B0),
StateString(circuit.GetOUT("EQ")),
StateString(circuit.GetOUT("NE")));
printf("%1s%1s%1s%1s %1s%1s%1s%1s %1s %1s ",
StateString(A3),StateString(A2),StateString(A1),StateString(A0),
StateString(B3),StateString(B2),StateString(B1),StateString(B0),
StateString(circuit.GetOUT("EQ")),
StateString(circuit.GetOUT("NE")));
}
}
catch (SDLSEXCEPTION &exception)
{
printf("Exception: %s ",exception.GetErrorMessage());
}
fclose(OUTFILE);
system("PAUSE");
return( 0 );
}
SDL.h LINK: file:///C:/Users/Martin/Documents/SDL.h
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
