mirror of
https://github.com/TomHarte/CLK.git
synced 2025-03-11 20:31:59 +00:00
(obiter: the 1540 now appears to discern the correct sequence of bits. Framing is off in my test printfs but that's neither here nor there).
35 lines
582 B
C++
35 lines
582 B
C++
//
|
|
// Storage.hpp
|
|
// Clock Signal
|
|
//
|
|
// Created by Thomas Harte on 10/07/2016.
|
|
// Copyright © 2016 Thomas Harte. All rights reserved.
|
|
//
|
|
|
|
#ifndef Storage_hpp
|
|
#define Storage_hpp
|
|
|
|
#include "../NumberTheory/Factors.hpp"
|
|
|
|
namespace Storage {
|
|
|
|
struct Time {
|
|
unsigned int length, clock_rate;
|
|
|
|
inline void simplify()
|
|
{
|
|
unsigned int common_divisor = NumberTheory::greatest_common_divisor(length, clock_rate);
|
|
length /= common_divisor;
|
|
clock_rate /= common_divisor;
|
|
}
|
|
|
|
inline float get_float()
|
|
{
|
|
return (float)length / (float)clock_rate;
|
|
}
|
|
};
|
|
|
|
}
|
|
|
|
#endif /* Storage_h */
|