From a4e04c33313807de92df89a8e0d62c013c33e0d2 Mon Sep 17 00:00:00 2001 From: Christopher Mosher Date: Mon, 16 Dec 2013 21:51:12 -0500 Subject: [PATCH] add trace of transistors --- Cpu6502.h | 4 ++++ Emu6502.h | 2 +- SegmentCache.h | 4 ++++ Trace.cpp | 14 ++++++++++++++ Trace.h | 5 ++++- TransCache.h | 16 +++++++++++++++- trans.h | 3 ++- 7 files changed, 44 insertions(+), 4 deletions(-) diff --git a/Cpu6502.h b/Cpu6502.h index cab9ddf..d5bd3f7 100644 --- a/Cpu6502.h +++ b/Cpu6502.h @@ -9,6 +9,7 @@ #define CPU6502_H #include "SegmentTypes.h" +#include "Trace.h" class AddressBus; class Trace; @@ -18,6 +19,9 @@ class Cpu6502 final { public: Cpu6502(AddressBus& addressBus, Trace& trace, Common& common) : addressBus(addressBus), trace(trace), common(common) { +#if 0 + trace.dumpTransistors(); +#endif } void setPins(const PinSettings& ps); diff --git a/Emu6502.h b/Emu6502.h index 2412cad..ab27c07 100644 --- a/Emu6502.h +++ b/Emu6502.h @@ -22,7 +22,7 @@ class AddressBus; class Emu6502 { public: - Emu6502(std::istream& transistors, AddressBus& mem) : tn(transistors, segs, transes), c(tn), trace(segs, c), cpu(mem, trace, c), cpuhelper(cpu, c) { + Emu6502(std::istream& transistors, AddressBus& mem) : tn(transistors, segs, transes), c(tn), trace(segs, transes, c), cpu(mem, trace, c), cpuhelper(cpu, c) { } virtual ~Emu6502() { diff --git a/SegmentCache.h b/SegmentCache.h index f0f8548..8a662cc 100644 --- a/SegmentCache.h +++ b/SegmentCache.h @@ -38,6 +38,10 @@ public: return this->cache.end(); } + Map::size_type size() const { + return this->cache.size(); + } + private: Map cache; diff --git a/Trace.cpp b/Trace.cpp index 54416f8..fd021ea 100644 --- a/Trace.cpp +++ b/Trace.cpp @@ -6,6 +6,7 @@ */ #include "Trace.h" +#include "TransCache.h" #include "SegmentCache.h" #include "Common.h" #include "trans.h" @@ -87,3 +88,16 @@ void Trace::dumpRegisters() const { std::cout << std::endl; } + +void Trace::dumpTransistors() const { + /* count depletion-mode MOSFETs */ + int cd(0); + for (auto sp : this->segs) { + Segment* seg = sp.second.get(); + if (seg->dmos) { + ++cd; + } + } + + std::cout << "eMOSFETs: " << this->transes.size() << ", dMOSFETs: " << cd << std::endl; +} diff --git a/Trace.h b/Trace.h index 5a72060..b543940 100644 --- a/Trace.h +++ b/Trace.h @@ -9,15 +9,17 @@ #define TRACE_H class SegmentCache; +class TransCache; class Common; class Trace final { public: - Trace(const SegmentCache& segs, const Common& common) : segs(segs), common(common) { + Trace(const SegmentCache& segs, const TransCache& transes, const Common& common) : segs(segs), transes(transes), common(common) { } void dumpSegments() const; + void dumpTransistors() const; void dumpRegisters() const; private: @@ -26,6 +28,7 @@ private: Trace& operator=(const Trace&) = delete; const SegmentCache& segs; + const TransCache& transes; const Common& common; }; diff --git a/TransCache.h b/TransCache.h index ac59144..f121399 100644 --- a/TransCache.h +++ b/TransCache.h @@ -22,12 +22,26 @@ public: void add(Segment* c1, Segment* gate, Segment* c2); + typedef std::set> Set; + + Set::const_iterator begin() const { + return this->cache.begin(); + } + + Set::const_iterator end() const { + return this->cache.end(); + } + + Set::size_type size() const { + return this->cache.size(); + } + private: TransCache(const TransCache&) = delete; TransCache& operator=(const TransCache&) = delete; - std::set> cache; + Set cache; }; #endif /* TRANSCACHE_H */ diff --git a/trans.h b/trans.h index efd12b9..12b3ff6 100644 --- a/trans.h +++ b/trans.h @@ -25,6 +25,7 @@ private: public: std::set gates; std::set c1c2s; + bool dmos; bool vss; bool vcc; @@ -33,7 +34,7 @@ public: - Segment(const std::string& id) : id(id), vss(false), vcc(false), pull(id[0]=='+' ? Pull::UP : Pull::FLOAT), on(false) { + Segment(const std::string& id) : id(id), dmos(id[0]=='+'), vss(false), vcc(false), pull(dmos ? Pull::UP : Pull::FLOAT), on(false) { }