diff --git a/Makefile b/Makefile index c774034..08225bd 100644 --- a/Makefile +++ b/Makefile @@ -2,16 +2,20 @@ CXXFLAGS=-g -std=c++11 all: v6502 -v6502: v6502.o cpu.o nodes.o SegmentCache.o +v6502: v6502.o cpu.o nodes.o trans.o SegmentCache.o TransNetwork.o g++ $^ -o $@ -v6502.o: v6502.cpp cpu.h addressbus.h +v6502.o: v6502.cpp cpu.h addressbus.h TransNetwork.h cpu.o: cpu.cpp cpu.h addressbus.h nodes.h nodes.o: nodes.cpp nodes.h -SegmentCache.o : SegmentCache.cpp SegmentCache.h +trans.o: trans.cpp trans.h SegmentCache.h + +SegmentCache.o: SegmentCache.cpp SegmentCache.h + +TransNetwork.o: TransNetwork.cpp TransNetwork.h trans.h clean: -rm *.o diff --git a/SegmentCache.cpp b/SegmentCache.cpp index 4cff130..1a2bcad 100644 --- a/SegmentCache.cpp +++ b/SegmentCache.cpp @@ -6,9 +6,9 @@ */ #include "SegmentCache.h" +#include #include #include -#include #include Segment* SegmentCache::getOrAdd(std::string& id) { diff --git a/TransNetwork.cpp b/TransNetwork.cpp new file mode 100644 index 0000000..337e6c8 --- /dev/null +++ b/TransNetwork.cpp @@ -0,0 +1,28 @@ +/* + * File: TransNetwork.cpp + * Author: cmosher + * + * Created on December 11, 2013, 10:44 AM + */ + +#include "TransNetwork.h" +#include "trans.h" +#include "SegmentCache.h" +#include + +TransNetwork::TransNetwork(std::istream& readFromHere) { + SegmentCache segs; + + std::string c1, gate, c2; + readFromHere >> c1 >> gate >> c2; + while (readFromHere.good()) { + Trans trans(segs.getOrAdd(c1), segs.getOrAdd(gate), segs.getOrAdd(c2)); + std::cout << trans; + + readFromHere >> c1 >> gate >> c2; + } + std::cout << std::endl << "done" << std::endl; +} + +TransNetwork::~TransNetwork() { +} diff --git a/TransNetwork.h b/TransNetwork.h new file mode 100644 index 0000000..21f7ac3 --- /dev/null +++ b/TransNetwork.h @@ -0,0 +1,23 @@ +/* + * File: TransNetwork.h + * Author: cmosher + * + * Created on December 11, 2013, 10:44 AM + */ + +#ifndef TRANSNETWORK_H +#define TRANSNETWORK_H + +#include + +class TransNetwork { +public: + TransNetwork(std::istream& readFromHere); + virtual ~TransNetwork(); + +private: + TransNetwork(const TransNetwork&); + TransNetwork& operator=(const TransNetwork&); +}; + +#endif /* TRANSNETWORK_H */ diff --git a/cpu.cpp b/cpu.cpp index 2d7aeb0..0a10264 100644 --- a/cpu.cpp +++ b/cpu.cpp @@ -20,7 +20,6 @@ - #define TRACEREG 1 //#define TRACESEG 1 //#define TRACEMEM 1 diff --git a/trans.cpp b/trans.cpp new file mode 100644 index 0000000..ef07706 --- /dev/null +++ b/trans.cpp @@ -0,0 +1,10 @@ +/* + * File: Trans.cpp + * Author: cmosher + * + * Created on December 11, 2013, 10:44 AM + */ + +#include "trans.h" +#include "SegmentCache.h" +#include diff --git a/trans.h b/trans.h index 9e3f8c0..8d38152 100644 --- a/trans.h +++ b/trans.h @@ -10,8 +10,10 @@ #include #include +#include class Trans; +class SegmentCache; class Segment { public: @@ -28,12 +30,23 @@ public: }; class Trans { -public: +private: Segment* c1; Segment* gate; Segment* c2; bool on; + +public: + Trans(Segment* c1, Segment* gate, Segment* c2) : on(false), c1(c1), gate(gate), c2(c2) { + } + + virtual ~Trans() { + } + +private: + Trans(const Trans&); + Trans& operator=(const Trans&); }; #endif /* TRANS_H */ diff --git a/v6502.cpp b/v6502.cpp index 63705ce..e06f515 100644 --- a/v6502.cpp +++ b/v6502.cpp @@ -12,6 +12,8 @@ #include "addressbus.h" #include "cpu.h" +#include "TransNetwork.h" + //memory[0xFF] = 0x68; // PLA //memory[0xFF] = 0xFF; @@ -36,6 +38,15 @@ //} int main(int argc, char *argv[]) { + std::ifstream if_trans("transistors"); + if (!if_trans.is_open()) { + std::cerr << "error opening file: transistors" << std::endl; + exit(EXIT_FAILURE); + } + TransNetwork n(if_trans); +} + +int xxxmain(int argc, char *argv[]) { AddressBus mem; CPU cpu(mem);