Fixed some stuff

This commit is contained in:
daniel 2017-04-10 19:42:32 -04:00
parent 6741a85820
commit de3b3726c0
3 changed files with 33 additions and 6 deletions

View File

@ -11,3 +11,4 @@ bool event::operator<(const event &e1) {
} }
return evTime > e1.evTime; return evTime > e1.evTime;
} }

View File

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

View File

@ -1,10 +1,15 @@
#ifndef AND #ifndef NAND
#define AND #define NAND
#include "gate.h"
#include "event.h"
#include "wire.h"
class andGate : public gate { using namespace std;
class nandGate : public gate {
public: public:
andGate(wire* wire1 = nullptr, wire* wire2 = nullptr, wire* wire3 = nullptr); nandGate(int d, wire* wire1 = nullptr, wire* wire2 = nullptr, wire* wire3 = nullptr);
int evaluate(); int evaluate(int time);
}; };
#endif // !AND #endif // !NAND