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) {
|
2019-03-13 02:46:31 +00:00
|
|
|
// Check whether the current list of bus steps is exhausted; if so then
|
|
|
|
// seek out another one from the current program (if any), and if there
|
|
|
|
// are no more to do, revert to scheduling something else (after checking
|
|
|
|
// for interrupts).
|
|
|
|
if(active_step_->action == BusStep::Action::ScheduleNextProgram) {
|
|
|
|
if(active_micro_op_) {
|
|
|
|
++active_micro_op_;
|
|
|
|
switch(active_micro_op_->action) {
|
|
|
|
case MicroOp::Action::None: break;
|
|
|
|
|
|
|
|
case MicroOp::Action::PerformOperation:
|
|
|
|
std::cerr << "Should do something with program operation " << int(active_program_->operation) << std::endl;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
active_step_ = active_micro_op_->bus_program;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!active_step_) {
|
|
|
|
std::cerr << "68000 Abilities exhausted; should schedule an instruction or something?" << std::endl;
|
|
|
|
return;
|
|
|
|
}
|
2019-03-10 21:42:13 +00:00
|
|
|
}
|
|
|
|
|
2019-03-13 02:46:31 +00:00
|
|
|
// The bus step list is not exhausted, so perform the microcycle.
|
2019-03-10 21:42:13 +00:00
|
|
|
|
|
|
|
// Check for DTack if this isn't being treated implicitly.
|
|
|
|
if(!dtack_is_implicit) {
|
2019-03-13 02:46:31 +00:00
|
|
|
if(active_step_->microcycle.operation & (Microcycle::UpperData | Microcycle::LowerData) && !dtack_) {
|
2019-03-10 21:42:13 +00:00
|
|
|
// TODO: perform wait state.
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-12 02:47:58 +00:00
|
|
|
// TODO: synchronous bus.
|
|
|
|
|
2019-03-10 21:42:13 +00:00
|
|
|
// Perform the microcycle.
|
2019-03-13 02:46:31 +00:00
|
|
|
bus_handler_.perform_bus_operation(active_step_->microcycle, is_supervisor_);
|
2019-03-10 21:42:13 +00:00
|
|
|
|
|
|
|
// Perform the post-hoc action.
|
2019-03-13 02:46:31 +00:00
|
|
|
switch(active_step_->action) {
|
2019-03-10 21:42:13 +00:00
|
|
|
default:
|
2019-03-13 02:46:31 +00:00
|
|
|
std::cerr << "Unimplemented 68000 bus step action: " << int(active_step_->action) << std::endl;
|
2019-03-10 21:42:13 +00:00
|
|
|
return;
|
|
|
|
break;
|
|
|
|
|
2019-03-13 02:46:31 +00:00
|
|
|
case BusStep::Action::None: break;
|
2019-03-10 21:42:13 +00:00
|
|
|
|
2019-03-13 02:46:31 +00:00
|
|
|
case BusStep::Action::IncrementEffectiveAddress: effective_address_ += 2; break;
|
|
|
|
case BusStep::Action::IncrementProgramCounter: program_counter_.full += 2; break;
|
2019-03-10 21:42:13 +00:00
|
|
|
|
2019-03-13 02:46:31 +00:00
|
|
|
case BusStep::Action::AdvancePrefetch:
|
2019-03-10 21:42:13 +00:00
|
|
|
prefetch_queue_[0] = prefetch_queue_[1];
|
|
|
|
break;
|
|
|
|
}
|
2019-03-10 22:40:12 +00:00
|
|
|
|
|
|
|
// Move to the next program step.
|
2019-03-13 02:46:31 +00:00
|
|
|
++active_step_;
|
2019-03-10 21:42:13 +00:00
|
|
|
}
|
2019-03-10 21:27:34 +00:00
|
|
|
}
|