rename gate subclasses, add class declarations, and add skeleton

implementation of program
This commit is contained in:
Joel Beckmeyer 2017-04-06 13:28:20 -04:00
parent 372c6b6d87
commit 6aa93bddaa
10 changed files with 93 additions and 14 deletions

0
src/andGate.cpp Normal file
View File

10
src/andGate.h Normal file
View File

@ -0,0 +1,10 @@
#ifndef AND
#define AND
class andGate : public gate {
public:
andGate(wire* wire1 = nullptr, wire* wire2 = nullptr, wire* wire3 = nullptr);
int evaluate();
};
#endif // !AND

View File

@ -1,16 +1,15 @@
#ifndef GATE #ifndef GATE
#define GATE #define GATE
class wire;
class gate { class gate {
public: public:
gate(wire* wire1 = nullptr, wire* wire2 = nullptr, wire* wire3 = nullptr); gate();
virtual int getOutput() = 0; virtual int evaluate() = 0;
protected: protected:
wire* in1, in2, out; wire* in1, in2, out;
/* TODO int delay;
* delay
* type
*/
}; };
#endif // !GATE #endif // !GATE

0
src/notGate.cpp Normal file
View File

9
src/notGate.h Normal file
View File

@ -0,0 +1,9 @@
#ifndef NOT
#define NOT
class not : public gate {
notGate(wire* wire1 = nullptr, wire* wire2 = nullptr);
int evaluate();
};
#endif // !NOT

0
src/orGate.cpp Normal file
View File

9
src/orGate.h Normal file
View File

@ -0,0 +1,9 @@
#ifndef OR
#define OR
class orGate : public gate {
orGate(wire* wire1 = nullptr, wire* wire2 = nullptr, wire* wire3 = nullptr);
int evaluate();
};
#endif // !OR

8
src/pQueue.h Normal file
View File

@ -0,0 +1,8 @@
#ifndef pQUEUE
#define pQUEUE
class pQueue {
//TODO
};
#endif // !pQUEUE

33
src/radec.cpp Normal file
View File

@ -0,0 +1,33 @@
#include "wire.h"
#include "pQueue.h"
#include "orGate.h"
#include "andGate.h"
#include "notGate.h"
int main() {
// 1. Parse circuit file to create in-memory data structure of Gates and Wires
// to simulate
vector<gate*> gates;
vector<wire*> wires;
string fileName;
getline(cin, fileName);
bool parseSuccess = parseCircuit(gates, wires, fileName);
if(parseSuccess) {
// 2. Parse the vector file to initialize the simulation Queue with initial
// Wire state (i.e., value) changes
queue e;
parseSuccess = e.parseVector(fileName);
// 3. Simulate the circuit using Event-driven control
// first, remove the top Event e in the Queue
// second, determine if e causes a future Wire state change
// third, create and queue any future Wire state changes as new Events
// fourth, apply e's effects
// 4. Print the results of the simulation
}
bool parseCircuit(gates, wires) {
//TODO
}

View File

@ -1,15 +1,26 @@
#ifndef WIRE #ifndef WIRE
#define WIRE #define WIRE
#include <vector>
#include <queue>
#include <string>
class gate;
class wire { class wire {
/* TODO: public:
* data members: wire(int number, string name = "");
* state
* gate connections int getState() const;
* wire number void setState(bool newValue, int setTime);
* name
* is input/output void addGate(gate* newGate);
*/
private:
int wireNumber, value;
string name;
bool isInput;
vector<gate*> gates;
}; };
#endif // !WIRE #endif // !WIRE