mirror of
https://github.com/cmosher01/v6502cpp.git
synced 2024-12-27 18:30:52 +00:00
more WIP on new pointer-based data structure
This commit is contained in:
parent
a5f11856ba
commit
e8ae299597
10
Makefile
10
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
|
||||
|
@ -6,9 +6,9 @@
|
||||
*/
|
||||
|
||||
#include "SegmentCache.h"
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <algorithm>
|
||||
|
||||
Segment* SegmentCache::getOrAdd(std::string& id) {
|
||||
|
28
TransNetwork.cpp
Normal file
28
TransNetwork.cpp
Normal file
@ -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 <iostream>
|
||||
|
||||
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() {
|
||||
}
|
23
TransNetwork.h
Normal file
23
TransNetwork.h
Normal file
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* File: TransNetwork.h
|
||||
* Author: cmosher
|
||||
*
|
||||
* Created on December 11, 2013, 10:44 AM
|
||||
*/
|
||||
|
||||
#ifndef TRANSNETWORK_H
|
||||
#define TRANSNETWORK_H
|
||||
|
||||
#include <istream>
|
||||
|
||||
class TransNetwork {
|
||||
public:
|
||||
TransNetwork(std::istream& readFromHere);
|
||||
virtual ~TransNetwork();
|
||||
|
||||
private:
|
||||
TransNetwork(const TransNetwork&);
|
||||
TransNetwork& operator=(const TransNetwork&);
|
||||
};
|
||||
|
||||
#endif /* TRANSNETWORK_H */
|
10
trans.cpp
Normal file
10
trans.cpp
Normal file
@ -0,0 +1,10 @@
|
||||
/*
|
||||
* File: Trans.cpp
|
||||
* Author: cmosher
|
||||
*
|
||||
* Created on December 11, 2013, 10:44 AM
|
||||
*/
|
||||
|
||||
#include "trans.h"
|
||||
#include "SegmentCache.h"
|
||||
#include <istream>
|
15
trans.h
15
trans.h
@ -10,8 +10,10 @@
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
|
||||
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 */
|
||||
|
11
v6502.cpp
11
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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user