Add Queue as input for nand constructor

This commit is contained in:
daniel 2017-04-10 20:28:37 -04:00
parent dfc6064bcd
commit 441fda70ce
4 changed files with 15 additions and 9 deletions

View File

@ -10,6 +10,7 @@ class gate {
protected:
wire *in1, *in2, *out;
int delay;
priority_queue<event> *e;
};
#endif // !GATE

View File

@ -1,21 +1,23 @@
#include "nandGate.h"
nandGate::nandGate(int d, wire * wire1, wire * wire2, wire * wire3)
nandGate::nandGate(priority_queue<event> *eQueue, int d, wire * wire1, wire * wire2, wire * wire3)
{
in1 = wire1;
in2 = wire2;
out = wire3;
delay = d;
e = eQueue;
}
int nandGate::evaluate(int time)
void nandGate::evaluate(int time)
{
if (in1->getValue(time) == 0 || in2->getValue(time) == 0) {
if (out->getValue(time + delay) != 1) {
out->setValue(1, time + delay);
return 1;
}
else if{
}
else {
out->setValue(0, time + delay);
return 0;
}
}

View File

@ -8,8 +8,8 @@ using namespace std;
class nandGate : public gate {
public:
nandGate(int d, wire* wire1 = nullptr, wire* wire2 = nullptr, wire* wire3 = nullptr);
int evaluate(int time);
nandGate(priority_queue<event> *eQueue, int d, wire* wire1, wire* wire2, wire* wire3);
void evaluate(int time);
};
#endif // !NAND

View File

@ -1,7 +1,10 @@
#ifndef NOT
#define NOT
#include "gate.h"
#include "wire.h"
#include "event.h"
class not : public gate {
class notGate : public gate {
notGate(int delay, wire* wire1 = nullptr, wire* wire2 = nullptr);
int evaluate();
};