Motorola HC12 Refrence Manual page 319

Table of Contents

Advertisement

9.5.2.1 Set Up Prior to Executing REVW
Some CPU registers and memory locations need to be set up prior to executing the
REVW instruction. X and Y index registers are used as index pointers to the rule list
and the list of rule weights. The A accumulator is used for intermediate calculation re-
sults and needs to be set to $FF initially. The V condition code bit is used as an instruc-
tion status indicator that shows whether antecedents or consequents are being
processed. Initially the V bit is cleared to zero to indicate antecedents are being pro-
cessed. The C condition code bit is used to indicate whether rule weights are to be
used (1) or not (0). The fuzzy outputs (working RAM locations) need to be cleared to
$00. If these values are not initialized before executing the REVW instruction, results
will be erroneous.
The X index register is set to the address of the first element in the rule list (in the
knowledge base). The REVW instruction automatically updates this pointer so that the
instruction can resume correctly if it is interrupted. After the REVW instruction finishes,
X will point at the next address past the $FFFF separator word that marks the end of
the rule list.
The Y index register is set to the starting address of the list of rule weights. Each rule
weight is an 8-bit value. The weighted result is the truncated upper eight bits of the 16-
bit result, which is derived by multiplying the minimum rule antecedent value ($00–
$FF) by the weight plus one ($001–$100). This method of weighting rules allows an 8-
bit weighting factor to represent a value between zero and one inclusive.
The 8-bit A accumulator is used to hold intermediate calculation results during execu-
tion of the REVW instruction. During antecedent processing, A starts out at $FF and
is replaced by any smaller fuzzy input that is referenced by a rule antecedent. If rule
weights are enabled by the C condition code bit equal one, the rule truth value is mul-
tiplied by the rule weight just before consequent processing starts. During consequent
processing, A holds the truth value (possibly weighted) 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 REVW, A must be set to $FF (the largest 8-bit value) be-
cause 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 de-
tects the $FFFE marker word between the last consequent of the previous rule, and
the first antecedent of a new rule.
Both the C and V condition code bits must be set up prior to starting a REVW instruc-
tion. Once the REVW instruction starts, the C bit remains constant and the value in the
V bit is automatically maintained as $FFFE separator words are detected.
The final requirement to clear all fuzzy outputs to $00 is part of the MAX algorithm.
Each time a rule consequent references a fuzzy output, that fuzzy output is compared
to the truth value (weighted) for the current rule. If the current truth value is larger, it is
written over the previous value in the fuzzy output. After all rules have been evaluated,
the fuzzy output contains the truth value for the most-true rule that referenced that
fuzzy output.
CPU12
REFERENCE MANUAL
FUZZY LOGIC SUPPORT
MOTOROLA
9-19

Advertisement

Table of Contents
loading

This manual is also suitable for:

Cpu12

Table of Contents