Motorola HC12 Refrence Manual page 314

Table of Contents

Advertisement

9.5.1 Unweighted Rule Evaluation (REV)
This instruction implements basic min-max rule evaluation. CPU registers are used for
pointers and intermediate calculation results.
Since the REV instruction is essentially a list-processing instruction, execution time is
dependent on the number of elements in the rule list. The REV instruction is interrupt-
ible (typically within three bus cycles), so it does not adversely affect worst case inter-
rupt latency. Since all intermediate results and instruction status are held in stacked
CPU registers, the interrupt service code can even include independent REV and
REVW instructions.
9.5.1.1 Set Up Prior to Executing REV
Some CPU registers and memory locations need to be set up prior to executing the
REV instruction. X and Y index registers are used as index pointers to the rule list and
the fuzzy inputs and outputs. The A accumulator is used for intermediate calculation
results and needs to be set to $FF initially. The V condition code bit is used as an in-
struction status indicator to show whether antecedents or consequents are being pro-
cessed. Initially, the V bit is cleared to zero to indicate antecedents are being
processed. The fuzzy outputs (working RAM locations) need to be cleared to $00. If
these values are not initialized before executing the REV instruction, results will be er-
roneous.
The X index register is set to the address of the first element in the rule list (in the
knowledge base). The REV instruction automatically updates this pointer so that the
instruction can resume correctly if it is interrupted. After the REV instruction finishes,
X will point at the next address past the $FF separator character that marks the end
of the rule list.
The Y index register is set to the base address for the fuzzy inputs and outputs (in
working RAM). Each rule antecedent is an unsigned 8-bit offset from this base address
to the referenced fuzzy input. Each rule consequent is an unsigned 8-bit offset from
this base address to the referenced fuzzy output. The Y index register remains con-
stant throughout execution of the REV instruction.
The 8-bit A accumulator is used to hold intermediate calculation results during execu-
tion of the REV instruction. During antecedent processing, A starts out at $FF and is
replaced by any smaller fuzzy input that is referenced by a rule antecedent (MIN). Dur-
ing consequent processing, A holds the truth value for the rule. This truth value is
stored to any fuzzy output that is referenced by a rule consequent, unless that fuzzy
output is already larger (MAX).
Before starting to execute REV, A must be set to $FF (the largest 8-bit value) because
rule evaluation always starts with processing of the antecedents of the first rule. For
subsequent rules in the list, A is automatically set to $FF when the instruction detects
the $FE marker character between the last consequent of the previous rule, and the
first antecedent of a new rule.
MOTOROLA
9-14
FUZZY LOGIC SUPPORT
CPU12
REFERENCE MANUAL

Advertisement

Table of Contents
loading

This manual is also suitable for:

Cpu12

Table of Contents