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
7namespace openmsx {
8
9class Scheduler;
10class ClockPin;
11
13{
14public:
15 virtual void signal(ClockPin& pin, EmuTime::param time) = 0;
16 virtual void signalPosEdge(ClockPin& pin, EmuTime::param time) = 0;
17
18protected:
19 ~ClockPinListener() = default;
20};
21
22class ClockPin final : public Schedulable
23{
24public:
25 explicit ClockPin(Scheduler& scheduler, ClockPinListener* listener = nullptr);
26
27 // input side
28 void setState(bool status, EmuTime::param time);
30 EmuDuration::param hi, EmuTime::param time);
31
32 // output side
33 [[nodiscard]] bool getState(EmuTime::param time) const;
34 [[nodiscard]] bool isPeriodic() const { return periodic; }
35 [[nodiscard]] EmuDuration::param getTotalDuration() const;
36 [[nodiscard]] EmuDuration::param getHighDuration() const;
37 [[nodiscard]] unsigned getTicksBetween(EmuTime::param begin,
38 EmuTime::param end) const;
39
40 // control
41 void generateEdgeSignals(bool wanted, EmuTime::param time);
42
43 template<typename Archive>
44 void serialize(Archive& ar, unsigned version);
45
46private:
47 void unschedule();
48 void schedule(EmuTime::param time);
49 void executeUntil(EmuTime::param time) override;
50
51private:
52 ClockPinListener* const listener;
53
54 EmuDuration totalDur;
55 EmuDuration hiDur;
56 EmuTime referenceTime = EmuTime::zero();
57
58 bool periodic = false;
59 bool status = false;
60 bool signalEdge = false;
61};
62
63} // namespace openmsx
64
65#endif
virtual void signal(ClockPin &pin, EmuTime::param time)=0
virtual void signalPosEdge(ClockPin &pin, EmuTime::param time)=0
bool isPeriodic() const
Definition ClockPin.hh:34
unsigned getTicksBetween(EmuTime::param begin, EmuTime::param end) const
Definition ClockPin.cc:76
void generateEdgeSignals(bool wanted, EmuTime::param time)
Definition ClockPin.cc:94
void setState(bool status, EmuTime::param time)
Definition ClockPin.cc:13
void serialize(Archive &ar, unsigned version)
Definition ClockPin.cc:136
bool getState(EmuTime::param time) const
Definition ClockPin.cc:55
EmuDuration::param getHighDuration() const
Definition ClockPin.cc:70
void setPeriodicState(EmuDuration::param total, EmuDuration::param hi, EmuTime::param time)
Definition ClockPin.cc:33
EmuDuration::param getTotalDuration() const
Definition ClockPin.cc:64
Every class that wants to get scheduled at some point must inherit from this class.
This file implemented 3 utility functions:
Definition Autofire.cc:11
constexpr auto begin(const zstring_view &x)
constexpr auto end(const zstring_view &x)