Add the event generation to the nand Gate

This commit is contained in:
daniel 2017-04-10 20:44:48 -04:00
parent 42037af8fa
commit 8aacd56b65
3 changed files with 9 additions and 7 deletions

View File

@ -1,9 +1,7 @@
#include "event.h"
using namespace std;
event::event(int num, int value, int setTime, int wire) : evNum(num), evValue(value),
evTime(setTime), wireNum(wire) {}
event::event(int num, int value, int setTime, int wire, wire *output) : evNum(num), evValue(value),
evTime(setTime), out(output) {}
bool event::operator<(const event &e1) {
if(evTime == e1.evTime) {

View File

@ -1,13 +1,16 @@
#ifndef EVENT
#define EVENT
using namespace std;
#include "wire.h"
class event {
public:
event(int num, int value, int setTime, int wire);
event(int num, int value, int setTime, wire * output);
bool operator<(const event &e1);
private:
int evNum, evValue, evTime, wireNum;
int evNum, evValue, evTime;
wire *out;
};
#endif // !EVENT

View File

@ -13,11 +13,12 @@ void nandGate::evaluate(int time)
{
if (in1->getValue(time) == 0 || in2->getValue(time) == 0) {
if (out->getValue(time + delay) != 1) {
e->push(event(e->size, 1, time + delay, out));
out->setValue(1, time + delay);
}
}
else {
e->push(event(e->size, 0, time + delay, out));
out->setValue(0, time + delay);
}
}