m2isar.metamodel.arch ===================== .. py:module:: m2isar.metamodel.arch .. autoapi-nested-parse:: 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 ---------- .. autoapisummary:: m2isar.metamodel.arch.ValOrConst Classes ------- .. autoapisummary:: m2isar.metamodel.arch.Named m2isar.metamodel.arch.SizedRefOrConst m2isar.metamodel.arch.Constant m2isar.metamodel.arch.RangeSpec m2isar.metamodel.arch.MemoryAttribute m2isar.metamodel.arch.ConstAttribute m2isar.metamodel.arch.InstrAttribute m2isar.metamodel.arch.FunctionAttribute m2isar.metamodel.arch.FunctionThrows m2isar.metamodel.arch.DataType m2isar.metamodel.arch.DataType2 m2isar.metamodel.arch.VoidType m2isar.metamodel.arch.IntegerType m2isar.metamodel.arch.FnParam m2isar.metamodel.arch.Scalar m2isar.metamodel.arch.Intrinsic m2isar.metamodel.arch.Memory m2isar.metamodel.arch.BitVal m2isar.metamodel.arch.BitField m2isar.metamodel.arch.BitFieldDescr m2isar.metamodel.arch.Instruction m2isar.metamodel.arch.Function m2isar.metamodel.arch.AlwaysBlock m2isar.metamodel.arch.InstructionSet m2isar.metamodel.arch.CoreDef Functions --------- .. autoapisummary:: m2isar.metamodel.arch.get_const_or_val m2isar.metamodel.arch.extract_memory_alias Module Contents --------------- .. py:function:: get_const_or_val(arg) -> int .. py:class:: Named(name: str) A simple base class for a named object. .. py:attribute:: name :type: str The name of the object. .. py:method:: __str__() -> str .. py:method:: __repr__() -> str .. py:data:: ValOrConst .. py:class:: SizedRefOrConst(name, size: ValOrConst) Bases: :py:obj:`Named` .. autoapi-inheritance-diagram:: m2isar.metamodel.arch.SizedRefOrConst :parts: 1 :private-bases: 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. .. py:attribute:: _size :type: Union[int, Constant, m2isar.metamodel.behav.BaseNode] The size of the object .. py:property:: size :type: int Returns the resolved size, by calling get_const_or_val on _size. .. py:property:: actual_size Returns the bits needed in multiples of eight to represent the resolved size of the object. .. py:method:: __str__() -> str .. py:class:: Constant(name, value: Union[int, Constant, m2isar.metamodel.behav.BaseNode], attributes: dict[ConstAttribute, list[BaseNode]], size=None, signed=False) Bases: :py:obj:`SizedRefOrConst` .. autoapi-inheritance-diagram:: m2isar.metamodel.arch.Constant :parts: 1 :private-bases: An object holding a constant value. Should have a value at some point, also holds attributes and signedness information. .. py:attribute:: _value :type: Union[int, Constant, m2isar.metamodel.behav.BaseNode] The value this object holds. Can be an int, another constant or a statically resolvable BaseNode. .. py:attribute:: attributes :type: dict[ConstAttribute, list[BaseNode]] A dictionary of attributes, mapping attribute type to a list of attribute arguments. .. py:attribute:: signed :type: bool The signedness of this constant. .. py:property:: value Returns the resolved value this constant holds. .. py:method:: __str__() -> str .. py:method:: __repr__() -> str .. py:class:: RangeSpec(upper_base: ValOrConst, lower_base: ValOrConst = None, upper_power: ValOrConst = 1, lower_power: ValOrConst = 1) A class holding a range to denote a range of indices or width of a memory bank. .. py:attribute:: _upper_base :type: Union[int, Constant, m2isar.metamodel.behav.BaseNode] The upper bound of the range. Can be an int, a constant or a statically resolvable BaseNode. .. py:attribute:: _lower_base :type: Union[int, Constant, m2isar.metamodel.behav.BaseNode] The lower bound of the range. Can be an int, a constant or a statically resolvable BaseNode. .. py:attribute:: _upper_power :type: Union[int, Constant, m2isar.metamodel.behav.BaseNode] Obsolete, do not use .. py:attribute:: _lower_power :type: Union[int, Constant, m2isar.metamodel.behav.BaseNode] Obsolete, do not use .. py:property:: upper_power Returns the resolved upper bound power. .. py:property:: lower_power Returns the resolved lower bound power. .. py:property:: upper_base Returns the resolved upper bound base. .. py:property:: lower_base Returns the resolved lower bound base. .. py:property:: upper :type: Union[int, None] Returns the resolved upper power. .. py:property:: lower :type: int Returns the resolved lower power. .. py:property:: length Returns the length of the range using following algorithm: if self.upper is None: return None elif self.lower is None: return self.upper else return self.upper - self.lower + 1 .. py:method:: __str__() -> str .. py:class:: MemoryAttribute Bases: :py:obj:`enum.Enum` .. autoapi-inheritance-diagram:: m2isar.metamodel.arch.MemoryAttribute :parts: 1 :private-bases: Generic enumeration. Derive from this class to define new enumerations. .. py:attribute:: IS_PC .. py:attribute:: IS_MAIN_MEM .. py:attribute:: IS_MAIN_REG .. py:attribute:: DELETE .. py:attribute:: ETISS_CAN_FAIL .. py:attribute:: ETISS_IS_GLOBAL_IRQ_EN .. py:attribute:: ETISS_IS_IRQ_EN .. py:attribute:: ETISS_IS_IRQ_PENDING .. py:attribute:: ETISS_IS_PROCNO .. py:class:: ConstAttribute Bases: :py:obj:`enum.Enum` .. autoapi-inheritance-diagram:: m2isar.metamodel.arch.ConstAttribute :parts: 1 :private-bases: Generic enumeration. Derive from this class to define new enumerations. .. py:attribute:: IS_REG_WIDTH .. py:attribute:: IS_ADDR_WIDTH .. py:class:: InstrAttribute Bases: :py:obj:`enum.Enum` .. autoapi-inheritance-diagram:: m2isar.metamodel.arch.InstrAttribute :parts: 1 :private-bases: Generic enumeration. Derive from this class to define new enumerations. .. py:attribute:: NO_CONT .. py:attribute:: COND .. py:attribute:: FLUSH .. py:attribute:: SIM_EXIT .. py:attribute:: ENABLE .. py:attribute:: ETISS_ERROR_INSTRUCTION .. py:class:: FunctionAttribute Bases: :py:obj:`enum.Enum` .. autoapi-inheritance-diagram:: m2isar.metamodel.arch.FunctionAttribute :parts: 1 :private-bases: Generic enumeration. Derive from this class to define new enumerations. .. py:attribute:: ETISS_STATICFN .. py:attribute:: ETISS_NEEDS_ARCH .. py:attribute:: ETISS_TRAP_ENTRY_FN .. py:attribute:: ETISS_TRAP_TRANSLATE_FN .. py:class:: FunctionThrows Bases: :py:obj:`enum.IntEnum` .. autoapi-inheritance-diagram:: m2isar.metamodel.arch.FunctionThrows :parts: 1 :private-bases: Enum where members are also (and must be) ints .. py:attribute:: NO :value: 0 .. py:attribute:: YES :value: 1 .. py:attribute:: MAYBE :value: 2 .. py:class:: DataType Bases: :py:obj:`enum.Enum` .. autoapi-inheritance-diagram:: m2isar.metamodel.arch.DataType :parts: 1 :private-bases: Generic enumeration. Derive from this class to define new enumerations. .. py:attribute:: NONE .. py:attribute:: U .. py:attribute:: S .. py:attribute:: F .. py:attribute:: D .. py:attribute:: Q .. py:attribute:: B .. py:class:: DataType2(ptr) A datatype base class, only holds information on whether it is a pointer. .. py:attribute:: ptr :type: Any .. py:class:: VoidType(ptr) Bases: :py:obj:`DataType2` .. autoapi-inheritance-diagram:: m2isar.metamodel.arch.VoidType :parts: 1 :private-bases: A void datatype, automatically assumes native size. .. py:class:: IntegerType(width: Union[int, Constant, m2isar.metamodel.behav.BaseNode], signed: bool, ptr) Bases: :py:obj:`DataType2` .. autoapi-inheritance-diagram:: m2isar.metamodel.arch.IntegerType :parts: 1 :private-bases: An integer datatype with width and sign information. .. py:attribute:: _width :type: Union[int, Constant, m2isar.metamodel.behav.BaseNode] .. py:attribute:: signed :type: bool .. py:property:: width Returns the resolved width value. .. py:property:: actual_width Returns the resolved width value rounded to the nearest multiple of 8. .. py:class:: FnParam(name, size, data_type: DataType, width=1) Bases: :py:obj:`SizedRefOrConst` .. autoapi-inheritance-diagram:: m2isar.metamodel.arch.FnParam :parts: 1 :private-bases: A function parameter. .. py:attribute:: data_type :type: DataType .. py:attribute:: _width :type: Union[int, Constant, m2isar.metamodel.behav.BaseNode] The array width of this parameter. .. py:property:: width Returns the resolved array width value. .. py:method:: __str__() -> str .. py:class:: Scalar(name, value: int, static: bool, size, data_type: DataType) Bases: :py:obj:`SizedRefOrConst` .. autoapi-inheritance-diagram:: m2isar.metamodel.arch.Scalar :parts: 1 :private-bases: A scalar variable object, used mainly in behavior descriptions. .. py:attribute:: value :type: int .. py:attribute:: static :type: bool .. py:attribute:: data_type :type: DataType .. py:class:: Intrinsic(name, size: ValOrConst, data_type: DataType, value: int = None) Bases: :py:obj:`SizedRefOrConst` .. autoapi-inheritance-diagram:: m2isar.metamodel.arch.Intrinsic :parts: 1 :private-bases: 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. .. py:attribute:: value :type: int .. py:attribute:: data_type :type: DataType .. py:class:: Memory(name, range_: RangeSpec, size, attributes: dict[MemoryAttribute, list[BaseNode]]) Bases: :py:obj:`SizedRefOrConst` .. autoapi-inheritance-diagram:: m2isar.metamodel.arch.Memory :parts: 1 :private-bases: 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. .. py:attribute:: attributes :type: dict[MemoryAttribute, list[BaseNode]] .. py:attribute:: range :type: RangeSpec .. py:attribute:: children :type: list[Memory] .. py:attribute:: parent :type: Union[Memory, None] .. py:attribute:: _initval :type: dict[int, Union[int, Constant, BaseNode]] .. py:method:: initval(idx=None) Return the initial value for the given index. .. py:property:: data_range Returns a RangeSpec object with upper=range.upper-range.lower, lower=0. .. py:property:: is_pc Return true if this memory is tagged as being the program counter. .. py:property:: is_main_mem Return true if this memory is tagged as being the main memory array. .. py:class:: BitVal A class representing a fixed bit sequence in an instruction encoding. Modeled as length and integral value. .. py:attribute:: length :type: int .. py:attribute:: value :type: int .. py:class:: BitField(name, _range: RangeSpec, data_type: DataType) Bases: :py:obj:`Named` .. autoapi-inheritance-diagram:: m2isar.metamodel.arch.BitField :parts: 1 :private-bases: 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. .. py:attribute:: range :type: RangeSpec .. py:attribute:: data_type :type: DataType .. py:method:: __str__() -> str .. py:method:: __repr__() .. py:class:: BitFieldDescr(name, size: ValOrConst, data_type: DataType) Bases: :py:obj:`SizedRefOrConst` .. autoapi-inheritance-diagram:: m2isar.metamodel.arch.BitFieldDescr :parts: 1 :private-bases: A class representing a full instruction operand. Has no information about the actual bits it is composed of, for that use BitField. .. py:attribute:: data_type .. py:class:: Instruction(name, attributes: dict[InstrAttribute, list[BaseNode]], encoding: list[Union[BitField, BitVal]], mnemonic: str, assembly: str, operation: m2isar.metamodel.behav.Operation, function_info: m2isar.metamodel.code_info.FunctionInfo) Bases: :py:obj:`SizedRefOrConst` .. autoapi-inheritance-diagram:: m2isar.metamodel.arch.Instruction :parts: 1 :private-bases: A class representing an instruction. .. py:attribute:: attributes :type: dict[InstrAttribute, list[BaseNode]] .. py:attribute:: encoding :type: list[Union[BitField, BitVal]] .. py:attribute:: mnemonic :type: str .. py:attribute:: assembly :type: str .. py:attribute:: operation :type: m2isar.metamodel.behav.Operation .. py:attribute:: ext_name :type: str .. py:attribute:: fields :type: dict[str, BitFieldDescr] .. py:attribute:: scalars :type: dict[str, Scalar] .. py:attribute:: throws :type: bool .. py:attribute:: mask :type: int .. py:attribute:: code :type: int .. py:attribute:: function_info .. py:method:: __str__() -> str .. py: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) Bases: :py:obj:`SizedRefOrConst` .. autoapi-inheritance-diagram:: m2isar.metamodel.arch.Function :parts: 1 :private-bases: A class representing a function. .. py:attribute:: attributes :type: dict[FunctionAttribute, list[BaseNode]] .. py:attribute:: data_type :type: DataType .. py:attribute:: args :type: list[FnParam] .. py:attribute:: operation :type: m2isar.metamodel.behav.Operation .. py:attribute:: extern :type: bool .. py:attribute:: ext_name :type: str .. py:attribute:: scalars :type: dict[str, Scalar] .. py:attribute:: throws :type: bool .. py:attribute:: static :type: bool .. py:attribute:: function_info :value: None .. py:method:: __str__() -> str .. py:function:: extract_memory_alias(memories: list[Memory]) Extract and separate parent and children memories from the given list of memory objects. .. py:class:: AlwaysBlock(name: str, attributes, operation) Bases: :py:obj:`Named` .. autoapi-inheritance-diagram:: m2isar.metamodel.arch.AlwaysBlock :parts: 1 :private-bases: A simple base class for a named object. .. py:attribute:: attributes :type: dict[FunctionAttribute, list[BaseNode]] .. py:attribute:: operation :type: m2isar.metamodel.behav.Operation .. py:class:: InstructionSet(name, extension: list[str], constants: dict[str, Constant], memories: dict[str, Memory], functions: dict[str, Function], instructions: dict[tuple[int, int], Instruction]) Bases: :py:obj:`Named` .. autoapi-inheritance-diagram:: m2isar.metamodel.arch.InstructionSet :parts: 1 :private-bases: A class representing an InstructionSet collection. Bundles constants, memories, functions and instructions under a common name. .. py:attribute:: extension .. py:attribute:: constants .. py:attribute:: functions .. py:attribute:: instructions .. py: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]) Bases: :py:obj:`Named` .. autoapi-inheritance-diagram:: m2isar.metamodel.arch.CoreDef :parts: 1 :private-bases: A class representing an entire CPU core. Contains the collected attributes of multiple InstructionSets. .. py:attribute:: contributing_types .. py:attribute:: template .. py:attribute:: constants .. py:attribute:: memories .. py:attribute:: memory_aliases .. py:attribute:: functions .. py:attribute:: instructions .. py:attribute:: instr_classes .. py:attribute:: main_reg_file :value: None .. py:attribute:: main_memory :value: None .. py:attribute:: pc_memory :value: None .. py:attribute:: global_irq_en_memory :value: None .. py:attribute:: global_irq_en_mask :value: None .. py:attribute:: procno_memory :value: None .. py:attribute:: irq_en_memory :value: None .. py:attribute:: irq_pending_memory :value: None .. py:attribute:: intrinsics .. py:attribute:: instructions_by_ext .. py:attribute:: functions_by_ext .. py:attribute:: instructions_by_class