mirror of
https://github.com/TomHarte/CLK.git
synced 2024-10-18 23:23:56 +00:00
Attempted to fix implementation of divide
, and marked everything as-yet unmarked as inline
.
This commit is contained in:
parent
40339a12e1
commit
cfbd62a5dc
@ -11,8 +11,8 @@
|
|||||||
|
|
||||||
template <class T> class WrappedInt {
|
template <class T> class WrappedInt {
|
||||||
public:
|
public:
|
||||||
WrappedInt(int l) : length_(l) {}
|
inline WrappedInt(int l) : length_(l) {}
|
||||||
WrappedInt() : length_(0) {}
|
inline WrappedInt() : length_(0) {}
|
||||||
|
|
||||||
inline T &operator =(const T &rhs) {
|
inline T &operator =(const T &rhs) {
|
||||||
length_ = rhs.length_;
|
length_ = rhs.length_;
|
||||||
@ -69,8 +69,8 @@ template <class T> class WrappedInt {
|
|||||||
|
|
||||||
inline int as_int() const { return length_; }
|
inline int as_int() const { return length_; }
|
||||||
inline T divide(const T &divisor) {
|
inline T divide(const T &divisor) {
|
||||||
T result(length_ / divisor);
|
T result(length_ / divisor.length_);
|
||||||
length_ %= divisor;
|
length_ %= divisor.length_;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,19 +84,19 @@ template <class T> class WrappedInt {
|
|||||||
/*! Describes an integer number of whole cycles — pairs of clock signal transitions. */
|
/*! Describes an integer number of whole cycles — pairs of clock signal transitions. */
|
||||||
class Cycles: public WrappedInt<Cycles> {
|
class Cycles: public WrappedInt<Cycles> {
|
||||||
public:
|
public:
|
||||||
Cycles(int l) : WrappedInt<Cycles>(l) {}
|
inline Cycles(int l) : WrappedInt<Cycles>(l) {}
|
||||||
Cycles() : WrappedInt<Cycles>() {}
|
inline Cycles() : WrappedInt<Cycles>() {}
|
||||||
Cycles(const Cycles &cycles) : WrappedInt<Cycles>(cycles.length_) {}
|
inline Cycles(const Cycles &cycles) : WrappedInt<Cycles>(cycles.length_) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
/*! Describes an integer number of half cycles — single clock signal transitions. */
|
/*! Describes an integer number of half cycles — single clock signal transitions. */
|
||||||
class HalfCycles: public WrappedInt<HalfCycles> {
|
class HalfCycles: public WrappedInt<HalfCycles> {
|
||||||
public:
|
public:
|
||||||
HalfCycles(int l) : WrappedInt<HalfCycles>(l) {}
|
inline HalfCycles(int l) : WrappedInt<HalfCycles>(l) {}
|
||||||
HalfCycles() : WrappedInt<HalfCycles>() {}
|
inline HalfCycles() : WrappedInt<HalfCycles>() {}
|
||||||
|
|
||||||
HalfCycles(const Cycles &cycles) : WrappedInt<HalfCycles>(cycles.as_int() << 1) {}
|
inline HalfCycles(const Cycles &cycles) : WrappedInt<HalfCycles>(cycles.as_int() << 1) {}
|
||||||
HalfCycles(const HalfCycles &half_cycles) : WrappedInt<HalfCycles>(half_cycles.length_) {}
|
inline HalfCycles(const HalfCycles &half_cycles) : WrappedInt<HalfCycles>(half_cycles.length_) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -107,11 +107,11 @@ class HalfCycles: public WrappedInt<HalfCycles> {
|
|||||||
*/
|
*/
|
||||||
template <class T> class ClockReceiver {
|
template <class T> class ClockReceiver {
|
||||||
public:
|
public:
|
||||||
void run_for(const Cycles &cycles) {
|
inline void run_for(const Cycles &cycles) {
|
||||||
static_cast<T *>(this)->run_for(HalfCycles(cycles));
|
static_cast<T *>(this)->run_for(HalfCycles(cycles));
|
||||||
}
|
}
|
||||||
|
|
||||||
void run_for(const HalfCycles &half_cycles) {
|
inline void run_for(const HalfCycles &half_cycles) {
|
||||||
int cycles = half_cycles.as_int() + half_cycle_carry;
|
int cycles = half_cycles.as_int() + half_cycle_carry;
|
||||||
half_cycle_carry = cycles & 1;
|
half_cycle_carry = cycles & 1;
|
||||||
run_for(Cycles(cycles >> 1));
|
run_for(Cycles(cycles >> 1));
|
||||||
|
Loading…
Reference in New Issue
Block a user