rename gate subclasses, add class declarations, and add skeleton
implementation of program
This commit is contained in:
parent
372c6b6d87
commit
6aa93bddaa
0
src/andGate.cpp
Normal file
0
src/andGate.cpp
Normal file
10
src/andGate.h
Normal file
10
src/andGate.h
Normal 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
|
11
src/gate.h
11
src/gate.h
@ -1,16 +1,15 @@
|
||||
#ifndef GATE
|
||||
#define GATE
|
||||
class wire;
|
||||
|
||||
class gate {
|
||||
public:
|
||||
gate(wire* wire1 = nullptr, wire* wire2 = nullptr, wire* wire3 = nullptr);
|
||||
virtual int getOutput() = 0;
|
||||
gate();
|
||||
virtual int evaluate() = 0;
|
||||
|
||||
protected:
|
||||
wire* in1, in2, out;
|
||||
/* TODO
|
||||
* delay
|
||||
* type
|
||||
*/
|
||||
int delay;
|
||||
};
|
||||
|
||||
#endif // !GATE
|
||||
|
0
src/notGate.cpp
Normal file
0
src/notGate.cpp
Normal file
9
src/notGate.h
Normal file
9
src/notGate.h
Normal 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
0
src/orGate.cpp
Normal file
9
src/orGate.h
Normal file
9
src/orGate.h
Normal 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
8
src/pQueue.h
Normal file
@ -0,0 +1,8 @@
|
||||
#ifndef pQUEUE
|
||||
#define pQUEUE
|
||||
|
||||
class pQueue {
|
||||
//TODO
|
||||
};
|
||||
|
||||
#endif // !pQUEUE
|
33
src/radec.cpp
Normal file
33
src/radec.cpp
Normal 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
|
||||
}
|
27
src/wire.h
27
src/wire.h
@ -1,15 +1,26 @@
|
||||
#ifndef WIRE
|
||||
#define WIRE
|
||||
|
||||
#include <vector>
|
||||
#include <queue>
|
||||
#include <string>
|
||||
|
||||
class gate;
|
||||
|
||||
class wire {
|
||||
/* TODO:
|
||||
* data members:
|
||||
* state
|
||||
* gate connections
|
||||
* wire number
|
||||
* name
|
||||
* is input/output
|
||||
*/
|
||||
public:
|
||||
wire(int number, string name = "");
|
||||
|
||||
int getState() const;
|
||||
void setState(bool newValue, int setTime);
|
||||
|
||||
void addGate(gate* newGate);
|
||||
|
||||
private:
|
||||
int wireNumber, value;
|
||||
string name;
|
||||
bool isInput;
|
||||
vector<gate*> gates;
|
||||
};
|
||||
|
||||
#endif // !WIRE
|
||||
|
Loading…
Reference in New Issue
Block a user