From 7bf89ece1559ae37ceffef23b72150205c88f0fe Mon Sep 17 00:00:00 2001 From: daniel Date: Sun, 23 Apr 2017 19:24:33 -0400 Subject: [PATCH] Fix the class names in simulation .cpp --- src/andGate.cpp | 31 ------------------------------- src/andGate.h | 15 --------------- src/event.cpp | 16 ---------------- src/event.h | 16 ---------------- src/gate.h | 19 ------------------- src/nandGate.cpp | 31 ------------------------------- src/nandGate.h | 16 ---------------- src/norGate.cpp | 32 -------------------------------- src/norGate.h | 15 --------------- src/notGate.cpp | 31 ------------------------------- src/notGate.h | 14 -------------- src/orGate.cpp | 32 -------------------------------- src/orGate.h | 15 --------------- src/wire.cpp | 39 --------------------------------------- src/wire.h | 30 ------------------------------ src/xnorGate.cpp | 34 ---------------------------------- src/xnorGate.h | 15 --------------- src/xorGate.cpp | 34 ---------------------------------- src/xorGate.h | 15 --------------- 19 files changed, 450 deletions(-) delete mode 100644 src/andGate.cpp delete mode 100644 src/andGate.h delete mode 100644 src/event.cpp delete mode 100644 src/event.h delete mode 100644 src/gate.h delete mode 100644 src/nandGate.cpp delete mode 100644 src/nandGate.h delete mode 100644 src/norGate.cpp delete mode 100644 src/norGate.h delete mode 100644 src/notGate.cpp delete mode 100644 src/notGate.h delete mode 100644 src/orGate.cpp delete mode 100644 src/orGate.h delete mode 100644 src/wire.cpp delete mode 100644 src/wire.h delete mode 100644 src/xnorGate.cpp delete mode 100644 src/xnorGate.h delete mode 100644 src/xorGate.cpp delete mode 100644 src/xorGate.h diff --git a/src/andGate.cpp b/src/andGate.cpp deleted file mode 100644 index 9ccaac8..0000000 --- a/src/andGate.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include "andGate.h" - -using namespace std; - -andGate::andGate(priority_queue *eQueue, int d, wire* wire1, wire* wire2, - wire* wire3) { - e = eQueue; - delay = d; - in1 = wire1; - in2 = wire2; - out = wire3; -} -int andGate::evaluate(int evTime) { - if (in1->getValue(evTime) == 0 || in2->getValue(evTime) == 0) { - if (out->getValue(evTime + delay) != 0) { - e->push(event(e->size, 0, evTime + delay, out)); - out->setValue(0, evTime + delay); - } - } - else if(in1->getValue(evTime) == 1 && in2->getValue(evTime) == 1){ - if (out->getValue(evTime + delay) != 1) { - e->push(event(e->size, 1, evTime + delay, out)); - out->setValue(1, evTime + delay); - } - } -} - -int andGate::getDelay() -{ - return delay; -} diff --git a/src/andGate.h b/src/andGate.h deleted file mode 100644 index 78e8470..0000000 --- a/src/andGate.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef AND -#define AND -#include "gate.h" -#include "event.h" -#include "wire.h" - -class andGate : public gate { - public: - andGate(priority_queue *eQueue, int d, wire* wire1, wire* wire2, - wire* wire3); - void evaluate(int evTime); - int getDelay(); -}; - -#endif // !AND diff --git a/src/event.cpp b/src/event.cpp deleted file mode 100644 index 4c840b5..0000000 --- a/src/event.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include "event.h" - -event::event(int num, int value, int setTime, wire * output){ - evNum = num; - evValue = value; - evTime = setTime; - out = output; -} - -bool operator<(const event &e1, const event &e2) { - if(e1.evTime == e2.evTime) { - return e1.evNum > e2.evNum; - } - return e1.evTime > e2.evTime; -} - diff --git a/src/event.h b/src/event.h deleted file mode 100644 index 48592d1..0000000 --- a/src/event.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef EVENT -#define EVENT - -using namespace std; -#include "wire.h" - -class event { - public: - event(int num, int value, int setTime, wire * output); - friend bool operator<(const event &e1, const event &e2); - private: - int evNum, evValue, evTime; - wire *out; -}; - -#endif // !EVENT diff --git a/src/gate.h b/src/gate.h deleted file mode 100644 index 3a42d45..0000000 --- a/src/gate.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef GATE -#define GATE - -#include "event.h" - -class wire; - -class gate { - public: - gate(); - virtual void evaluate(int) = 0; - - protected: - wire *in1, *in2, *out; - priority_queue *e; - int delay; -}; - -#endif // !GATE diff --git a/src/nandGate.cpp b/src/nandGate.cpp deleted file mode 100644 index d35ff35..0000000 --- a/src/nandGate.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include "nandGate.h" - -nandGate::nandGate(priority_queue *eQueue, int d, wire * wire1, wire * wire2, wire * wire3) -{ - in1 = wire1; - in2 = wire2; - out = wire3; - delay = d; - e = eQueue; -} - -void nandGate::evaluate(int evTime) -{ - if (in1->getValue(evTime) == 0 || in2->getValue(evTime) == 0) { - if (out->getValue(evTime + delay) != 1) { - e->push(event(e->size, 1, evTime + delay, out)); - out->setValue(1, evTime + delay); - } - } - else { - if (out->getValue(evTime + delay) != 0) { - e->push(event(e->size, 0, evTime + delay, out)); - out->setValue(0, evTime + delay); - } - } -} - -int nandGate::getDelay() -{ - return delay; -} diff --git a/src/nandGate.h b/src/nandGate.h deleted file mode 100644 index e1b8163..0000000 --- a/src/nandGate.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef NAND -#define NAND -#include "gate.h" -#include "event.h" -#include "wire.h" - -using namespace std; - -class nandGate : public gate { - public: - nandGate(priority_queue *eQueue, int d, wire* wire1, wire* wire2, wire* wire3); - void evaluate(int time); - int getDelay(); -}; - -#endif // !NAND diff --git a/src/norGate.cpp b/src/norGate.cpp deleted file mode 100644 index 934bcec..0000000 --- a/src/norGate.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include "norGate.h" - -using namespace std; - -norGate::norGate(priority_queue *eQueue, int d, wire* wire1, wire* wire2, - wire* wire3) { - e = eQueue; - delay = d; - in1 = wire1; - in2 = wire2; - out = wire3; -} - -void norGate::evaluate(int evTime) { - if (in1->getValue(evTime) == 1 || in2->getValue(evTime) == 1) { - if (out->getValue(evTime + delay) != 0) { - e->push(event(e->size, 0, evTime + delay, out)); - out->setValue(0, evTime + delay); - } - } - else if (in1->getValue(evTime) == 0 && in2->getValue(evTime) == 0) { - if (out->getValue(evTime + delay) != 1) { - e->push(event(e->size, 1, evTime + delay, out)); - out->setValue(1, evTime + delay); - } - } -} - -int norGate::getDelay() -{ - return delay; -} diff --git a/src/norGate.h b/src/norGate.h deleted file mode 100644 index e87a50a..0000000 --- a/src/norGate.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef NOR -#define NOR -#include "gate.h" -#include "event.h" -#include "wire.h" - -class norGate : public gate { - public: - norGate(priority_queue *eQueue, int d, wire* wire1, wire* wire2, - wire* wire3); - void evaluate(int evTime); - int getDelay(); -}; - -#endif // !NOR diff --git a/src/notGate.cpp b/src/notGate.cpp deleted file mode 100644 index 60c8787..0000000 --- a/src/notGate.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include "notGate.h" - -using namespace std; - -notGate::notGate(priority_queue *eQueue, int d, wire* wire1, wire* wire2) { - e = eQueue; - delay = d; - in1 = wire1; - out = wire2; - -} - -void notGate::evaluate(int evTime) { - if (in1->getValue(evTime) == 0) { - if (out->getValue(evTime + delay) != 0) { - e->push(event(e->size, 0, evTime + delay, out)); - out->setValue(0, evTime + delay); - } - } - else{ - if (out->getValue(evTime + delay) != 1) { - e->push(event(e->size, 1, evTime + delay, out)); - out->setValue(1, evTime + delay); - } - } -} - -int notGate::getDelay() -{ - return delay; -} diff --git a/src/notGate.h b/src/notGate.h deleted file mode 100644 index ac742f8..0000000 --- a/src/notGate.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef NOT -#define NOT -#include "gate.h" -#include "wire.h" -#include "event.h" - -class notGate : public gate { - public: - notGate(priority_queue *eQueue, int d, wire* wire1, wire* wire2); - void evaluate(int evTime); - int getDelay(); -}; - -#endif // !NOT diff --git a/src/orGate.cpp b/src/orGate.cpp deleted file mode 100644 index 9ba2f6d..0000000 --- a/src/orGate.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include "orGate.h" - -using namespace std; - -orGate::orGate(priority_queue *eQueue, int d, wire* wire1, wire* wire2, - wire* wire3) { - e = eQueue; - delay = d; - in1 = wire1; - in2 = wire2; - out = wire3; -} - -void orGate::evaluate(int evTime) { - if (in1->getValue(evTime) == 1 || in2->getValue(evTime) == 1) { - if (out->getValue(evTime + delay) != 1) { - e->push(event(e->size, 1, evTime + delay, out)); - out->setValue(1, evTime + delay); - } - } - else if (in1->getValue(evTime) == 0 && in2->getValue(evTime) == 0) { - if (out->getValue(evTime + delay) != 0) { - e->push(event(e->size, 0, evTime + delay, out)); - out->setValue(0, evTime + delay); - } - } -} - -int orGate::getDelay() -{ - return delay; -} diff --git a/src/orGate.h b/src/orGate.h deleted file mode 100644 index 0a9f9e5..0000000 --- a/src/orGate.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef OR -#define OR -#include "gate.h" -#include "event.h" -#include "wire.h" - -class orGate : public gate { - public: - orGate(priority_queue *eQueue, int d, wire* wire1, wire* wire2, - wire* wire3); - void evaluate(int evTime); - int getDelay(); -}; - -#endif // !OR diff --git a/src/wire.cpp b/src/wire.cpp deleted file mode 100644 index dec8a8d..0000000 --- a/src/wire.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#include "Wire.h" - -Wire::Wire(int number, bool io, string inName) -{ - WireNumber = number; - isPrint = io; - name = inName; - value = -1; - lastEvent = 0; - history.insert(history.begin(), 60, -1); -} - -int wire::getValue(int time) const -{ - for (auto i = history.begin() + time; i != history.begin(); i--) { - if (i[0] != -1) { - return i[0]; - } - } - return -1; -} - -void wire::setValue(int newValue, int setTime) -{ - history[setTime] = newValue; - if (lastEvent < setTime) { - lastEvent = setTime; - } -} - -int wire::getNumber() const -{ - return wireNumber; -} - -void wire::addGate(gate * newGate) -{ - gates.push_back(newGate); -} diff --git a/src/wire.h b/src/wire.h deleted file mode 100644 index 8e15386..0000000 --- a/src/wire.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef WIRE -#define WIRE - -#include -#include -#include - -using namespace std; - -class gate; - -class wire { - public: - wire(int number, bool io, string inName = ""); - - int getValue(int time) const; - void setValue(int newValue, int setTime); - - int getNumber() const; - void addGate(gate* newGate); - - private: - int wireNumber, value, lastEvent; - vector history; - string name; - bool isPrint; - vector gates; -}; - -#endif // !WIRE diff --git a/src/xnorGate.cpp b/src/xnorGate.cpp deleted file mode 100644 index 8d102ea..0000000 --- a/src/xnorGate.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#include "xnorGate.h" - -using namespace std; - -xnorGate::xnorGate(priority_queue *eQueue, int d, wire* wire1, - wire* wire2, wire* wire3) { - e = eQueue; - delay = d; - in1 = wire1; - in2 = wire2; - out = wire3; -} - -void xnorGate::evaluate(int evTime) { - if (in1->getValue(evTime) != -1 && in2->getValue(evTime) != -1) { - if (in1->getValue(evTime) == in2->getValue(evTime)) { - if (out->getValue(evTime + delay) != 1) { - e->push(event(e->size, 1, evTime + delay, out)); - out->setValue(1, evTime + delay); - } - } - else { - if (out->getValue(evTime + delay) != 0) { - e->push(event(e->size, 0, evTime + delay, out)); - out->setValue(0, evTime + delay); - } - } - } -} - -int xnorGate::getDelay() -{ - return delay; -} diff --git a/src/xnorGate.h b/src/xnorGate.h deleted file mode 100644 index 1b4ecda..0000000 --- a/src/xnorGate.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef XNOR -#define XNOR -#include "gate.h" -#include "event.h" -#include "wire.h" - -class xnorGate : public gate { - public: - xnorGate(priority_queue *eQueue, int d, wire* wire1, wire* wire2, - wire* wire3); - void evaluate(int evTime); - int getDelay(); -}; - -#endif // !XNOR diff --git a/src/xorGate.cpp b/src/xorGate.cpp deleted file mode 100644 index 74292bf..0000000 --- a/src/xorGate.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#include "xorGate.h" - -using namespace std; - -xorGate::xorGate(priority_queue *eQueue, int d, wire* wire1, - wire* wire2, wire* wire3) { - e = eQueue; - delay = d; - in1 = wire1; - in2 = wire2; - out = wire3; -} - -void xorGate::evaluate(int evTime) { - if (in1->getValue(evTime) != -1 && in2->getValue(evTime) != -1) { - if (in1->getValue(evTime) != in2->getValue(evTime)) { - if (out->getValue(evTime + delay) != 1) { - e->push(event(e->size, 1, evTime + delay, out)); - out->setValue(1, evTime + delay); - } - } - else { - if (out->getValue(evTime + delay) != 0) { - e->push(event(e->size, 0, evTime + delay, out)); - out->setValue(0, evTime + delay); - } - } - } -} - -int xorGate::getDelay() -{ - return delay; -} diff --git a/src/xorGate.h b/src/xorGate.h deleted file mode 100644 index eb593c4..0000000 --- a/src/xorGate.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef XOR -#define XOR -#include "gate.h" -#include "event.h" -#include "wire.h" - -class xorGate : public gate { - public: - xorGate(priority_queue *eQueue, int d, wire* wire1, wire* wire2, - wire* wire3); - void evaluate(int evTime); - int getDelay(); -}; - -#endif // !XOR