diff --git a/src/andGate.cpp b/src/andGate.cpp index 8451172..f344b60 100644 --- a/src/andGate.cpp +++ b/src/andGate.cpp @@ -2,8 +2,8 @@ using namespace std; -andGate::andGate(wire* wire1 = nullptr, wire* wire2 = nullptr, - wire* wire3 = nullptr) : in1(wire1), in2(wire2), out(wire3) {} +andGate::andGate(priority_queue *eQueue, int d, wire* wire1, wire* wire2, + wire* wire3) : e(eQueue), delay(d), in1(wire1), in2(wire2), out(wire3) {} int andGate::evaluate(int evTime) { int val1 = in1->getValue(); diff --git a/src/andGate.h b/src/andGate.h index 384360d..009bc11 100644 --- a/src/andGate.h +++ b/src/andGate.h @@ -3,8 +3,8 @@ class andGate : public gate { public: - andGate(wire* wire1 = nullptr, wire* wire2 = nullptr, - wire* wire3 = nullptr); + andGate(priority_queue *eQueue, int d, wire* wire1, wire* wire2, + wire* wire3); int evaluate(int evTime); }; diff --git a/src/gate.h b/src/gate.h index 557b4ee..e48e16f 100644 --- a/src/gate.h +++ b/src/gate.h @@ -5,10 +5,11 @@ class wire; class gate { public: gate(); - virtual int evaluate() = 0; + virtual void evaluate() = 0; protected: wire *in1, *in2, *out; + priority_queue *e; int delay; priority_queue *e; }; diff --git a/src/norGate.cpp b/src/norGate.cpp index e69de29..2b89207 100644 --- a/src/norGate.cpp +++ b/src/norGate.cpp @@ -0,0 +1,10 @@ +#include "norGate.h" + +using namespace std; + +norGate::norGate(priority_queue *eQueue, int d, wire* wire1, wire* wire2, + wire* wire3) : e(eQueue), delay(d), in1(wire1), in2(wire2), out(wire3); + +void norGate::evaluate(int evTime) { + //TODO +} diff --git a/src/norGate.h b/src/norGate.h index 178e872..8b17022 100644 --- a/src/norGate.h +++ b/src/norGate.h @@ -1,9 +1,10 @@ -#ifndef OR -#define OR +#ifndef NOR +#define NOR -class orGate : public gate { - orGate(wire* wire1 = nullptr, wire* wire2 = nullptr, wire* wire3 = nullptr); - int evaluate(); +class norGate : public gate { + norGate(priority_queue *eQueue, int d, wire* wire1, wire* wire2, + wire* wire3); + void evaluate(int evTime); }; -#endif // !OR +#endif // !NOR diff --git a/src/notGate.cpp b/src/notGate.cpp index 7215e46..b7225d2 100644 --- a/src/notGate.cpp +++ b/src/notGate.cpp @@ -2,13 +2,12 @@ using namespace std; -notGate::notGate(int gateDelay, wire* wire1 = nullptr, wire* wire2 = nullptr) - : delay(gateDelay), in1(wire1), out(wire2) {} +notGate::notGate(priority_queue *eQueue, int d, wire* wire1, wire* wire2) + : e(eQueue), delay(gateDelay), in1(wire1), out(wire2) {} -notGate::evaluate() { +void notGate::evaluate(int evTime) { int val = in1->getValue(); if(val != -1) { - return !val; } } diff --git a/src/notGate.h b/src/notGate.h index f0ad975..b60333c 100644 --- a/src/notGate.h +++ b/src/notGate.h @@ -4,9 +4,9 @@ #include "wire.h" #include "event.h" -class notGate : public gate { - notGate(int delay, wire* wire1 = nullptr, wire* wire2 = nullptr); - int evaluate(); +class not : public gate { + notGate(priority_queue *eQueue, int d, wire* wire1, wire* wire2); + void evaluate(int evTime); }; #endif // !NOT diff --git a/src/orGate.cpp b/src/orGate.cpp index e69de29..c682da9 100644 --- a/src/orGate.cpp +++ b/src/orGate.cpp @@ -0,0 +1,10 @@ +#include "orGate.h" + +using namespace std; + +orGate::orGate(priority_queue *eQueue, int d, wire* wire1, wire* wire2, + wire* wire3) : e(eQueue), delay(d), in1(wire1), in2(wire2), out(wire3); + +void orGate::evaluate(int evTime) { + //TODO +} diff --git a/src/orGate.h b/src/orGate.h index 178e872..b552410 100644 --- a/src/orGate.h +++ b/src/orGate.h @@ -2,8 +2,9 @@ #define OR class orGate : public gate { - orGate(wire* wire1 = nullptr, wire* wire2 = nullptr, wire* wire3 = nullptr); - int evaluate(); + orGate(priority_queue *eQueue, int d, wire* wire1, wire* wire2, + wire* wire3); + void evaluate(int evTime); }; #endif // !OR diff --git a/src/xnorGate.cpp b/src/xnorGate.cpp index e69de29..0a590c8 100644 --- a/src/xnorGate.cpp +++ b/src/xnorGate.cpp @@ -0,0 +1,11 @@ +#include "xnorGate.h" + +using namespace std; + +xnorGate::xnorGate(priority_queue *eQueue, int d, wire* wire1, + wire* wire2, wire* wire3) : e(eQueue), delay(d), in1(wire1), in2(wire2), + out(wire3); + +void xnorGate::evaluate(int evTime) { + //TODO +} diff --git a/src/xnorGate.h b/src/xnorGate.h index 178e872..ec0e344 100644 --- a/src/xnorGate.h +++ b/src/xnorGate.h @@ -1,9 +1,10 @@ -#ifndef OR -#define OR +#ifndef XNOR +#define XNOR -class orGate : public gate { - orGate(wire* wire1 = nullptr, wire* wire2 = nullptr, wire* wire3 = nullptr); - int evaluate(); +class xnorGate : public gate { + xnorGate(priority_queue *eQueue, int d, wire* wire1, wire* wire2, + wire* wire3); + void evaluate(int evTime); }; -#endif // !OR +#endif // !XNOR diff --git a/src/xorGate.cpp b/src/xorGate.cpp index e69de29..0243f7e 100644 --- a/src/xorGate.cpp +++ b/src/xorGate.cpp @@ -0,0 +1,11 @@ +#include "xorGate.h" + +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); + +void xorGate::evaluate(int evTime) { + //TODO +} diff --git a/src/xorGate.h b/src/xorGate.h index 178e872..2bb0c6f 100644 --- a/src/xorGate.h +++ b/src/xorGate.h @@ -1,9 +1,10 @@ -#ifndef OR -#define OR +#ifndef XOR +#define XOR -class orGate : public gate { - orGate(wire* wire1 = nullptr, wire* wire2 = nullptr, wire* wire3 = nullptr); - int evaluate(); +class xorGate : public gate { + xorGate(priority_queue *eQueue, int d, wire* wire1, wire* wire2, + wire* wire3); + void evaluate(int evTime); }; -#endif // !OR +#endif // !XOR