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 ("Parameter") Parameter value. |
|
A class holding a range to denote a range of indices or width of a memory bank. |
|
A function parameter. |
|
A simple base class for a symbol, which is a named object that |
|
A variable is only defined in the functional behavior of a function, but not in the architectural part. |
|
A simple base class for a symbol, which is a named object that |
|
A class representing a register bank. A register bank combines structured registers, |
|
A class representing a register. A register is a single defined Symbols. Dont mix it up |
|
A generic memory object. Can have children, which alias to specific indices |
|
A class representing an (potentially ranged) alias to a Register/Memory/RegisterBank entity, |
|
A class representing an operand in an instruction encoding. Can be split |
|
A class representing a fixed bit sequence in an instruction encoding. |
|
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 parameters, memories, functions |
|
A group of InstructionSet instances. |
|
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 |
|
Extract and separate parent and children register banks from the given list |
Module Contents
- class SizedRefOrConst(name, size: ValOrConst)[source]
Bases:
NamedA simple base class for an object with a name and a size. Size can be either an int, a Parameter or a statically resolvable expression, expressed by a BaseNode.
- _size: int | Parameter | m2isar.metamodel.behav.BaseNode[source]
The size of the object
- class Parameter(name, value: int | Parameter | m2isar.metamodel.behav.BaseNode, attributes: dict[attribute_info.ConstAttribute, list[BaseNode]], size=None, signed=False)[source]
Bases:
SizedRefOrConstAn object holding a (“Parameter”) Parameter value. Should have a value at some point, also holds attributes and signedness information.
- _value: int | Parameter | 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 | Parameter | 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 | Parameter | 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 | Parameter | m2isar.metamodel.behav.BaseNode[source]
Obsolete, do not use
- _lower_power: int | Parameter | m2isar.metamodel.behav.BaseNode[source]
Obsolete, do not use
- class FnParam(name, size, kind: m2isar.metamodel.type_info.TypeKind, width=1)[source]
Bases:
NamedA function parameter.
- _width: int | Parameter | m2isar.metamodel.behav.BaseNode[source]
The array width of this parameter.
- class Symbol(name: str, ty: m2isar.metamodel.type_info.PrimitiveType | m2isar.metamodel.type_info.FloatType | m2isar.metamodel.type_info.ArrayType | m2isar.metamodel.type_info.BitFieldType | m2isar.metamodel.type_info.PointerType, attributes: dict = {})[source]
Bases:
NamedA simple base class for a symbol, which is a named object that can be used as an operand in an instruction or function.
- class Variable(name: str, ty: m2isar.metamodel.type_info.PrimitiveType | m2isar.metamodel.type_info.FloatType | m2isar.metamodel.type_info.ArrayType, attributes: dict = {'static': attribute_info.AccessAttribute.RW}, value=None, children=[])[source]
Bases:
SymbolA variable is only defined in the functional behavior of a function, but not in the architectural part. Archtiectural Parts are depicted as Register Banks or Memories, but not as variables. However, we need to define variables for intermediate results, …
- class Intrinsic(name, size: ValOrConst, kind: m2isar.metamodel.type_info.TypeKind, value: int = None)[source]
Bases:
SymbolA simple base class for a symbol, which is a named object that can be used as an operand in an instruction or function.
- class RegisterBank(name, nr_ele: int | Parameter, kind: m2isar.metamodel.type_info.TypeKind, size, attributes: dict[attribute_info.MemoryAttribute, list[BaseNode]])[source]
Bases:
SymbolA class representing a register bank. A register bank combines structured registers, which is used to represent registers in the architectural part of an M2-ISA-R model.
- property is_main_reg[source]
Return true if this memory is tagged as being a general-purpose register.
- property is_float_reg: bool[source]
Return true if this memory is tagged as being a float register array or named F.
- property is_vector_reg: bool[source]
Return true if this memory is tagged as being a vector register array or named V.
- _is_specific_register(register_type: m2isar.metamodel.attribute_info.RegisterAttribute, expected_name: str = '') bool[source]
This is a helper function to ensure, that all checks are performed always the same. :param register_type: The register attribute qualifying for this check :param expected_name: The fixed name for this specific type of register :return: True if the register matches the constraints, False otherwise
- class Register(name, kind: m2isar.metamodel.type_info.TypeKind, size, attributes: dict[attribute_info.RegisterAttribute, list[BaseNode]])[source]
Bases:
SymbolA class representing a register. A register is a single defined Symbols. Dont mix it up bit alias that are IndexedReference of already declared Symbols. This class should simplify different handling to register bank. And is used to represent registers in the architectural part of an M2-ISA-R model.
- _is_specific_register(register_type: m2isar.metamodel.attribute_info.RegisterAttribute, expected_name: str = '') bool[source]
This is a helper function to ensure, that all checks are performed always the same. :param register_type: The register attribute qualifying for this check :param expected_name: The fixed name for this specific type of memory :return: True if the memory matches the constraints, False otherwise
- class Memory(name, kind: m2isar.metamodel.type_info.TypeKind, size, length, attributes: dict[attribute_info.MemoryAttribute, list[BaseNode]])[source]
Bases:
SymbolA 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.
- property data_range[source]
Returns a RangeSpec object with upper=range.upper-range.lower, lower=0.
- property is_csr_reg: bool[source]
Return true if this memory is tagged as being a csr register array or named CSR.
- _is_specific_memory(memory_type: m2isar.metamodel.attribute_info.MemoryAttribute, expected_name: str = '') bool[source]
This is a helper function to ensure, that all checks are performed always the same. :param memory_type: The memory attribute qualifying for this check :param expected_name: The fixed name for this specific type of memory :return: True if the memory matches the constraints, False otherwise
- class Alias(name, parent: Memory | RegisterBank, range: RangeSpec, type: m2isar.metamodel.type_info.PointerType, attributes: dict = {})[source]
Bases:
SymbolA class representing an (potentially ranged) alias to a Register/Memory/RegisterBank entity, which refer to the architectural part of an M2-ISA-R model. This access might be ranged
- parent: Memory | RegisterBank[source]
- class BitField(name, _range: RangeSpec, kind: m2isar.metamodel.type_info.TypeKind)[source]
Bases:
SymbolA 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 BitVal[source]
A class representing a fixed bit sequence in an instruction encoding. Modeled as length and integral value.
- class BitFieldDescr(name, size: ValOrConst, kind: m2isar.metamodel.type_info.TypeKind)[source]
Bases:
NamedA 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[attribute_info.InstrAttribute, list[BaseNode]], encoding: list[BitField | BitVal], mnemonic: str, assembly: str, operation: m2isar.metamodel.behav.Operation, function_info: m2isar.metamodel.code_info.FunctionInfo)[source]
Bases:
SizedRefOrConstA class representing an instruction.
- operation: m2isar.metamodel.behav.Operation[source]
- fields: dict[str, BitFieldDescr][source]
- class Function(name, attributes: dict[attribute_info.FunctionAttribute, list[BaseNode]], return_len, kind: m2isar.metamodel.type_info.TypeKind, args: list[FnParam], operation: m2isar.metamodel.behav.Operation, extern: bool = False, function_info: m2isar.metamodel.code_info.FunctionInfo = None)[source]
Bases:
NamedA 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.
- extract_register_alias(register_banks: list[RegisterBank])[source]
Extract and separate parent and children register banks from the given list of register bank objects.
- class AlwaysBlock(name: str, attributes, operation)[source]
Bases:
NamedA simple base class for a named object.
- operation: m2isar.metamodel.behav.Operation[source]
- class InstructionSet(name, extension: list[str], parameters: dict[str, Parameter], memories: dict[str, Memory], register_banks: dict[str, RegisterBank], functions: dict[str, Function], instructions: dict[tuple[int, int], Instruction])[source]
Bases:
NamedA class representing an InstructionSet collection. Bundles parameters, memories, functions and instructions under a common name.
- class InstructionSetGroup(name, combines: list[str])[source]
Bases:
InstructionSetA group of InstructionSet instances.
- class CoreDef(name, contributing_types: list[str], template: str, parameters: dict[str, Parameter], memories: dict[str, Memory], memory_aliases: dict[str, Alias], register_banks: dict[str, RegisterBank | Register], register_aliases: dict[str, Alias], functions: dict[str, Function], instructions: dict[tuple[int, int], Instruction] | list[Instruction], instr_classes: set[int], intrinsics: dict[str, Intrinsic])[source]
Bases:
NamedA class representing an entire CPU core. Contains the collected attributes of multiple InstructionSets.