Fix base initialization for and, not , and xor

This commit is contained in:
daniel 2017-04-10 21:28:44 -04:00
parent 2be1e257c3
commit 7574ffc9a4
3 changed files with 23 additions and 8 deletions

View File

@ -3,11 +3,16 @@
using namespace std; using namespace std;
andGate::andGate(priority_queue<event> *eQueue, int d, wire* wire1, wire* wire2, andGate::andGate(priority_queue<event> *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 andGate::evaluate(int evTime) {
int val1 = in1->getValue(); int val1 = in1->getValue(evTime);
int val2 = in2->getValue(); int val2 = in2->getValue(evTime);
if(val1 != -1 && val2 != -1) { if(val1 != -1 && val2 != -1) {
return val1 && val2; return val1 && val2;
} }

View File

@ -2,8 +2,13 @@
using namespace std; using namespace std;
notGate::notGate(priority_queue<event> *eQueue, int d, wire* wire1, wire* wire2) notGate::notGate(priority_queue<event> *eQueue, int d, wire* wire1, wire* wire2) {
: e(eQueue), delay(gateDelay), in1(wire1), out(wire2) {} e = eQueue;
delay = d;
in1 = wire1;
out = wire2;
}
void notGate::evaluate(int evTime) { void notGate::evaluate(int evTime) {
int val = in1->getValue(); int val = in1->getValue();

View File

@ -3,8 +3,13 @@
using namespace std; using namespace std;
xorGate::xorGate(priority_queue<event> *eQueue, int d, wire* wire1, xorGate::xorGate(priority_queue<event> *eQueue, int d, wire* wire1,
wire* wire2, wire* wire3) : e(eQueue), delay(d), in1(wire1), in2(wire2), wire* wire2, wire* wire3) {
out(wire3); e = eQueue;
delay = d;
in1 = wire1;
in2 = wire2;
out = wire3;
}
void xorGate::evaluate(int evTime) { void xorGate::evaluate(int evTime) {
//TODO //TODO