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;
andGate::andGate(wire* wire1 = nullptr, wire* wire2 = nullptr,
wire* wire3 = nullptr) : in1(wire1), in2(wire2), out(wire3) {}
andGate::andGate(priority_queue<event> *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();

View File

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

View File

@ -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<event> *e;
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
#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<event> *eQueue, int d, wire* wire1, wire* wire2,
wire* wire3);
void evaluate(int evTime);
};
#endif // !OR
#endif // !NOR

View File

@ -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<event> *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;
}
}

View File

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