implement findWire() and clean up code
This commit is contained in:
parent
46fc86d36a
commit
0abbc7440e
@ -1,7 +1,6 @@
|
|||||||
# RADEC
|
# RADEC
|
||||||
|
|
||||||
# TODO
|
# TODO
|
||||||
* implement findWire() function
|
|
||||||
* implement vector file parsing
|
* implement vector file parsing
|
||||||
* develop pQueue class
|
* develop pQueue class
|
||||||
* define all classes more completely
|
* define all classes more completely
|
||||||
|
@ -0,0 +1,3 @@
|
|||||||
|
#include "notGate.h"
|
||||||
|
|
||||||
|
using namespace std;
|
1
src/pQueue.cpp
Normal file
1
src/pQueue.cpp
Normal file
@ -0,0 +1 @@
|
|||||||
|
#include "pQueue.h"
|
@ -8,6 +8,7 @@
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
int getDelay(string d);
|
int getDelay(string d);
|
||||||
|
bool parseCircuit(vector<gate*> &gates, vector<wire*> &wires, fileName);
|
||||||
wire* findWire(int n, vector<wire*> wires);
|
wire* findWire(int n, vector<wire*> wires);
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
@ -34,7 +35,7 @@ int main() {
|
|||||||
// 4. Print the results of the simulation
|
// 4. Print the results of the simulation
|
||||||
}
|
}
|
||||||
|
|
||||||
bool parseCircuit(gates, wires, fileName) {
|
bool parseCircuit(vector<gate*> &gates, vector<wire*> &wires, fileName) {
|
||||||
ifstream in;
|
ifstream in;
|
||||||
circuit.open(fileName + ".txt");
|
circuit.open(fileName + ".txt");
|
||||||
if(in.fail()) {
|
if(in.fail()) {
|
||||||
@ -61,7 +62,8 @@ bool parseCircuit(gates, wires, fileName) {
|
|||||||
wires.push_back(tmpWire);
|
wires.push_back(tmpWire);
|
||||||
}else if(tmpType == "NOT") {
|
}else if(tmpType == "NOT") {
|
||||||
tmp2 << in;
|
tmp2 << in;
|
||||||
tmpGate = new notGate(getDelay(tmpString), findWire(tmp1), findWire(tmp2));
|
tmpGate = new notGate(getDelay(tmpString), findWire(tmp1),
|
||||||
|
findWire(tmp2));
|
||||||
gates.push_back(tmpGate);
|
gates.push_back(tmpGate);
|
||||||
}else if(tmpType == "AND") {
|
}else if(tmpType == "AND") {
|
||||||
tmp2 << in;
|
tmp2 << in;
|
||||||
@ -72,8 +74,8 @@ bool parseCircuit(gates, wires, fileName) {
|
|||||||
}else if(tmpType == "NAND") {
|
}else if(tmpType == "NAND") {
|
||||||
tmp2 << in;
|
tmp2 << in;
|
||||||
tmp3 << in;
|
tmp3 << in;
|
||||||
tmpGate = new nandGate(getDelay(tmpString), findWire(tmp1), findWire(tmp2),
|
tmpGate = new nandGate(getDelay(tmpString), findWire(tmp1),
|
||||||
findWire(tmp3));
|
findWire(tmp2), findWire(tmp3));
|
||||||
gates.push_back(tmpGate);
|
gates.push_back(tmpGate);
|
||||||
}else if(tmpType == "OR") {
|
}else if(tmpType == "OR") {
|
||||||
tmp2 << in;
|
tmp2 << in;
|
||||||
@ -104,7 +106,10 @@ bool parseCircuit(gates, wires, fileName) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
wire* findWire(int n, vector<wire*> wires) {
|
wire* findWire(int n, vector<wire*> wires) {
|
||||||
//TODO
|
for(auto i = wires.begin(); i != wires.end(); ++i) {
|
||||||
|
if(n == *i) return i;
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getDelay(string d) {
|
int getDelay(string d) {
|
||||||
|
@ -14,6 +14,7 @@ class wire {
|
|||||||
int getState() const;
|
int getState() const;
|
||||||
void setState(bool newValue, int setTime);
|
void setState(bool newValue, int setTime);
|
||||||
|
|
||||||
|
int getNumber() const;
|
||||||
void addGate(gate* newGate);
|
void addGate(gate* newGate);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
Reference in New Issue
Block a user