openMSX
ClockPin.hh
Go to the documentation of this file.
1 #ifndef CLOCKPIN_HH
2 #define CLOCKPIN_HH
3 
4 #include "EmuTime.hh"
5 #include "Schedulable.hh"
6 
7 namespace openmsx {
8 
9 class Scheduler;
10 class ClockPin;
11 
13 {
14 public:
15  virtual void signal(ClockPin& pin, EmuTime::param time) = 0;
16  virtual void signalPosEdge(ClockPin& pin, EmuTime::param time) = 0;
17 protected:
18  virtual ~ClockPinListener() {}
19 };
20 
21 class ClockPin : public Schedulable
22 {
23 public:
24  explicit ClockPin(Scheduler& scheduler, ClockPinListener* listener = nullptr);
25 
26  // input side
27  void setState(bool status, EmuTime::param time);
30 
31  // output side
32  bool getState(EmuTime::param time) const;
33  bool isPeriodic() const;
37  EmuTime::param end) const;
38 
39  // control
40  void generateEdgeSignals(bool wanted, EmuTime::param time);
41 
42  template<typename Archive>
43  void serialize(Archive& ar, unsigned version);
44 
45 private:
46  void unschedule();
47  void schedule(EmuTime::param time);
48  virtual void executeUntil(EmuTime::param time, int userData);
49 
50  ClockPinListener* const listener;
51 
52  EmuDuration totalDur;
53  EmuDuration hiDur;
54  EmuTime referenceTime;
55 
56  bool periodic;
57  bool status;
58  bool signalEdge;
59 };
60 
61 } // namespace openmsx
62 
63 #endif
void setState(bool status, EmuTime::param time)
Definition: ClockPin.cc:16
void serialize(Archive &ar, unsigned version)
Definition: ClockPin.cc:144
bool isPeriodic() const
Definition: ClockPin.cc:67
virtual ~ClockPinListener()
Definition: ClockPin.hh:18
Every class that wants to get scheduled at some point must inherit from this class.
Definition: Schedulable.hh:16
virtual void signal(ClockPin &pin, EmuTime::param time)=0
EmuDuration::param getTotalDuration() const
Definition: ClockPin.cc:72
virtual void signalPosEdge(ClockPin &pin, EmuTime::param time)=0
ClockPin(Scheduler &scheduler, ClockPinListener *listener=nullptr)
Definition: ClockPin.cc:9
bool getState(EmuTime::param time) const
Definition: ClockPin.cc:58
void generateEdgeSignals(bool wanted, EmuTime::param time)
Definition: ClockPin.cc:102
int getTicksBetween(EmuTime::param begin, EmuTime::param end) const
Definition: ClockPin.cc:84
void setPeriodicState(EmuDuration::param total, EmuDuration::param hi, EmuTime::param time)
Definition: ClockPin.cc:36
EmuDuration::param getHighDuration() const
Definition: ClockPin.cc:78