Add the event generation to the nand Gate
This commit is contained in:
parent
441fda70ce
commit
c1c31af8e6
@ -1,9 +1,7 @@
|
|||||||
#include "event.h"
|
#include "event.h"
|
||||||
|
|
||||||
using namespace std;
|
event::event(int num, int value, int setTime, int wire, wire *output) : evNum(num), evValue(value),
|
||||||
|
evTime(setTime), out(output) {}
|
||||||
event::event(int num, int value, int setTime, int wire) : evNum(num), evValue(value),
|
|
||||||
evTime(setTime), wireNum(wire) {}
|
|
||||||
|
|
||||||
bool event::operator<(const event &e1) {
|
bool event::operator<(const event &e1) {
|
||||||
if(evTime == e1.evTime) {
|
if(evTime == e1.evTime) {
|
||||||
|
@ -1,13 +1,16 @@
|
|||||||
#ifndef EVENT
|
#ifndef EVENT
|
||||||
#define EVENT
|
#define EVENT
|
||||||
|
using namespace std;
|
||||||
|
#include "wire.h"
|
||||||
|
|
||||||
|
|
||||||
class event {
|
class event {
|
||||||
public:
|
public:
|
||||||
event(int num, int value, int setTime, int wire);
|
event(int num, int value, int setTime, wire * output);
|
||||||
bool operator<(const event &e1);
|
bool operator<(const event &e1);
|
||||||
private:
|
private:
|
||||||
int evNum, evValue, evTime, wireNum;
|
int evNum, evValue, evTime;
|
||||||
|
wire *out;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // !EVENT
|
#endif // !EVENT
|
||||||
|
@ -13,11 +13,12 @@ void nandGate::evaluate(int time)
|
|||||||
{
|
{
|
||||||
if (in1->getValue(time) == 0 || in2->getValue(time) == 0) {
|
if (in1->getValue(time) == 0 || in2->getValue(time) == 0) {
|
||||||
if (out->getValue(time + delay) != 1) {
|
if (out->getValue(time + delay) != 1) {
|
||||||
|
e->push(event(e->size, 1, time + delay, out));
|
||||||
out->setValue(1, time + delay);
|
out->setValue(1, time + delay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
e->push(event(e->size, 0, time + delay, out));
|
||||||
out->setValue(0, time + delay);
|
out->setValue(0, time + delay);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user