Add Queue as input for nand constructor
This commit is contained in:
parent
dfc6064bcd
commit
441fda70ce
@ -10,6 +10,7 @@ class gate {
|
||||
protected:
|
||||
wire *in1, *in2, *out;
|
||||
int delay;
|
||||
priority_queue<event> *e;
|
||||
};
|
||||
|
||||
#endif // !GATE
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -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
|
||||
|
@ -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();
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user