m2isar.metamodel.arch
This module contains classes for modeling the architectural part of an M2-ISA-R model. The architectural part is anything but the functional behavior of functions and instructions.
Attributes
Classes
A simple base class for a named object. |
|
A simple base class for an object with a name and a size. |
|
An object holding a constant value. Should have a value at some point, also holds attributes |
|
A class holding a range to denote a range of indices or width of a memory bank. |
|
Generic enumeration. |
|
Generic enumeration. |
|
Generic enumeration. |
|
Generic enumeration. |
|
Enum where members are also (and must be) ints |
|
Generic enumeration. |
|
A datatype base class, only holds information on whether it is a pointer. |
|
A void datatype, automatically assumes native size. |
|
An integer datatype with width and sign information. |
|
A function parameter. |
|
A scalar variable object, used mainly in behavior descriptions. |
|
A simple base class for an object with a name and a size. |
|
A generic memory object. Can have children, which alias to specific indices |
|
A class representing a fixed bit sequence in an instruction encoding. |
|
A class representing an operand in an instruction encoding. Can be split |
|
A class representing a full instruction operand. Has no information about |
|
A class representing an instruction. |
|
A class representing a function. |
|
A simple base class for a named object. |
|
A class representing an InstructionSet collection. Bundles constants, memories, functions |
|
A class representing an entire CPU core. Contains the collected attributes of multiple InstructionSets. |
Functions
|
|
|
Extract and separate parent and children memories from the given list |
Module Contents
- class SizedRefOrConst(name, size: ValOrConst)[source]
Bases:
Named
A simple base class for an object with a name and a size. Size can be either an int, a Constant or a statically resolvable expression, expressed by a BaseNode.
- _size: int | Constant | m2isar.metamodel.behav.BaseNode[source]
The size of the object
- class Constant(name, value: int | Constant | m2isar.metamodel.behav.BaseNode, attributes: dict[ConstAttribute, list[BaseNode]], size=None, signed=False)[source]
Bases:
SizedRefOrConst
An object holding a constant value. Should have a value at some point, also holds attributes and signedness information.
- _value: int | Constant | m2isar.metamodel.behav.BaseNode[source]
The value this object holds. Can be an int, another constant or a statically resolvable BaseNode.
- class RangeSpec(upper_base: ValOrConst, lower_base: ValOrConst = None, upper_power: ValOrConst = 1, lower_power: ValOrConst = 1)[source]
A class holding a range to denote a range of indices or width of a memory bank.
- _upper_base: int | Constant | m2isar.metamodel.behav.BaseNode[source]
The upper bound of the range. Can be an int, a constant or a statically resolvable BaseNode.
- _lower_base: int | Constant | m2isar.metamodel.behav.BaseNode[source]
The lower bound of the range. Can be an int, a constant or a statically resolvable BaseNode.
- _upper_power: int | Constant | m2isar.metamodel.behav.BaseNode[source]
Obsolete, do not use
- _lower_power: int | Constant | m2isar.metamodel.behav.BaseNode[source]
Obsolete, do not use
- class MemoryAttribute[source]
Bases:
enum.Enum
Generic enumeration.
Derive from this class to define new enumerations.
- class ConstAttribute[source]
Bases:
enum.Enum
Generic enumeration.
Derive from this class to define new enumerations.
- class InstrAttribute[source]
Bases:
enum.Enum
Generic enumeration.
Derive from this class to define new enumerations.
- class FunctionAttribute[source]
Bases:
enum.Enum
Generic enumeration.
Derive from this class to define new enumerations.
- class FunctionThrows[source]
Bases:
enum.IntEnum
Enum where members are also (and must be) ints
- class DataType[source]
Bases:
enum.Enum
Generic enumeration.
Derive from this class to define new enumerations.
- class DataType2(ptr)[source]
A datatype base class, only holds information on whether it is a pointer.
- class IntegerType(width: int | Constant | m2isar.metamodel.behav.BaseNode, signed: bool, ptr)[source]
Bases:
DataType2
An integer datatype with width and sign information.
- _width: int | Constant | m2isar.metamodel.behav.BaseNode[source]
- class FnParam(name, size, data_type: DataType, width=1)[source]
Bases:
SizedRefOrConst
A function parameter.
- _width: int | Constant | m2isar.metamodel.behav.BaseNode[source]
The array width of this parameter.
- class Scalar(name, value: int, static: bool, size, data_type: DataType)[source]
Bases:
SizedRefOrConst
A scalar variable object, used mainly in behavior descriptions.
- class Intrinsic(name, size: ValOrConst, data_type: DataType, value: int = None)[source]
Bases:
SizedRefOrConst
A simple base class for an object with a name and a size. Size can be either an int, a Constant or a statically resolvable expression, expressed by a BaseNode.
- class Memory(name, range_: RangeSpec, size, attributes: dict[MemoryAttribute, list[BaseNode]])[source]
Bases:
SizedRefOrConst
A generic memory object. Can have children, which alias to specific indices of their parent memory. Has a variable array size, can therefore represent both scalar and array registers and/or memories.
- class BitVal[source]
A class representing a fixed bit sequence in an instruction encoding. Modeled as length and integral value.
- class BitField(name, _range: RangeSpec, data_type: DataType)[source]
Bases:
Named
A class representing an operand in an instruction encoding. Can be split into multiple parts, if the operand is split over two or more bit ranges.
- class BitFieldDescr(name, size: ValOrConst, data_type: DataType)[source]
Bases:
SizedRefOrConst
A class representing a full instruction operand. Has no information about the actual bits it is composed of, for that use BitField.
- class Instruction(name, attributes: dict[InstrAttribute, list[BaseNode]], encoding: list[BitField | BitVal], disass: str, operation: m2isar.metamodel.behav.Operation, function_info: m2isar.metamodel.code_info.FunctionInfo)[source]
Bases:
SizedRefOrConst
A class representing an instruction.
- operation: m2isar.metamodel.behav.Operation[source]
- fields: dict[str, BitFieldDescr][source]
- class Function(name, attributes: dict[FunctionAttribute, list[BaseNode]], return_len, data_type: DataType, args: list[FnParam], operation: m2isar.metamodel.behav.Operation, extern: bool = False, function_info: m2isar.metamodel.code_info.FunctionInfo = None)[source]
Bases:
SizedRefOrConst
A class representing a function.
- operation: m2isar.metamodel.behav.Operation[source]
- extract_memory_alias(memories: list[Memory])[source]
Extract and separate parent and children memories from the given list of memory objects.
- class AlwaysBlock(name: str, attributes, operation)[source]
Bases:
Named
A simple base class for a named object.
- operation: m2isar.metamodel.behav.Operation[source]
- class InstructionSet(name, extension: list[str], constants: dict[str, Constant], memories: dict[str, Memory], functions: dict[str, Function], instructions: dict[tuple[int, int], Instruction])[source]
Bases:
Named
A class representing an InstructionSet collection. Bundles constants, memories, functions and instructions under a common name.
- class CoreDef(name, contributing_types: list[str], template: str, constants: dict[str, Constant], memories: dict[str, Memory], memory_aliases: dict[str, Memory], functions: dict[str, Function], instructions: dict[tuple[int, int], Instruction], instr_classes: set[int], intrinsics: dict[str, Intrinsic])[source]
Bases:
Named
A class representing an entire CPU core. Contains the collected attributes of multiple InstructionSets.