MC decoder model specification

Decoders

class mcdecoder.core.McDecoder(namespace: str | None, namespace_prefix: str, machine: MachineDecoder, instructions: List[InstructionDecoder], decision_trees: List[McdDecisionTree], extras: Any | None)

Bases: object

Decoder itself. The root model element of MC decoder model

decision_trees: List[McdDecisionTree]

Child McdDecisionTrees

extras: Any | None

User-defined data not related to a machine, an instruction and a field

property instruction_decoders: List[InstructionDecoder]

Child InstructionDecoders

Deprecated since version 0.1a6: This will be removed in 1.0. Use instructions instead

instructions: List[InstructionDecoder]

Child InstructionDecoders

machine: MachineDecoder

Child MachineDecoder

property machine_decoder: MachineDecoder

Child MachineDecoder

Deprecated since version 0.1a6: This will be removed in 1.0. Use machine instead

namespace: str | None

Namespace of generated codes

namespace_prefix: str

Namespace prefix of generated codes

class mcdecoder.core.MachineDecoder(byteorder: Literal['big', 'little'], extras: Any | None)

Bases: object

Decoder for a machine

byteorder: Literal['big', 'little']

Byte order of a machine

extras: Any | None

User-defined data for a machine

class mcdecoder.core.InstructionDecoder(name: str, encoding_element_bit_length: int, length_of_encoding_elements: int, fixed_bit_mask: int, fixed_bits: int, type_bit_length: int, match_condition: InstructionDecoderCondition | None, unmatch_condition: InstructionDecoderCondition | None, fields: List[InstructionFieldDecoder], extras: Any | None, _encoding: str)

Bases: object

Decoder for an instruction

encoding_element_bit_length: int

Bit length of an encoding element

extras: Any | None

User-defined data for an instruction

property field_decoders: List[InstructionFieldDecoder]

Child InstructionFieldDecoders

Deprecated since version 0.1a6: This will be removed in 1.0. Use fields instead

fields: List[InstructionFieldDecoder]

Child InstructionFieldDecoders

fixed_bit_mask: int

Mask of fixed bit positions of an instruction

fixed_bits: int

Fixed bits of an instruction

property fixed_bits_mask: int

Mask of fixed bit positions of an instruction

Deprecated since version 0.1a6: This will be removed in 1.0. Use fixed_bit_mask instead

length_of_encoding_elements: int

Length of encoding elements

match_condition: InstructionDecoderCondition | None

Condition an instruction must satisfy

name: str

Name of an instruction

type_bit_length: int

Bit length of a data type used for an instruction

property type_bit_size: int

Bit length of a data type used for an instruction

Deprecated since version 0.1a6: This will be removed in 1.0. Use type_bit_length instead

unmatch_condition: InstructionDecoderCondition | None

Condition an instruction must not satisfy

class mcdecoder.core.InstructionFieldDecoder(name: str, type_bit_length: int, subfields: List[InstructionSubfieldDecoder], extras: Any | None, _msb: int)

Bases: object

Decoder for an instruction field

extras: Any | None

User-defined data for a field

name: str

Name of a field

property subfield_decoders: List[InstructionSubfieldDecoder]

Child InstructionSubfieldDecoders

Deprecated since version 0.1a6: This will be removed in 1.0. Use subfields instead

subfields: List[InstructionSubfieldDecoder]

Child InstructionSubfieldDecoders

type_bit_length: int

Bit length of a data type used for a field

property type_bit_size: int

Bit length of a data type used for a field

Deprecated since version 0.1a6: This will be removed in 1.0. Use type_bit_length instead

class mcdecoder.core.InstructionSubfieldDecoder(index: int, mask: int, msb_in_instruction: int, lsb_in_instruction: int, lsb_in_field: int)

Bases: object

Decoder for an instruction subfield

property end_bit_in_field: int

LSB of a subfield in a field

Deprecated since version 0.1a6: This will be removed in 1.0. Use lsb_in_field instead

property end_bit_in_instruction: int

LSB of a subfield in an instruction

Deprecated since version 0.1a6: This will be removed in 1.0. Use lsb_in_instruction instead

index: int

Index number of a subfield in a field: 0th to (n-1)th

lsb_in_field: int

LSB of a subfield in a field

lsb_in_instruction: int

LSB of a subfield in an instruction

mask: int

Mask of a subfield in an instruction

msb_in_instruction: int

MSB of a subfield in an instruction

property start_bit_in_instruction: int

MSB of a subfield in an instruction

Deprecated since version 0.1a6: This will be removed in 1.0. Use msb_in_instruction instead

Conditions

class mcdecoder.core.InstructionDecoderCondition

Bases: object

Condition of instruction encoding when an instruction applys.

Each subclass must have a string attribute ‘type’ to express the type of a subclass.

abstract property type: str

Type of InstructionDecoderCondition

class mcdecoder.core.AndIdCondition(conditions: List[InstructionDecoderCondition])

Bases: InstructionDecoderCondition

‘and’ condition subclass for InstructionDecoderCondition to combine conditions with AND operator

conditions: List[InstructionDecoderCondition]

