I'm supposed to get this:
Testing the FullAdder class.
c_in a b c_out s
-----------+---------
0 0 0 | 0 0
0 0 1 | 0 1
0 1 0 | 0 1
0 1 1 | 1 0
1 0 0 | 0 1
1 0 1 | 1 0
1 1 0 | 1 0
1 1 1 | 1 1
But I'm getting:
Testing the FullAdder class.
c_in a b c_out s
-----------+---------
0 0 0 | -858993460 -858993460
0 0 1 | -858993460 -858993460
0 1 0 | -858993460 -858993460
0 1 1 | -858993460 -858993460
1 0 0 | -858993460 -858993460
1 0 1 | -858993460 -858993460
1 1 0 | -858993460 -858993460
1 1 1 | -858993460 -858993460
FullAdder.cpp (This is where is most likely coming from)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
#include "FullAdder.hpp"
FullAdder::FullAdder()
{
Init(0, 0, 0);
}
FullAdder::FullAdder(int pInputA, int pInputB, int pInputC)
{
Init(pInputA, pInputB, pInputC);
}
void FullAdder::Eval()
{
mXor1.SetInputA(mInputA);
mXor1.SetInputB(mInputB);
mXor2.SetInputA(mXor1.GetOutput());
mXor2.SetInputB(mInputC);
mAnd1.SetInputA(mXor1.GetOutput());
mAnd1.SetInputB(mInputC);
mAnd2.SetInputA(mInputA);
mAnd2.SetInputB(mInputB);
mOr.SetInputA(mAnd1.GetOutput());
mOr.SetInputB(mAnd2.GetOutput());
mOutputC = mOr.GetOutput();
mOutputS = mXor2.GetOutput();
}
int FullAdder::GetOutputC()
{
return mOutputC;
}
int FullAdder::GetOutputS()
{
return mOutputS;
}
void FullAdder::Init(int pInputA, int pInputB, int pInputC)
{
mInputA = pInputA;
mInputB = pInputB;
mInputC = pInputC;
}
void FullAdder::SetInputA(int pInputA)
{
mInputA = pInputA;
Eval();
}
void FullAdder::SetInputB(int pInputB)
{
mInputB = pInputB;
Eval();
}
void FullAdder::SetInputC(int pInputC)
{
mInputC = pInputC;
Eval();
}
|
Last edited on
What sets the values of FullAddr::mOutputC and FullAddr::mOutputS? You are seeing their uninitialized values.
Last edited on
So how do I fixed it? I need it fixed by Sunday.
Last edited on
You need to actually assign a value to mOutputC and mOutputS. Otherwise, you'll just get a random number.
Can you at least give me hints on how to do it?
How am I not doing it?
1 2
|
mOutputC = mOr.GetOutput();
mOutputS = mXor2.GetOutput();
|
I need to set mOutputC to the output from mOr and mOutputS to the output from mXor2.
Last edited on
I need it fixed by Sunday morning.
Last edited on