1
0
mirror of https://github.com/TomHarte/CLK.git synced 2025-02-07 05:30:30 +00:00

Starts introducing a sequencer, to resolve responsibility of perform.

This commit is contained in:
Thomas Harte 2022-04-29 10:40:19 -04:00
parent 8066b19f93
commit d16dab6f62
3 changed files with 105 additions and 0 deletions

View File

@ -0,0 +1,30 @@
//
// Sequence.cpp
// Clock Signal
//
// Created by Thomas Harte on 29/04/2022.
// Copyright © 2022 Thomas Harte. All rights reserved.
//
#include "Sequence.hpp"
using namespace InstructionSet::M68k;
template <typename EnumT, EnumT... T> struct Steps {
static constexpr uint16_t value = 0;
};
template <typename EnumT, EnumT F, EnumT... T> struct Steps<EnumT, F, T...> {
static constexpr uint16_t value = uint16_t(F) | uint16_t(Mask<EnumT, T...>::value << 3);
};
uint16_t Sequence::steps_for(Operation operation) {
switch(operation) {
// This handles a NOP, and not much else.
default: return 0;
case Operation::ABCD: return Steps< Step::FetchOp1, Step::Perform, Step::StoreOp1 >::value;
}
}
Sequence::Sequence(Operation operation) : steps_(steps_for(operation)) {}

View File

@ -0,0 +1,71 @@
//
// 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"
namespace InstructionSet {
namespace M68k {
/// Indicates the abstract steps necessary to perform an operation,
/// at least as far as that's generic.
class Sequence {
public:
Sequence(Operation);
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,
};
/// @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() {
const auto step = Step(steps_ & 7);
steps_ >>= 3;
return step;
}
/// @returns @c true if no steps other than @c Done remain;
/// @c false otherwise.
bool empty() {
return !steps_;
}
private:
uint16_t steps_ = 0;
uint16_t steps_for(Operation);
};
static_assert(sizeof(Sequence) == sizeof(uint16_t));
}
}
#endif /* InstructionSets_68k_Sequencer_h */

View File

@ -1425,6 +1425,8 @@
4B79629D2819681F008130F9 /* Model.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Model.hpp; sourceTree = "<group>"; };
4B79629E2819681F008130F9 /* Decoder.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Decoder.hpp; sourceTree = "<group>"; };
4B79629F2819681F008130F9 /* Decoder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Decoder.cpp; sourceTree = "<group>"; };
4B7962A3281C1B76008130F9 /* Sequence.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = Sequence.hpp; sourceTree = "<group>"; };
4B7962A4281C2EE3008130F9 /* Sequence.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Sequence.cpp; sourceTree = "<group>"; };
4B79A4FE1FC9082300EEDAD5 /* TypedDynamicMachine.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = TypedDynamicMachine.hpp; sourceTree = "<group>"; };
4B79A4FF1FC913C900EEDAD5 /* MSX.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MSX.cpp; sourceTree = "<group>"; };
4B79A5001FC913C900EEDAD5 /* MSX.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = MSX.hpp; sourceTree = "<group>"; };
@ -3161,10 +3163,12 @@
isa = PBXGroup;
children = (
4B79629F2819681F008130F9 /* Decoder.cpp */,
4B7962A4281C2EE3008130F9 /* Sequence.cpp */,
4B79629E2819681F008130F9 /* Decoder.hpp */,
4B79629C2819681F008130F9 /* Instruction.hpp */,
4B79629D2819681F008130F9 /* Model.hpp */,
4BB5B996281B1E3F00522DA9 /* Perform.hpp */,
4B7962A3281C1B76008130F9 /* Sequence.hpp */,
4BB5B997281B1F7B00522DA9 /* Status.hpp */,
4BB5B999281B244400522DA9 /* Implementation */,
);