Merge branch 'master' of https://daniel12997@gitlab.com/AluminumTank/radec.git
This commit is contained in:
commit
2307a6b304
@ -6,18 +6,19 @@ bool Simulation::parseCircuit(string fileName)
|
||||
in.open(fileName + ".txt");
|
||||
if (in.fail()) {
|
||||
cerr << endl << fileName << ".txt could not be opened :(";
|
||||
exit(1);
|
||||
return false;
|
||||
}
|
||||
|
||||
string tmpString, tmpType;
|
||||
int tmp1, tmp2, tmp3;
|
||||
Wire *tmpWire;
|
||||
Gate *tmpGate;
|
||||
|
||||
// get rid of first line
|
||||
getline(in, tmpString);
|
||||
|
||||
while (!in.eof()) {
|
||||
in >> tmpType;
|
||||
|
||||
in >> tmpString;
|
||||
in >> tmp1;
|
||||
|
||||
@ -78,6 +79,37 @@ bool Simulation::parseCircuit(string fileName)
|
||||
gates.push_back(tmpGate);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool parseVector(string fileName) {
|
||||
ifstream in;
|
||||
in.open(fileName + "_v.txt");
|
||||
if (in.fail()) {
|
||||
cerr << endl << fileName << "_v.txt could not be opened :(";
|
||||
return false;
|
||||
}
|
||||
|
||||
string tmpString;
|
||||
int timeInt, valInt;
|
||||
|
||||
// get rid of first line
|
||||
getline(in, tmpString);
|
||||
|
||||
while(!in.eof()) {
|
||||
in >> tmpString;
|
||||
in >> tmpString;
|
||||
in >> timeInt;
|
||||
in >> valInt;
|
||||
|
||||
for(auto i = wires.begin(); i != wires.end(); ++i) {
|
||||
if(i->getName() == tmpString) {
|
||||
tmpWire = i;
|
||||
}
|
||||
}
|
||||
|
||||
e.push(Event(eventNum++, valInt, timeInt, tmpWire));
|
||||
}
|
||||
}
|
||||
|
||||
void Simulation::simulate()
|
||||
|
@ -1,16 +1,16 @@
|
||||
#ifndef SIMULATION
|
||||
#define SIMULATION
|
||||
|
||||
#include "wire.h"
|
||||
#include "event.h"
|
||||
#include "gate.h"
|
||||
#include "andGate.h"
|
||||
#include "nandGate.h"
|
||||
#include "orGate.h"
|
||||
#include "norGate.h"
|
||||
#include "xnorGate.h"
|
||||
#include "xorGate.h"
|
||||
#include "notGate.h"
|
||||
#include "Wire.h"
|
||||
#include "Event.h"
|
||||
#include "Gate.h"
|
||||
#include "AndGate.h"
|
||||
#include "NandGate.h"
|
||||
#include "OrGate.h"
|
||||
#include "NorGate.h"
|
||||
#include "XnorGate.h"
|
||||
#include "XorGate.h"
|
||||
#include "NotGate.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <fstream>
|
||||
@ -21,6 +21,7 @@ using namespace std;
|
||||
class Simulation {
|
||||
public:
|
||||
bool parseCircuit(string fileName);
|
||||
bool parseVector(string fileName);
|
||||
void simulate();
|
||||
void print();
|
||||
private:
|
||||
@ -30,6 +31,7 @@ class Simulation {
|
||||
priority_queue<Event> e;
|
||||
vector<Gate*> gates;
|
||||
vector<Wire*> wires;
|
||||
int eventNum;
|
||||
};
|
||||
|
||||
#endif // !SIMULATION
|
||||
|
Loading…
Reference in New Issue
Block a user