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 a :subclass`` of the ExprVisitor MetaClass including the needed
transformations/ recursive calls. For examples on how the recursive generate functions look like,
see the ExprVisitor MetaClass with its default generate function in m2isar.metamodel.utils.ExprVisitor
Multiple examples of such visitors can be found in the m2isar.backends submodules,
e.g. m2isar.backends.etiss.instruction_transform or m2isar.backends.isa_manual.visitor.
But also the metamodel builders in m2isar.frontends.coredsl2 use this approach to build
the model from the parse tree. As well as the Frontend.
Usually a M2-ISA-R behavioral model is traversed from top to bottom. Necessary contextual
information is either stored globally within the self object of the ExprVisitor or passed to lower levels
by a user-defined context object for local stack-based information. 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.
Submodules
Attributes
Classes
Functions
|
Monkey patch transformation functions inside module |
|
|
|
Package Contents
- patch_model(module)[source]
Monkey patch transformation functions inside module into
m2isar.metamodel.behavclassesTransformation 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.behavwhich this transformation is associated with. Context can be any user-defined object to keep track of additional contextual information, if needed.