m2isar.metamodel

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 patch_model() function and a module including the needed transformations. 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 m2isar.metamodel.utils or the main code generation module m2isar.backends.etiss.instruction_transform. For a description of the monkey patching, see 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, 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.

Subpackages

Submodules

Attributes

M2_METAMODEL_VERSION

intrinsic_defs

intrinsics

Classes

M2Model

Functions

patch_model(module)

Monkey patch transformation functions inside module

Package Contents

M2_METAMODEL_VERSION = 2[source]
patch_model(module)[source]

Monkey patch transformation functions inside module into m2isar.metamodel.behav classes

Transformation functions must have a specific signature for this to work:

def transform(self: <behav Class>, context: Any)

where <behav Class> is the class in 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.

intrinsic_defs[source]
intrinsics[source]
class M2Model[source]
model_version: int[source]
models: dict[str, arch.CoreDef][source]
code_infos: dict[int, code_info.CodeInfoBase][source]
__post_init__()[source]