2019-03-10 21:27:34 +00:00
|
|
|
//
|
|
|
|
// 68000Implementation.hpp
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 10/03/2019.
|
|
|
|
// Copyright © 2019 Thomas Harte. All rights reserved.
|
|
|
|
//
|
|
|
|
|
2019-03-10 22:40:12 +00:00
|
|
|
template <class T, bool dtack_is_implicit> void Processor<T, dtack_is_implicit>::run_for(HalfCycles duration) {
|
2019-03-10 21:42:13 +00:00
|
|
|
// TODO: obey the 'cycles' count.
|
|
|
|
while(true) {
|
|
|
|
// Check whether the program is exhausted.
|
|
|
|
if(active_program_->action == Step::Action::ScheduleNextProgram) {
|
|
|
|
std::cerr << "68000 Abilities exhausted" << std::endl;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// The program is not exhausted, so perform the microcycle.
|
|
|
|
|
|
|
|
// Check for DTack if this isn't being treated implicitly.
|
|
|
|
if(!dtack_is_implicit) {
|
|
|
|
if(active_program_->microcycle.operation & (Microcycle::UpperData | Microcycle::LowerData) && !dtack_) {
|
|
|
|
// TODO: perform wait state.
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Perform the microcycle.
|
|
|
|
bus_handler_.perform_bus_operation(active_program_->microcycle, is_supervisor_);
|
|
|
|
|
|
|
|
// Perform the post-hoc action.
|
|
|
|
switch(active_program_->action) {
|
|
|
|
default:
|
|
|
|
std::cerr << "Unimplemented 68000 action: " << int(active_program_->action) << std::endl;
|
|
|
|
return;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Step::Action::None: break;
|
|
|
|
|
|
|
|
case Step::Action::IncrementEffectiveAddress: effective_address_ += 2; break;
|
|
|
|
case Step::Action::IncrementProgramCounter: program_counter_.full += 2; break;
|
|
|
|
|
|
|
|
case Step::Action::AdvancePrefetch:
|
|
|
|
prefetch_queue_[0] = prefetch_queue_[1];
|
|
|
|
break;
|
|
|
|
}
|
2019-03-10 22:40:12 +00:00
|
|
|
|
|
|
|
// Move to the next program step.
|
|
|
|
++active_program_;
|
2019-03-10 21:42:13 +00:00
|
|
|
}
|
2019-03-10 21:27:34 +00:00
|
|
|
}
|