add trace of transistors

This commit is contained in:
Christopher Mosher 2013-12-16 21:51:12 -05:00
parent 735259becc
commit a4e04c3331
7 changed files with 44 additions and 4 deletions

View File

@ -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);

View File

@ -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() {

View File

@ -38,6 +38,10 @@ public:
return this->cache.end();
}
Map::size_type size() const {
return this->cache.size();
}
private:
Map cache;

View File

@ -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;
}

View File

@ -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;
};

View File

@ -22,12 +22,26 @@ public:
void add(Segment* c1, Segment* gate, Segment* c2);
typedef std::set<std::shared_ptr<Trans>> 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<std::shared_ptr<Trans>> cache;
Set cache;
};
#endif /* TRANSCACHE_H */

View File

@ -25,6 +25,7 @@ private:
public:
std::set<Trans*> gates;
std::set<Trans*> 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) {
}