From d16dab6f62084d1eee77426e0953c083ff7422d8 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Fri, 29 Apr 2022 10:40:19 -0400 Subject: [PATCH] Starts introducing a sequencer, to resolve responsibility of `perform`. --- InstructionSets/M68k/Sequence.cpp | 30 ++++++++ InstructionSets/M68k/Sequence.hpp | 71 +++++++++++++++++++ .../Clock Signal.xcodeproj/project.pbxproj | 4 ++ 3 files changed, 105 insertions(+) create mode 100644 InstructionSets/M68k/Sequence.cpp create mode 100644 InstructionSets/M68k/Sequence.hpp diff --git a/InstructionSets/M68k/Sequence.cpp b/InstructionSets/M68k/Sequence.cpp new file mode 100644 index 000000000..a476be507 --- /dev/null +++ b/InstructionSets/M68k/Sequence.cpp @@ -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 struct Steps { + static constexpr uint16_t value = 0; +}; + +template struct Steps { + static constexpr uint16_t value = uint16_t(F) | uint16_t(Mask::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)) {} diff --git a/InstructionSets/M68k/Sequence.hpp b/InstructionSets/M68k/Sequence.hpp new file mode 100644 index 000000000..b33ca0ce7 --- /dev/null +++ b/InstructionSets/M68k/Sequence.hpp @@ -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 */ diff --git a/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj b/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj index 54f0cb863..280d5e11f 100644 --- a/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj +++ b/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj @@ -1425,6 +1425,8 @@ 4B79629D2819681F008130F9 /* Model.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Model.hpp; sourceTree = ""; }; 4B79629E2819681F008130F9 /* Decoder.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Decoder.hpp; sourceTree = ""; }; 4B79629F2819681F008130F9 /* Decoder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Decoder.cpp; sourceTree = ""; }; + 4B7962A3281C1B76008130F9 /* Sequence.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = Sequence.hpp; sourceTree = ""; }; + 4B7962A4281C2EE3008130F9 /* Sequence.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Sequence.cpp; sourceTree = ""; }; 4B79A4FE1FC9082300EEDAD5 /* TypedDynamicMachine.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = TypedDynamicMachine.hpp; sourceTree = ""; }; 4B79A4FF1FC913C900EEDAD5 /* MSX.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MSX.cpp; sourceTree = ""; }; 4B79A5001FC913C900EEDAD5 /* MSX.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = MSX.hpp; sourceTree = ""; }; @@ -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 */, );