m2isar.metamodel ================ .. py:module:: m2isar.metamodel .. autoapi-nested-parse:: This module contains the M2-ISA-R metamodel classes to build an ISA from. The M2-ISA-R metamodel is split into two submodules, one for architectural description, one for the behavioral description. Also included are preprocessing functions, mostly to simplify a model and to extract information about scalar and function staticness as well as exceptions. Any model traversal should use the :func:`patch_model` function and a module including the needed transformations. :func:`patch_model` monkey patches transformation functions into the classes of the behavior model, therefore separating model code from transformation code. For examples on how these transformation functions look like, see either the modules in :mod:`m2isar.metamodel.utils` or the main code generation module :mod:`m2isar.backends.etiss.instruction_transform`. For a description of the monkey patching, see :func:`patch_model`. Usually a M2-ISA-R behavioral model is traversed from top to bottom. Necessary contextual information is passed to lower levels by a user-defined `context` object. Each object should then generate a piece of output (e.g. c-code for ETISS) and return it to its parent. Value passing between generation functions is completely user-defined, :mod:`m2isar.backends.etiss.instruction_transform` uses complex objects in lower levels of translation and switches to strings for the two highest levels of the hierarchy. Submodules ---------- .. toctree:: :maxdepth: 1 /autoapi/m2isar/metamodel/arch/index /autoapi/m2isar/metamodel/behav/index /autoapi/m2isar/metamodel/code_info/index /autoapi/m2isar/metamodel/utils/index Attributes ---------- .. autoapisummary:: m2isar.metamodel.M2_METAMODEL_VERSION m2isar.metamodel.intrinsic_defs m2isar.metamodel.intrinsics Classes ------- .. autoapisummary:: m2isar.metamodel.M2Model Functions --------- .. autoapisummary:: m2isar.metamodel.patch_model Package Contents ---------------- .. py:data:: M2_METAMODEL_VERSION :value: 2 .. py:function:: patch_model(module) Monkey patch transformation functions inside `module` into :mod:`m2isar.metamodel.behav` classes Transformation functions must have a specific signature for this to work: `def transform(self: , context: Any)` where `` is the class in :mod:`m2isar.metamodel.behav` which this transformation is associated with. Context can be any user-defined object to keep track of additional contextual information, if needed. .. py:data:: intrinsic_defs .. py:data:: intrinsics .. py:class:: M2Model .. py:attribute:: model_version :type: int .. py:attribute:: cores :type: dict[str, arch.CoreDef] .. py:attribute:: sets :type: dict[str, arch.InstructionSet] .. py:attribute:: code_infos :type: dict[int, code_info.CodeInfoBase] .. py:method:: __post_init__()