This commit is contained in:
Joel Beckmeyer 2017-04-10 21:29:11 -04:00
commit 5229141506
10 changed files with 46 additions and 12 deletions

View File

@ -3,11 +3,16 @@
using namespace std;
andGate::andGate(priority_queue<event> *eQueue, int d, wire* wire1, wire* wire2,
wire* wire3) : e(eQueue), delay(d), in1(wire1), in2(wire2), out(wire3) {}
wire* wire3) {
e = eQueue;
delay = d;
in1 = wire1;
in2 = wire2;
out = wire3;
}
int andGate::evaluate(int evTime) {
int val1 = in1->getValue();
int val2 = in2->getValue();
int val1 = in1->getValue(evTime);
int val2 = in2->getValue(evTime);
if(val1 != -1 && val2 != -1) {
return val1 && val2;
}

View File

@ -1,5 +1,8 @@
#ifndef AND
#define AND
#include "gate.h"
#include "event.h"
#include "wire.h"
class andGate : public gate {
public:

View File

@ -1,7 +1,11 @@
#include "event.h"
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, wire * output){
evNum = num;
evValue = value;
evTime = setTime;
out = output;
}
bool event::operator<(const event &e1) {
if(evTime == e1.evTime) {

View File

@ -1,9 +1,9 @@
#ifndef EVENT
#define EVENT
using namespace std;
#include "wire.h"
class event {
public:
event(int num, int value, int setTime, wire * output);

View File

@ -1,5 +1,8 @@
#ifndef NOR
#define NOR
#include "gate.h"
#include "event.h"
#include "wire.h"
class norGate : public gate {
norGate(priority_queue<event> *eQueue, int d, wire* wire1, wire* wire2,

View File

@ -2,8 +2,13 @@
using namespace std;
notGate::notGate(priority_queue<event> *eQueue, int d, wire* wire1, wire* wire2)
: e(eQueue), delay(gateDelay), in1(wire1), out(wire2) {}
notGate::notGate(priority_queue<event> *eQueue, int d, wire* wire1, wire* wire2) {
e = eQueue;
delay = d;
in1 = wire1;
out = wire2;
}
void notGate::evaluate(int evTime) {
int val = in1->getValue();

View File

@ -1,7 +1,10 @@
#ifndef OR
#define OR
#include "gate.h"
#include "event.h"
#include "wire.h"
class xnorGate : public gate {
class orGate : public gate {
orGate(priority_queue<event> *eQueue, int d, wire* wire1, wire* wire2,
wire* wire3);
void evaluate(int evTime);

View File

@ -1,5 +1,8 @@
#ifndef XNOR
#define XNOR
#include "gate.h"
#include "event.h"
#include "wire.h"
class xnorGate : public gate {
xnorGate(priority_queue<event> *eQueue, int d, wire* wire1, wire* wire2,

View File

@ -3,8 +3,13 @@
using namespace std;
xorGate::xorGate(priority_queue<event> *eQueue, int d, wire* wire1,
wire* wire2, wire* wire3) : e(eQueue), delay(d), in1(wire1), in2(wire2),
out(wire3);
wire* wire2, wire* wire3) {
e = eQueue;
delay = d;
in1 = wire1;
in2 = wire2;
out = wire3;
}
void xorGate::evaluate(int evTime) {
//TODO

View File

@ -1,5 +1,8 @@
#ifndef XOR
#define XOR
#include "gate.h"
#include "event.h"
#include "wire.h"
class xorGate : public gate {
xorGate(priority_queue<event> *eQueue, int d, wire* wire1, wire* wire2,