riscemu.CPU module

RiscEmu (c) 2021-2022 Anton Lydike

SPDX-License-Identifier: MIT

This file contains the CPU logic (not the individual instruction sets). See instructions/instruction_set.py for more info on them.

class riscemu.CPU.UserModeCPU(instruction_sets: List[Type[InstructionSet]], conf: RunConfig)

Bases: CPU

This class represents a single CPU. It holds references to it’s mmu, registers and syscall interrupt handler.

It is initialized with a configuration and a list of instruction sets.

__init__(instruction_sets: List[Type[InstructionSet]], conf: RunConfig)

Creates a CPU instance.

Parameters:

instruction_sets – A list of instruction set classes. These must inherit from the InstructionSet class

step(verbose: bool = False)

Execute a single instruction, then return.

run(verbose: bool = False)
setup_stack(stack_size: int = 4096) bool

Create program stack and populate stack pointer :param stack_size: the size of the required stack, defaults to 4Kib :return:

classmethod get_loaders() Iterable[Type[ProgramLoader]]
regs: Registers
mmu: MMU
pc: int
cycle: int
halted: bool
debugger_active: bool
instructions: Dict[str, Callable[[Instruction], None]]
instruction_sets: Set[InstructionSet]
conf: RunConfig