Child InstructionDecoderConditions combined with logical AND operation

property type: str

Type of InstructionDecoderCondition. It’s always ‘and’ for AndIdCondition

class mcdecoder.core.OrIdCondition(conditions: List[InstructionDecoderCondition])

Bases: InstructionDecoderCondition

‘or’ condition subclass for InstructionDecoderCondition to combine conditions with OR operator

conditions: List[InstructionDecoderCondition]

Child InstructionDecoderConditions combined with logical OR operation

property type: str

Type of InstructionDecoderCondition. It’s always ‘or’ for OrIdCondition

class mcdecoder.core.EqualityIdCondition(subject: InstructionDecoderConditionObject, operator: str, object: InstructionDecoderConditionObject)

Bases: InstructionDecoderCondition

Equality condition subclass for InstructionDecoderCondition to test a field value’s equality with a value.

Supported operators are ==, !=, >, >=, < and <=.

object: InstructionDecoderConditionObject

Objective InstructionDecoderConditionObject to test with

operator: str

Operator to test

subject: InstructionDecoderConditionObject

Subjective InstructionDecoderConditionObject to be tested

property type: str

Type of InstructionDecoderCondition. It’s always ‘equality’ for EqualityIdCondition

class mcdecoder.core.InIdCondition(subject: InstructionDecoderConditionObject, values: List[int])

Bases: InstructionDecoderCondition

‘in’ condition subclass for InstructionDecoderCondition to test an instruction field is in a value set

subject: InstructionDecoderConditionObject

Subjective InstructionDecoderConditionObject to be tested

property type: str

Type of InstructionDecoderCondition. It’s always ‘in’ for InIdCondition

values: List[int]

Value set a field must be in

class mcdecoder.core.InRangeIdCondition(subject: InstructionDecoderConditionObject, value_start: int, value_end: int)

Bases: InstructionDecoderCondition

‘in_range’ condition subclass for InstructionDecoderCondition to test an instruction field is in a value range(inclusive)

subject: InstructionDecoderConditionObject

Subjective InstructionDecoderConditionObject to be tested

property type: str

Type of InstructionDecoderCondition. It’s always ‘in_range’ for InRangeIdCondition

value_end: int

End of a value range a field must be in

value_start: int

Start of a value range a field must be in

class mcdecoder.core.InstructionDecoderConditionObject

Bases: object

Object or subject of InstructionDecoderCondition.

Each subclass must have a string attribute ‘type’ to express the type of a subclass.

abstract property type: str

Type of InstructionDecoderConditionObject

class mcdecoder.core.FieldIdConditionObject(field: str, element_index: int | None)

Bases: InstructionDecoderConditionObject

Field object/subject subclass for InstructionDecoderConditionObject

element_index: int | None

Bit element index of a field to be tested

field: str

Name of a field to be tested

property type: str

Type of InstructionDecoderConditionObject. It’s always ‘field’ for FieldIdConditionObject

class mcdecoder.core.ImmediateIdConditionObject(value: int)

Bases: InstructionDecoderConditionObject

Immediate value object/subject subclass for InstructionDecoderConditionObject

property type: str

Type of InstructionDecoderConditionObject. It’s always ‘immediate’ for ImmediateIdConditionObject

value: int

Value to be tested

class mcdecoder.core.FunctionIdConditionObject(function: str, argument: FieldIdConditionObject)

Bases: InstructionDecoderConditionObject

Uses the result of a function call as an object/subject. It is a subclass for InstructionDecoderConditionObject

argument: FieldIdConditionObject

Argument FieldIdConditionObject

function: str

Name of a function to be called

property type: str

Type of InstructionDecoderConditionObject. It’s always ‘function’ for FunctionIdConditionObject

Decision tree

class mcdecoder.core.McdDecisionTree(encoding_element_bit_length: int, length_of_encoding_elements: int, root_node: McdDecisionNode)

Bases: object

Decision tree to find a matched instruction for a code

encoding_element_bit_length: int

Bit length of an encoding element

length_of_encoding_elements: int

Length of encoding elements

root_node: McdDecisionNode

Root node of a decision tree

class mcdecoder.core.McdDecisionNode(index: int, mask: int, fixed_bit_nodes: Dict[int, McdDecisionNode], arbitrary_bit_node: McdDecisionNode | None, instructions: List[InstructionDecoder])

Bases: object

Node of a McdDecisionTree.

It has two types of child nodes:

  • Fixed bit node: A node related to fixed bits. It is decided by a threshold value.

  • Arbitrary bit node: A node related to arbitrary bits. It isn’t decided by a threshold value and pass through to the node.

property all_nodes: Iterable[McdDecisionNode]

This node and its descendants.

The nodes are ordered in the way of depth-first search.

arbitrary_bit_node: McdDecisionNode | None

Arbitrary bit McdDecisionNode

fixed_bit_nodes: Dict[int, McdDecisionNode]

Dictionary of a threshold value and its fixed bit McdDecisionNode

index: int

Index number of a node in a tree

instructions: List[InstructionDecoder]

Instructions decided by a node

mask: int

Mask of threshold bit positions