mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-26 08:49:37 +00:00
Fixed Time
addition, added accumulation of distance into track into the disk drive, added a short circuit for LCM.
This commit is contained in:
parent
30f8b6baa4
commit
21f1fa37a4
@ -29,6 +29,8 @@ unsigned int NumberTheory::greatest_common_divisor(unsigned int a, unsigned int
|
|||||||
|
|
||||||
unsigned int NumberTheory::least_common_multiple(unsigned int a, unsigned int b)
|
unsigned int NumberTheory::least_common_multiple(unsigned int a, unsigned int b)
|
||||||
{
|
{
|
||||||
|
if(a == b) return a;
|
||||||
|
|
||||||
unsigned int gcd = greatest_common_divisor(a, b);
|
unsigned int gcd = greatest_common_divisor(a, b);
|
||||||
return (a / gcd) * (b / gcd);
|
return (a / gcd) * (b / gcd);
|
||||||
}
|
}
|
||||||
|
@ -101,9 +101,11 @@ void DiskDrive::process_next_event()
|
|||||||
{
|
{
|
||||||
case Track::Event::FluxTransition:
|
case Track::Event::FluxTransition:
|
||||||
_pll->add_pulse();
|
_pll->add_pulse();
|
||||||
|
_time_into_track = _time_into_track + _current_event.length;
|
||||||
break;
|
break;
|
||||||
case Track::Event::IndexHole:
|
case Track::Event::IndexHole:
|
||||||
_cycles_since_index_hole = 0;
|
_cycles_since_index_hole = 0;
|
||||||
|
_time_into_track.set_zero();
|
||||||
process_index_hole();
|
process_index_hole();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -103,6 +103,7 @@ class DiskDrive: public DigitalPhaseLockedLoop::Delegate, public TimedEventLoop
|
|||||||
|
|
||||||
inline void get_next_event();
|
inline void get_next_event();
|
||||||
Track::Event _current_event;
|
Track::Event _current_event;
|
||||||
|
Time _time_into_track;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -49,9 +49,21 @@ struct Time {
|
|||||||
{
|
{
|
||||||
Time result;
|
Time result;
|
||||||
result.clock_rate = NumberTheory::least_common_multiple(clock_rate, other.clock_rate);
|
result.clock_rate = NumberTheory::least_common_multiple(clock_rate, other.clock_rate);
|
||||||
result.length = length * (clock_rate / result.clock_rate) + other.length * (other.clock_rate / result.clock_rate);
|
result.length = length * (result.clock_rate / clock_rate) + other.length * (result.clock_rate / other.clock_rate);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void set_zero()
|
||||||
|
{
|
||||||
|
length = 0;
|
||||||
|
clock_rate = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void set_one()
|
||||||
|
{
|
||||||
|
length = 1;
|
||||||
|
clock_rate = 1;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user