diff --git a/Circuit.cpp b/Circuit.cpp index 497bb09..e264748 100644 --- a/Circuit.cpp +++ b/Circuit.cpp @@ -64,10 +64,10 @@ bool Circuit::getValue() { } /* otherwise, this test: */ for (auto s : this->segs) { - if (s->pullup) { + if (s->pull == Pull::UP) { return true; } - if (s->pulldown) { + if (s->pull == Pull::DOWN) { return false; } if (s->on) { diff --git a/Cpu6502.cpp b/Cpu6502.cpp index b8c29d6..cc70829 100644 --- a/Cpu6502.cpp +++ b/Cpu6502.cpp @@ -18,7 +18,7 @@ #define TRACEREG 1 -//#define TRACESEG 1 +#define TRACESEG 1 diff --git a/Makefile b/Makefile index 3c0dd80..1f594e0 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,7 @@ v6502: $(OBJS) clean: - -rm -f v6502 v6502.exe $(OBJS) $(DEPS) + -rm -Rf v6502 v6502.exe $(OBJS) $(DEPS) doxygen diff --git a/Trace.cpp b/Trace.cpp index d78d58a..263186a 100644 --- a/Trace.cpp +++ b/Trace.cpp @@ -27,10 +27,9 @@ static void pHexw(const unsigned short x) { void Trace::dumpSegments() const { for (auto sp : this->s) { Segment* seg = sp.second.get(); - assert(!(seg->pullup && seg->pulldown)); - if (seg->pullup) { + if (seg->pull == Pull::UP) { std::cout << (seg->on ? "U" : "u"); - } else if (seg->pulldown) { + } else if (seg->pull == Pull::DOWN) { std::cout << (seg->on ? "D" : "d"); } else { std::cout << (seg->on ? "F" : "f"); diff --git a/trans.h b/trans.h index 893a79a..4d7c896 100644 --- a/trans.h +++ b/trans.h @@ -8,33 +8,46 @@ #ifndef TRANS_H #define TRANS_H -#include -#include #include "ptr_less.h" +#include +#include + + class Trans; +enum class Pull { UP, DOWN, FLOAT }; + class Segment { public: - std::string id; + + const std::string id; std::set gates; std::set c1c2s; - - bool on; - bool pulldown; - bool pullup; - bool vss; bool vcc; - Segment(const std::string& id) : id(id), on(false), pulldown(false), pullup(id[0] == '+'), vss(false), vcc(false) { + Pull pull; + bool on; + + + + Segment(const std::string& id) : id(id), vss(false), vcc(false), pull(id[0]=='+' ? Pull::UP : Pull::FLOAT), on(false) { } - void set(bool up) { - this->pullup = up; - this->pulldown = !up; + virtual ~Segment() { } + + + void set(const bool up) { + this->pull = (up ? Pull::UP : Pull::DOWN); + } + + bool operator<(const Segment& that) { return this->id < that.id; } + + + static unsigned char asByte(Segment* b7, Segment* b6, Segment* b5, Segment* b4, Segment* b3, Segment* b2, Segment* b1, Segment* b0) { return b7->on << 0x7 | b6->on << 0x6 | b5->on << 0x5 | b4->on << 0x4 | b3->on << 0x3 | b2->on << 0x2 | b1->on << 0x1 | b0->on; } @@ -43,22 +56,30 @@ public: return bf->on << 0xf | be->on << 0xe | bd->on << 0xd | bc->on << 0xc | bb->on << 0xb | ba->on << 0xa | b9->on << 0x9 | b8->on << 0x8 | b7->on << 0x7 | b6->on << 0x6 | b5->on << 0x5 | b4->on << 0x4 | b3->on << 0x3 | b2->on << 0x2 | b1->on << 0x1 | b0->on; } - bool operator<(const Segment& that) { return this->id < that.id; } +private: + + Segment(const Segment&) = delete; + Segment& operator=(const Segment&) = delete; }; typedef std::set> setpSeg; + + + + + class Trans { public: + Segment* c1; - Segment* gate; Segment* c2; bool on; -public: - Trans(Segment* c1, Segment* gate, Segment* c2) : c1(c1), gate(gate), c2(c2), on(false) { + + Trans(Segment* c1, Segment* gate, Segment* c2) : c1(c1), c2(c2), on(false) { c1->c1c2s.insert(this); gate->gates.insert(this); c2->c1c2s.insert(this); @@ -68,8 +89,9 @@ public: } private: - Trans(const Trans&); - Trans& operator=(const Trans&); + + Trans(const Trans&) = delete; + Trans& operator=(const Trans&) = delete; }; #endif /* TRANS_H */