From 5d61e058b47d3e7034d3ec2160ce3368268ef866 Mon Sep 17 00:00:00 2001 From: daniel Date: Sun, 23 Apr 2017 19:29:29 -0400 Subject: [PATCH] Fix the gate evaluate definition to return event --- Radec/Radec/Radec.vcxproj | 40 +++++----- Radec/Radec/Radec.vcxproj.filters | 120 +++++++++++++++--------------- src/NandGate.h | 2 +- src/NorGate.h | 6 +- src/NotGate.h | 6 +- src/OrGate.h | 6 +- src/Simulation.cpp | 24 +++--- src/Simulation.h | 8 +- src/XnorGate.h | 6 +- src/XorGate.h | 6 +- 10 files changed, 112 insertions(+), 112 deletions(-) diff --git a/Radec/Radec/Radec.vcxproj b/Radec/Radec/Radec.vcxproj index 80164a7..1148403 100644 --- a/Radec/Radec/Radec.vcxproj +++ b/Radec/Radec/Radec.vcxproj @@ -146,31 +146,31 @@ - - - - - - - + + + + + + + - - - + + + - - - - - - - + + + + + + + - - - + + + diff --git a/Radec/Radec/Radec.vcxproj.filters b/Radec/Radec/Radec.vcxproj.filters index 9cbf4e1..9d1cfcc 100644 --- a/Radec/Radec/Radec.vcxproj.filters +++ b/Radec/Radec/Radec.vcxproj.filters @@ -21,77 +21,77 @@ - - Header Files - - - Header Files - - - Header Files - - - Header Files\Gates - - - Header Files\Gates - - - Header Files\Gates - - - Header Files\Gates - - - Header Files\Gates - - - Header Files\Gates - - - Header Files\Gates - Header Files + + Header Files\Gates + + + Header Files\Gates + + + Header Files\Gates + + + Header Files\Gates + + + Header Files\Gates + + + Header Files\Gates + + + Header Files\Gates + + + Header Files + + + Header Files + + + Header Files + - - Source Files - - - Source Files - - - Source Files\Gates - - - Source Files - - - Source Files\Gates - - - Source Files\Gates - - - Source Files\Gates - - - Source Files\Gates - - - Source Files\Gates - - - Source Files\Gates - Source Files Source Files + + Source Files\Gates + + + Source Files\Gates + + + Source Files\Gates + + + Source Files\Gates + + + Source Files\Gates + + + Source Files\Gates + + + Source Files\Gates + + + Source Files + + + Source Files + + + Source Files + diff --git a/src/NandGate.h b/src/NandGate.h index fbfd167..bda6fa4 100644 --- a/src/NandGate.h +++ b/src/NandGate.h @@ -9,7 +9,7 @@ using namespace std; class NandGate : public Gate { public: NandGate(int d, Wire* wire1, Wire* wire2, Wire* wire3); - void evaluate(int time); + Event evaluate(int time); int getDelay(); }; diff --git a/src/NorGate.h b/src/NorGate.h index ee0d430..c39d900 100644 --- a/src/NorGate.h +++ b/src/NorGate.h @@ -6,9 +6,9 @@ class NorGate : public Gate { public: - NorGate(int d, Wire* wire1, Wire* wire2, Wire* wire3); - void evaluate(int evTime); - int getDelay(); + NorGate(int d, Wire* wire1, Wire* wire2, Wire* wire3); + Event evaluate(int evTime); + int getDelay(); }; #endif // !NOR diff --git a/src/NotGate.h b/src/NotGate.h index f4ca66c..1721119 100644 --- a/src/NotGate.h +++ b/src/NotGate.h @@ -6,9 +6,9 @@ class NotGate : public Gate { public: - NotGate(int d, Wire* wire1, Wire* wire2); - void evaluate(int evTime); - int getDelay(); + NotGate(int d, Wire* wire1, Wire* wire2); + Event evaluate(int evTime); + int getDelay(); }; #endif // !NOT diff --git a/src/OrGate.h b/src/OrGate.h index 5eec0fc..514e8d3 100644 --- a/src/OrGate.h +++ b/src/OrGate.h @@ -6,9 +6,9 @@ class OrGate : public Gate { public: - OrGate(int d, Wire* wire1, Wire* wire2, Wire* wire3); - void evaluate(int evTime); - int getDelay(); + OrGate(int d, Wire* wire1, Wire* wire2, Wire* wire3); + Event evaluate(int evTime); + int getDelay(); }; #endif // !OR diff --git a/src/Simulation.cpp b/src/Simulation.cpp index 7fa3b42..a0e9c58 100644 --- a/src/Simulation.cpp +++ b/src/Simulation.cpp @@ -11,8 +11,8 @@ bool Simulation::parseCircuit(string fileName) string tmpString, tmpType; int tmp1, tmp2, tmp3; - wire *tmpWire; - gate *tmpGate; + Wire *tmpWire; + Gate *tmpGate; getline(in, tmpString); while (!in.eof()) { @@ -22,58 +22,58 @@ bool Simulation::parseCircuit(string fileName) in >> tmp1; if (tmpType == "INPUT") { - tmpWire = new wire(tmp1, true, tmpString); + tmpWire = new Wire(tmp1, true, tmpString); wires.push_back(tmpWire); } else if (tmpType == "OUTPUT") { - tmpWire = new wire(tmp1, false, tmpString); + tmpWire = new Wire(tmp1, false, tmpString); wires.push_back(tmpWire); } else if (tmpType == "NOT") { in >> tmp2; - tmpGate = new notGate(getDelay(tmpString), findWire(tmp1), + tmpGate = new NotGate(getDelay(tmpString), findWire(tmp1), findWire(tmp2)); gates.push_back(tmpGate); } else if (tmpType == "AND") { in >> tmp2; in >> tmp3; - tmpGate = new andGate(getDelay(tmpString), findWire(tmp1), findWire(tmp2), + tmpGate = new AndGate(getDelay(tmpString), findWire(tmp1), findWire(tmp2), findWire(tmp3)); gates.push_back(tmpGate); } else if (tmpType == "NAND") { in >> tmp2; in >> tmp3; - tmpGate = new nandGate(getDelay(tmpString), findWire(tmp1), + tmpGate = new NandGate(getDelay(tmpString), findWire(tmp1), findWire(tmp2), findWire(tmp3)); gates.push_back(tmpGate); } else if (tmpType == "OR") { in >> tmp2; in >> tmp3; - tmpGate = new orGate(getDelay(tmpString), findWire(tmp1), findWire(tmp2), + tmpGate = new OrGate(getDelay(tmpString), findWire(tmp1), findWire(tmp2), findWire(tmp3)); gates.push_back(tmpGate); } else if (tmpType == "XOR") { in >> tmp2; in >> tmp3; - tmpGate = new xorGate(getDelay(tmpString), findWire(tmp1), findWire(tmp2), + tmpGate = new XorGate(getDelay(tmpString), findWire(tmp1), findWire(tmp2), findWire(tmp3)); gates.push_back(tmpGate); } else if (tmpType == "NOR") { in >> tmp2; in >> tmp3; - tmpGate = new norGate(getDelay(tmpString), findWire(tmp1), findWire(tmp2), + tmpGate = new NorGate(getDelay(tmpString), findWire(tmp1), findWire(tmp2), findWire(tmp3)); gates.push_back(tmpGate); } else if (tmpType == "XNOR") { in >> tmp2; in >> tmp3; - tmpGate = new xnorGate(getDelay(tmpString), findWire(tmp1), findWire(tmp2), + tmpGate = new XnorGate(getDelay(tmpString), findWire(tmp1), findWire(tmp2), findWire(tmp3)); gates.push_back(tmpGate); } @@ -88,7 +88,7 @@ void Simulation::print() { } -wire * Simulation::findWire(int n) +Wire * Simulation::findWire(int n) { for (auto i = wires.begin(); i != wires.end(); ++i) { if (n == (**i).getNumber()) return *i; diff --git a/src/Simulation.h b/src/Simulation.h index 0ff5b5f..16bc64d 100644 --- a/src/Simulation.h +++ b/src/Simulation.h @@ -24,12 +24,12 @@ class Simulation { void simulate(); void print(); private: - wire* findWire(int n); + Wire* findWire(int n); int getDelay(string d); - priority_queue e; - vector gates; - vector wires; + priority_queue e; + vector gates; + vector wires; }; #endif // !SIMULATION diff --git a/src/XnorGate.h b/src/XnorGate.h index 2448b84..af2c438 100644 --- a/src/XnorGate.h +++ b/src/XnorGate.h @@ -6,9 +6,9 @@ class XnorGate : public Gate { public: - XnorGate(int d, Wire* wire1, Wire* wire2, Wire* wire3); - void evaluate(int evTime); - int getDelay(); + XnorGate(int d, Wire* wire1, Wire* wire2, Wire* wire3); + Event evaluate(int evTime); + int getDelay(); }; #endif // !XNOR diff --git a/src/XorGate.h b/src/XorGate.h index cadeef4..53da962 100644 --- a/src/XorGate.h +++ b/src/XorGate.h @@ -6,9 +6,9 @@ class XorGate : public Gate { public: - XorGate(int d, Wire* wire1, Wire* wire2, Wire* wire3); - void evaluate(int evTime); - int getDelay(); + XorGate(int d, Wire* wire1, Wire* wire2, Wire* wire3); + Event evaluate(int evTime); + int getDelay(); }; #endif // !XOR