Add Queue as input for nand constructor
This commit is contained in:
parent
dfc6064bcd
commit
441fda70ce
@ -10,6 +10,7 @@ class gate {
|
|||||||
protected:
|
protected:
|
||||||
wire *in1, *in2, *out;
|
wire *in1, *in2, *out;
|
||||||
int delay;
|
int delay;
|
||||||
|
priority_queue<event> *e;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // !GATE
|
#endif // !GATE
|
||||||
|
@ -1,21 +1,23 @@
|
|||||||
#include "nandGate.h"
|
#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;
|
in1 = wire1;
|
||||||
in2 = wire2;
|
in2 = wire2;
|
||||||
out = wire3;
|
out = wire3;
|
||||||
delay = d;
|
delay = d;
|
||||||
|
e = eQueue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int nandGate::evaluate(int time)
|
void nandGate::evaluate(int time)
|
||||||
{
|
{
|
||||||
if (in1->getValue(time) == 0 || in2->getValue(time) == 0) {
|
if (in1->getValue(time) == 0 || in2->getValue(time) == 0) {
|
||||||
out->setValue(1, time + delay);
|
if (out->getValue(time + delay) != 1) {
|
||||||
return 1;
|
|
||||||
|
out->setValue(1, time + delay);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if{
|
else {
|
||||||
out->setValue(0, time + delay);
|
out->setValue(0, time + delay);
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -8,8 +8,8 @@ using namespace std;
|
|||||||
|
|
||||||
class nandGate : public gate {
|
class nandGate : public gate {
|
||||||
public:
|
public:
|
||||||
nandGate(int d, wire* wire1 = nullptr, wire* wire2 = nullptr, wire* wire3 = nullptr);
|
nandGate(priority_queue<event> *eQueue, int d, wire* wire1, wire* wire2, wire* wire3);
|
||||||
int evaluate(int time);
|
void evaluate(int time);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // !NAND
|
#endif // !NAND
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
#ifndef NOT
|
#ifndef NOT
|
||||||
#define 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);
|
notGate(int delay, wire* wire1 = nullptr, wire* wire2 = nullptr);
|
||||||
int evaluate();
|
int evaluate();
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user