Skip to content

Proposal for a generic state machine #143

@stefanberndtsson

Description

@stefanberndtsson

I propose that ucode takes on the job of running everything around the instructions, and exceptions.
The state machine has one state chain for each instruction being executed. A state chain is a sequence
of microcode instructions (uop) being executed one after the other. Each uop taking 2 8MHz cycles,
and being run on even 8MHz cycles.

EA is just one or more sections of such a chain, and so are exceptions.

All of this assumes the full prefetch with IRC/IR/IRD is in place.

So the main role for an instruction is to setup the chain based on the instruction opcode (steps below may be optional):

  1. Insert any uop:s that's needed before any EA
  2. Append any EA chain that's relevant for reading
  3. The instructions actual operation (ADD, SUB, Shift, a.s.o.)
  4. Any EA chain for writing back to memory or such
  5. Parts for setting flags
  6. Remaining bits and prefetches before the instruction ends

The instruction is now only called to setup, after that, ucode takes over and steps through the chain.
If anything would happen that would change the normal execution, like for example a bus error occurs within
the EA steps, a bus error chain replaces the rest of the instruction chain, and ucode keeps on executing
just like before.

For TRAP this would essentially be the same thing, except the instruction would just insert the exception
chain for the TRAP exception into the chain straight away.

Other exceptions could be caught when ucode parses the end step, and if there is an exception/interrupt
pending, append the exception chain, and keep on running a bit longer.

Every uop is a callback into a function dealing with it. For steps 2 and 4 above, those are callbacks pretty
much the way they are in the EA code now. For 1, 3, 5 and 6, they would be provided by the instruction code.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions