1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-05 21:05:51 +00:00
CLK/InstructionSets/M68k/Sequence.hpp

80 lines
1.8 KiB
C++
Raw Normal View History

//
// Sequencer.hpp
// Clock Signal
//
// Created by Thomas Harte on 29/04/2022.
// Copyright © 2022 Thomas Harte. All rights reserved.
//
#ifndef InstructionSets_68k_Sequencer_hpp
#define InstructionSets_68k_Sequencer_hpp
#include "Instruction.hpp"
#include "Model.hpp"
namespace InstructionSet {
namespace M68k {
enum class Step {
/// No further steps remain.
Done,
/// Fetch the value of operand 1.
FetchOp1,
/// Fetch the value of operand 2.
FetchOp2,
/// Do the logical operation.
Perform,
/// A catch-all for bus activity that doesn't fit the pattern
/// of fetch/stop operand 1/2, e.g. this opaquely covers almost
/// the entirety of MOVEM.
///
/// TODO: list all operations that contain this step,
/// and to cover what activity.
SpecificBusActivity,
/// Store the value of operand 1.
StoreOp1,
/// Store the value of operand 2.
StoreOp2,
2022-04-30 00:30:48 +00:00
/// Calculate effective address of operand 1.
CalcEA1,
/// Calculate effective address of operand 2.
CalcEA2,
Max = CalcEA2
};
/// Indicates the abstract steps necessary to perform an operation,
/// at least as far as that's generic.
template<Model model> class Sequence {
public:
Sequence(Operation);
/// @returns The next @c Step to perform, or @c Done
/// if no further steps remain. This step is removed from the
/// list of remaining steps.
Step pop_front() {
2022-04-30 00:30:48 +00:00
static_assert(int(Step::Max) < 16);
const auto step = Step(steps_ & 15);
steps_ >>= 4;
return step;
}
/// @returns @c true if no steps other than @c Done remain;
/// @c false otherwise.
bool empty() {
return !steps_;
}
private:
2022-04-30 00:30:48 +00:00
uint32_t steps_ = 0;
2022-04-30 00:30:48 +00:00
uint32_t steps_for(Operation);
};
2022-04-30 00:30:48 +00:00
static_assert(sizeof(Sequence<Model::M68000>) == sizeof(uint32_t));
}
}
#endif /* InstructionSets_68k_Sequencer_h */