From 7574ffc9a4e4a7587545c9d8442663ce14d0a5cf Mon Sep 17 00:00:00 2001 From: daniel Date: Mon, 10 Apr 2017 21:28:44 -0400 Subject: [PATCH] Fix base initialization for and, not , and xor --- src/andGate.cpp | 13 +++++++++---- src/notGate.cpp | 9 +++++++-- src/xorGate.cpp | 9 +++++++-- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/andGate.cpp b/src/andGate.cpp index f344b60..27deace 100644 --- a/src/andGate.cpp +++ b/src/andGate.cpp @@ -3,11 +3,16 @@ using namespace std; andGate::andGate(priority_queue *eQueue, int d, wire* wire1, wire* wire2, - wire* wire3) : e(eQueue), delay(d), in1(wire1), in2(wire2), out(wire3) {} - + wire* wire3) { + e = eQueue; + delay = d; + in1 = wire1; + in2 = wire2; + out = wire3; +} int andGate::evaluate(int evTime) { - int val1 = in1->getValue(); - int val2 = in2->getValue(); + int val1 = in1->getValue(evTime); + int val2 = in2->getValue(evTime); if(val1 != -1 && val2 != -1) { return val1 && val2; } diff --git a/src/notGate.cpp b/src/notGate.cpp index b7225d2..8634950 100644 --- a/src/notGate.cpp +++ b/src/notGate.cpp @@ -2,8 +2,13 @@ using namespace std; -notGate::notGate(priority_queue *eQueue, int d, wire* wire1, wire* wire2) - : e(eQueue), delay(gateDelay), in1(wire1), out(wire2) {} +notGate::notGate(priority_queue *eQueue, int d, wire* wire1, wire* wire2) { + e = eQueue; + delay = d; + in1 = wire1; + out = wire2; + +} void notGate::evaluate(int evTime) { int val = in1->getValue(); diff --git a/src/xorGate.cpp b/src/xorGate.cpp index 0243f7e..0d356b2 100644 --- a/src/xorGate.cpp +++ b/src/xorGate.cpp @@ -3,8 +3,13 @@ using namespace std; xorGate::xorGate(priority_queue *eQueue, int d, wire* wire1, - wire* wire2, wire* wire3) : e(eQueue), delay(d), in1(wire1), in2(wire2), - out(wire3); + wire* wire2, wire* wire3) { + e = eQueue; + delay = d; + in1 = wire1; + in2 = wire2; + out = wire3; +} void xorGate::evaluate(int evTime) { //TODO