MOTOROLA
FUZZY LOGIC SUPPORT
CPU12
9-8
REFERENCE MANUAL
Figure 9-3 Fuzzy Inference Engine
Line 11 sets the loop count to clear seven fuzzy outputs.
Lines 12 and 13 form a loop to clear all fuzzy outputs before rule evaluation starts.
Line 14 initializes the X index register to point at the first element in the rule list for the
REV instruction.
Line 15 initializes the Y index register to point at the fuzzy inputs and outputs in the
system. The rule list (for REV) consists of 8-bit offsets from this base address to par-
ticular fuzzy inputs or fuzzy outputs. The special value $FE is interpreted by REV as a
marker between rule antecedents and consequents.
Line 16 initializes the A accumulator to the highest 8-bit value in preparation for finding
the smallest fuzzy input referenced by a rule antecedent. The LDAA #$FF instruction
also clears the V-bit in the CPU12’s condition code register so the REV instruction
knows it is processing antecedents. During rule list processing, the V bit is toggled
each time an $FE is detected in the list. The V bit indicates whether REV is processing
antecedents or consequents.
Line 17 is the REV instruction, a self-contained loop to process successive elements
in the rule list until an $FF character is found. For a system of 17 rules with two ante-
cedents and one consequent each, the REV instruction takes 259 cycles, but it is in-
terruptible so it does not cause a long interrupt latency.
*
01 [2]
FUZZIFY
LDX
#INPUT_MFS
;Point at MF definitions
02 [2]
LDY
#FUZ_INS
;Point at fuzzy input table
03 [3]
LDAA
CURRENT_INS
;Get first input value
04 [1]
LDAB
#7
;7 labels per input
05 [5]
GRAD_LOOP
MEM
;Evaluate one MF
06 [3]
DBNE
B,GRAD_LOOP
;For 7 labels of 1 input
07 [3]
LDAA
CURR1
;Get second input value
08 [1]
LDAB
#7
;7 labels per input
09 [5]
GRAD_LOOP1
MEM
;Evaluate one MF
10 [3]
DBNE
B,GRAD_LOOP1
;For 7 labels of 1 input
11 [1]
LDAB
#7
;Loop count
12 [2]
RULE_EVAL
CLR
1,Y+
;Clr a fuzzy out & inc ptr
13 [3]
DBNE
b,RULE_EVAL
;Loop to clr all fuzzy outs
14 [2]
LDX
#RULE_START
;Point at first rule element
15 [2]
LDY
#FUZ_INS
;Point at fuzzy ins and outs
16 [1]
LDAA
#$FF
;Init A (and clears V-bit)
17 [3n+4]
REV
;Process rule list
18 [2]
DEFUZ
LDY
#FUZ_OUT
;Point at fuzzy outputs
19 [1]
LDX
#SGLTN_POS
;Point at singleton positions
20 [1]
LDAB
#7
;7 fuzzy outs per COG output
21 [8b+9]
WAV
;Calculate sums for wtd av
22 [11]
EDIV
;Final divide for wtd av
23 [1]
TFR
Y D
;Move result to A:B
24 [3]
STAB
COG_OUT
;Store system output
*
***** End
Summary of Contents for CPU12
Page 8: ...MOTOROLA CPU12 viii REFERENCE MANUAL ...
Page 14: ...MOTOROLA INTRODUCTION CPU12 1 4 REFERENCE MANUAL ...
Page 20: ...MOTOROLA OVERVIEW CPU12 2 6 REFERENCE MANUAL ...
Page 38: ...MOTOROLA INSTRUCTION QUEUE CPU12 4 6 REFERENCE MANUAL ...
Page 300: ...MOTOROLA DEVELOPMENT AND DEBUG SUPPORT CPU12 8 16 REFERENCE MANUAL ...
Page 338: ...MOTOROLA MEMORY EXPANSION CPU12 10 8 REFERENCE MANUAL ...
Page 364: ...MOTOROLA INSTRUCTION REFERENCE CPU12 A 26 REFERENCE MANUAL ...
Page 386: ...MOTOROLA HIGH LEVEL LANGUAGE SUPPORT CPU12 C 6 REFERENCE MANUAL ...
Page 438: ...MOTOROLA SUMMARY OF CHANGES CPU12 S 2 REFERENCE MANUAL ...
Page 439: ......