Add Queue as input for nand constructor

This commit is contained in:
daniel 2017-04-10 20:28:37 -04:00
parent 030cb65800
commit 42037af8fa
4 changed files with 14 additions and 8 deletions

View File

@ -11,6 +11,7 @@ class gate {
wire *in1, *in2, *out;
priority_queue<event> *e;
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) {
out->setValue(1, time + delay);
return 1;
if (out->getValue(time + delay) != 1) {
out->setValue(1, time + delay);
}
}
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,5 +1,8 @@
#ifndef NOT
#define NOT
#include "gate.h"
#include "wire.h"
#include "event.h"
class not : public gate {
notGate(priority_queue<event> *eQueue, int d, wire* wire1, wire* wire2);