fix all gate classes and add pointer to priority queue
This commit is contained in:
parent
f365f0ab2b
commit
030cb65800
@ -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();
|
||||||
|
@ -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);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -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;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -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
|
||||||
|
}
|
@ -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
|
||||||
|
@ -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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
}
|
@ -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
|
||||||
|
@ -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
|
||||||
|
}
|
@ -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
|
||||||
|
@ -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
|
||||||
|
}
|
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user