fix all gate classes and add pointer to priority queue

This commit is contained in:
Joel Beckmeyer 2017-04-10 20:44:44 -04:00
parent f365f0ab2b
commit 030cb65800
13 changed files with 77 additions and 31 deletions

View File

@ -2,8 +2,8 @@
using namespace std; using namespace std;
andGate::andGate(wire* wire1 = nullptr, wire* wire2 = nullptr, andGate::andGate(priority_queue<event> *eQueue, int d, wire* wire1, wire* wire2,
wire* wire3 = nullptr) : 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();

View File

@ -3,8 +3,8 @@
class andGate : public gate { class andGate : public gate {
public: public:
andGate(wire* wire1 = nullptr, wire* wire2 = nullptr, andGate(priority_queue<event> *eQueue, int d, wire* wire1, wire* wire2,
wire* wire3 = nullptr); wire* wire3);
int evaluate(int evTime); int evaluate(int evTime);
}; };

View File

@ -5,10 +5,11 @@ class wire;
class gate { class gate {
public: public:
gate(); gate();
virtual int evaluate() = 0; virtual void evaluate() = 0;
protected: protected:
wire *in1, *in2, *out; wire *in1, *in2, *out;
priority_queue<event> *e;
int delay; int delay;
}; };

View File

@ -0,0 +1,10 @@
#include "norGate.h"
using namespace std;
norGate::norGate(priority_queue<event> *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
}

View File

@ -1,9 +1,10 @@
#ifndef OR #ifndef NOR
#define OR #define NOR
class orGate : public gate { class norGate : public gate {
orGate(wire* wire1 = nullptr, wire* wire2 = nullptr, wire* wire3 = nullptr); norGate(priority_queue<event> *eQueue, int d, wire* wire1, wire* wire2,
int evaluate(); wire* wire3);
void evaluate(int evTime);
}; };
#endif // !OR #endif // !NOR

View File

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

View File

@ -2,8 +2,8 @@
#define NOT #define NOT
class not : public gate { class not : public gate {
notGate(int delay, wire* wire1 = nullptr, wire* wire2 = nullptr); notGate(priority_queue<event> *eQueue, int d, wire* wire1, wire* wire2);
int evaluate(); void evaluate(int evTime);
}; };
#endif // !NOT #endif // !NOT

View File

@ -0,0 +1,10 @@
#include "orGate.h"
using namespace std;
orGate::orGate(priority_queue<event> *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
}

View File

@ -2,8 +2,9 @@
#define OR #define OR
class orGate : public gate { class orGate : public gate {
orGate(wire* wire1 = nullptr, wire* wire2 = nullptr, wire* wire3 = nullptr); orGate(priority_queue<event> *eQueue, int d, wire* wire1, wire* wire2,
int evaluate(); wire* wire3);
void evaluate(int evTime);
}; };
#endif // !OR #endif // !OR

View File

@ -0,0 +1,11 @@
#include "xnorGate.h"
using namespace std;
xnorGate::xnorGate(priority_queue<event> *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
}

View File

@ -1,9 +1,10 @@
#ifndef OR #ifndef XNOR
#define OR #define XNOR
class orGate : public gate { class xnorGate : public gate {
orGate(wire* wire1 = nullptr, wire* wire2 = nullptr, wire* wire3 = nullptr); xnorGate(priority_queue<event> *eQueue, int d, wire* wire1, wire* wire2,
int evaluate(); wire* wire3);
void evaluate(int evTime);
}; };
#endif // !OR #endif // !XNOR

View File

@ -0,0 +1,11 @@
#include "xorGate.h"
using namespace std;
xorGate::xorGate(priority_queue<event> *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
}

View File

@ -1,9 +1,10 @@
#ifndef OR #ifndef XOR
#define OR #define XOR
class orGate : public gate { class xorGate : public gate {
orGate(wire* wire1 = nullptr, wire* wire2 = nullptr, wire* wire3 = nullptr); xorGate(priority_queue<event> *eQueue, int d, wire* wire1, wire* wire2,
int evaluate(); wire* wire3);
void evaluate(int evTime);
}; };
#endif // !OR #endif // !XOR