mirror of
https://github.com/cmosher01/v6502cpp.git
synced 2024-06-13 00:29:30 +00:00
done reading trans network
This commit is contained in:
parent
e8ae299597
commit
654d0510c8
3
Makefile
3
Makefile
|
@ -11,7 +11,7 @@ cpu.o: cpu.cpp cpu.h addressbus.h nodes.h
|
||||||
|
|
||||||
nodes.o: nodes.cpp nodes.h
|
nodes.o: nodes.cpp nodes.h
|
||||||
|
|
||||||
trans.o: trans.cpp trans.h SegmentCache.h
|
trans.o: trans.cpp trans.h
|
||||||
|
|
||||||
SegmentCache.o: SegmentCache.cpp SegmentCache.h
|
SegmentCache.o: SegmentCache.cpp SegmentCache.h
|
||||||
|
|
||||||
|
@ -20,3 +20,4 @@ TransNetwork.o: TransNetwork.cpp TransNetwork.h trans.h
|
||||||
clean:
|
clean:
|
||||||
-rm *.o
|
-rm *.o
|
||||||
-rm v6502
|
-rm v6502
|
||||||
|
-rm v6502.exe
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <algorithm>
|
|
||||||
|
|
||||||
Segment* SegmentCache::getOrAdd(std::string& id) {
|
Segment* SegmentCache::getOrAdd(std::string& id) {
|
||||||
if (this->cache.find(id) == this->cache.end()) {
|
if (this->cache.find(id) == this->cache.end()) {
|
||||||
|
|
|
@ -7,21 +7,16 @@
|
||||||
|
|
||||||
#include "TransNetwork.h"
|
#include "TransNetwork.h"
|
||||||
#include "trans.h"
|
#include "trans.h"
|
||||||
#include "SegmentCache.h"
|
#include <memory>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
TransNetwork::TransNetwork(std::istream& readFromHere) {
|
TransNetwork::TransNetwork(std::istream& in) {
|
||||||
SegmentCache segs;
|
|
||||||
|
|
||||||
std::string c1, gate, c2;
|
std::string c1, gate, c2;
|
||||||
readFromHere >> c1 >> gate >> c2;
|
in >> c1 >> gate >> c2;
|
||||||
while (readFromHere.good()) {
|
while (in.good()) {
|
||||||
Trans trans(segs.getOrAdd(c1), segs.getOrAdd(gate), segs.getOrAdd(c2));
|
this->transes.insert(std::make_shared<Trans>(this->segs.getOrAdd(c1), this->segs.getOrAdd(gate), this->segs.getOrAdd(c2)));
|
||||||
std::cout << trans;
|
in >> c1 >> gate >> c2;
|
||||||
|
|
||||||
readFromHere >> c1 >> gate >> c2;
|
|
||||||
}
|
}
|
||||||
std::cout << std::endl << "done" << std::endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TransNetwork::~TransNetwork() {
|
TransNetwork::~TransNetwork() {
|
||||||
|
|
|
@ -8,9 +8,15 @@
|
||||||
#ifndef TRANSNETWORK_H
|
#ifndef TRANSNETWORK_H
|
||||||
#define TRANSNETWORK_H
|
#define TRANSNETWORK_H
|
||||||
|
|
||||||
|
#include "trans.h"
|
||||||
|
#include "SegmentCache.h"
|
||||||
#include <istream>
|
#include <istream>
|
||||||
|
|
||||||
class TransNetwork {
|
class TransNetwork {
|
||||||
|
private:
|
||||||
|
SegmentCache segs;
|
||||||
|
std::set<std::shared_ptr<Trans>> transes;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TransNetwork(std::istream& readFromHere);
|
TransNetwork(std::istream& readFromHere);
|
||||||
virtual ~TransNetwork();
|
virtual ~TransNetwork();
|
||||||
|
|
14
cpu.cpp
14
cpu.cpp
|
@ -110,13 +110,13 @@ addressBus(addressBus) {
|
||||||
|
|
||||||
for (int i = 0; i != trns.size(); ++i) {
|
for (int i = 0; i != trns.size(); ++i) {
|
||||||
trn& t = trns[i];
|
trn& t = trns[i];
|
||||||
if (t.c1 == n->VSS) {
|
// if (t.c1 == n->VSS) {
|
||||||
t.c1 = t.c2;
|
// t.c1 = t.c2;
|
||||||
t.c2 = n->VSS;
|
// t.c2 = n->VSS;
|
||||||
} else if (t.c1 == n->VCC) {
|
// } else if (t.c1 == n->VCC) {
|
||||||
t.c1 = t.c2;
|
// t.c1 = t.c2;
|
||||||
t.c2 = n->VCC;
|
// t.c2 = n->VCC;
|
||||||
}
|
// }
|
||||||
segs[t.gate].gates.push_back(i);
|
segs[t.gate].gates.push_back(i);
|
||||||
segs[t.c1].c1c2s.push_back(i);
|
segs[t.c1].c1c2s.push_back(i);
|
||||||
segs[t.c2].c1c2s.push_back(i);
|
segs[t.c2].c1c2s.push_back(i);
|
||||||
|
|
|
@ -6,5 +6,3 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "trans.h"
|
#include "trans.h"
|
||||||
#include "SegmentCache.h"
|
|
||||||
#include <istream>
|
|
||||||
|
|
13
trans.h
13
trans.h
|
@ -9,23 +9,21 @@
|
||||||
#define TRANS_H
|
#define TRANS_H
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <set>
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
class Trans;
|
class Trans;
|
||||||
class SegmentCache;
|
|
||||||
|
|
||||||
class Segment {
|
class Segment {
|
||||||
public:
|
public:
|
||||||
std::string id;
|
std::string id;
|
||||||
std::vector<Trans*> gates;
|
std::set<Trans*> gates;
|
||||||
std::vector<Trans*> c1c2s;
|
std::set<Trans*> c1c2s;
|
||||||
|
|
||||||
bool pullup;
|
bool pullup;
|
||||||
bool pulldown;
|
bool pulldown;
|
||||||
bool on;
|
bool on;
|
||||||
|
|
||||||
Segment(std::string& id) : id(id) {
|
Segment(std::string& id) : id(id), on(false), pulldown(false), pullup(id[0] == '+') {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -39,6 +37,9 @@ private:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Trans(Segment* c1, Segment* gate, Segment* c2) : on(false), c1(c1), gate(gate), c2(c2) {
|
Trans(Segment* c1, Segment* gate, Segment* c2) : on(false), c1(c1), gate(gate), c2(c2) {
|
||||||
|
c1->c1c2s.insert(this);
|
||||||
|
gate->gates.insert(this);
|
||||||
|
c2->c1c2s.insert(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~Trans() {
|
virtual ~Trans() {
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
// }
|
// }
|
||||||
//}
|
//}
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int xxxmain(int argc, char *argv[]) {
|
||||||
std::ifstream if_trans("transistors");
|
std::ifstream if_trans("transistors");
|
||||||
if (!if_trans.is_open()) {
|
if (!if_trans.is_open()) {
|
||||||
std::cerr << "error opening file: transistors" << std::endl;
|
std::cerr << "error opening file: transistors" << std::endl;
|
||||||
|
@ -46,7 +46,7 @@ int main(int argc, char *argv[]) {
|
||||||
TransNetwork n(if_trans);
|
TransNetwork n(if_trans);
|
||||||
}
|
}
|
||||||
|
|
||||||
int xxxmain(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
AddressBus mem;
|
AddressBus mem;
|
||||||
CPU cpu(mem);
|
CPU cpu(mem);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user