preparations for sphinx documentation generation

float_support
Anton Lydike 4 years ago
parent 6e6ce90e9a
commit 819d57e3c8

@ -11,7 +11,7 @@ from typing import Tuple, List, Dict, Callable, Type
from .Tokenizer import RiscVTokenizer from .Tokenizer import RiscVTokenizer
from .Syscall import SyscallInterface from .Syscall import SyscallInterface, get_syscall_symbols
from .Exceptions import RiscemuBaseException, LaunchDebuggerException from .Exceptions import RiscemuBaseException, LaunchDebuggerException
from .MMU import MMU from .MMU import MMU
from .Config import RunConfig from .Config import RunConfig
@ -19,6 +19,8 @@ from .Registers import Registers
from .debug import launch_debug_session from .debug import launch_debug_session
from .colors import FMT_CPU, FMT_NONE, FMT_ERROR from .colors import FMT_CPU, FMT_NONE, FMT_ERROR
import riscemu
import typing import typing
if typing.TYPE_CHECKING: if typing.TYPE_CHECKING:
@ -32,7 +34,7 @@ class CPU:
It is initialized with a configuration and a list of instruction sets. It is initialized with a configuration and a list of instruction sets.
""" """
def __init__(self, conf: RunConfig, instruction_sets: List[Type['InstructionSet']]): def __init__(self, conf: RunConfig, instruction_sets: List[Type['riscemu.InstructionSet']]):
""" """
Creates a CPU instance. Creates a CPU instance.
@ -53,7 +55,7 @@ class CPU:
self.syscall_int = SyscallInterface() self.syscall_int = SyscallInterface()
# load all instruction sets # load all instruction sets
self.instruction_sets: List['InstructionSet'] = list() self.instruction_sets: List[riscemu.InstructionSet] = list()
self.instructions: Dict[str, Callable[[LoadedInstruction], None]] = dict() self.instructions: Dict[str, Callable[[LoadedInstruction], None]] = dict()
for set_class in instruction_sets: for set_class in instruction_sets:
ins_set = set_class(self) ins_set = set_class(self)
@ -72,13 +74,13 @@ class CPU:
""" """
return RiscVTokenizer(tokenizer_input, self.all_instructions()) return RiscVTokenizer(tokenizer_input, self.all_instructions())
def load(self, e: 'Executable'): def load(self, e: riscemu.Executable):
""" """
Load an executable into Memory Load an executable into Memory
""" """
return self.mmu.load_bin(e) return self.mmu.load_bin(e)
def run_loaded(self, le: 'LoadedExecutable'): def run_loaded(self, le: 'riscemu.LoadedExecutable'):
""" """
Run a loaded executable Run a loaded executable
""" """

@ -4,9 +4,14 @@ RiscEmu (c) 2021 Anton Lydike
SPDX-License-Identifier: BSD-2-Clause SPDX-License-Identifier: BSD-2-Clause
""" """
import typing
from abc import abstractmethod from abc import abstractmethod
from .colors import * from .colors import *
if typing.TYPE_CHECKING:
from .Executable import LoadedInstruction
class RiscemuBaseException(BaseException): class RiscemuBaseException(BaseException):
@abstractmethod @abstractmethod
@ -93,6 +98,7 @@ class OutOfMemoryException(RiscemuBaseException):
# CPU Exceptions # CPU Exceptions
class UnimplementedInstruction(RiscemuBaseException): class UnimplementedInstruction(RiscemuBaseException):
def __init__(self, ins: 'LoadedInstruction'): def __init__(self, ins: 'LoadedInstruction'):
self.ins = ins self.ins = ins

@ -17,6 +17,8 @@ from .Executable import Executable, LoadedExecutable
from .ExecutableParser import ExecutableParser from .ExecutableParser import ExecutableParser
from .instructions import *
from .MMU import MMU from .MMU import MMU
from .Registers import Registers from .Registers import Registers
from .Syscall import SyscallInterface, Syscall from .Syscall import SyscallInterface, Syscall

@ -9,6 +9,7 @@ from typing import Tuple, Callable, Dict
from abc import ABC from abc import ABC
from ..CPU import CPU from ..CPU import CPU
from ..helpers import ASSERT_LEN, ASSERT_IN, to_unsigned from ..helpers import ASSERT_LEN, ASSERT_IN, to_unsigned
from ..Executable import LoadedInstruction
class InstructionSet(ABC): class InstructionSet(ABC):

@ -11,6 +11,7 @@ from ..colors import FMT_DEBUG, FMT_NONE
from ..debug import launch_debug_session from ..debug import launch_debug_session
from ..Exceptions import LaunchDebuggerException from ..Exceptions import LaunchDebuggerException
from ..Syscall import Syscall from ..Syscall import Syscall
from ..Executable import LoadedInstruction
class RV32I(InstructionSet): class RV32I(InstructionSet):

Loading…
Cancel
Save