v6502cpp/trans.h

66 lines
1.3 KiB
C
Raw Normal View History

2013-12-10 22:45:18 +00:00
/*
* File: trans.h
* Author: cmosher
*
* Created on December 10, 2013, 2:37 PM
*/
#ifndef TRANS_H
#define TRANS_H
#include <string>
2013-12-12 13:37:45 +00:00
#include <set>
2013-12-10 22:45:18 +00:00
class Trans;
class Segment {
public:
std::string id;
2013-12-12 13:37:45 +00:00
std::set<Trans*> gates;
std::set<Trans*> c1c2s;
2013-12-10 22:45:18 +00:00
bool pullup;
bool pulldown;
bool on;
2013-12-11 04:58:09 +00:00
2013-12-14 06:04:55 +00:00
bool vss;
bool vcc;
Segment(const std::string& id) : id(id), on(false), pulldown(false), pullup(id[0] == '+'), vss(false), vcc(false) {
2013-12-11 04:58:09 +00:00
}
2013-12-12 22:05:33 +00:00
void set(bool up) {
this->pullup = up;
this->pulldown = !up;
}
static unsigned char asByte(Segment* b7, Segment* b6, Segment* b5, Segment* b4, Segment* b3, Segment* b2, Segment* b1, Segment* b0);
static unsigned short asWord(Segment* b15, Segment* b14, Segment* b13, Segment* b12, Segment* b11, Segment* b10, Segment* b9, Segment* b8, Segment* b7, Segment* b6, Segment* b5, Segment* b4, Segment* b3, Segment* b2, Segment* b1, Segment* b0);
2013-12-10 22:45:18 +00:00
};
class Trans {
public:
2013-12-10 22:45:18 +00:00
Segment* c1;
Segment* gate;
Segment* c2;
bool on;
public:
2013-12-12 22:05:33 +00:00
Trans(Segment* c1, Segment* gate, Segment* c2) : on(false), c1(c1), gate(gate), c2(c2) {
2013-12-12 13:37:45 +00:00
c1->c1c2s.insert(this);
gate->gates.insert(this);
c2->c1c2s.insert(this);
}
virtual ~Trans() {
}
private:
Trans(const Trans&);
Trans& operator=(const Trans&);
2013-12-10 22:45:18 +00:00
};
#endif /* TRANS_H */