CPU12
FUZZY LOGIC SUPPORT
MOTOROLA
REFERENCE MANUAL
9-7
Where n is the number of labels of a system output, S
i
are the singleton positions from
the knowledge base, and F
i
are fuzzy outputs from RAM. For a common fuzzy logic
program on the CPU12, n is eight or less (though this instruction can handle any value
to 255) and S
i
and F
i
are 8-bit values. The final divide is performed with a separate
EDIV instruction placed immediately after the WAV instruction.
Before executing WAV, an accumulator must be loaded with the number of iterations
(n), one index register must be pointed at the list of singleton positions in the knowl-
edge base, and a second index register must be pointed at the list of fuzzy outputs in
RAM. If the system has more than one system output, the WAV instruction is executed
once for each system output.
9.3 Example Inference Kernel
is a complete fuzzy inference kernel written in CPU12 assembly language.
Numbers in square brackets are cycle counts. The kernel uses two system inputs with
seven labels each and one system output with seven labels. The program assembles
to 57 bytes. It executes in about 54
µ
s at an 8 MHz bus rate. The basic structure can
easily be extended to a general-purpose system with a larger number of inputs and
outputs.
Lines 1 to 3 set up pointers and load the system input value into the A accumulator.
Line 4 sets the loop count for the loop in lines 5 and 6.
Lines 5 and 6 make up the fuzzification loop for seven labels of one system input. The
MEM instruction finds the y-value on a trapezoidal membership function for the current
input value, for one label of the current input, and then stores the result to the corre-
sponding fuzzy input. Pointers in X and Y are automatically updated by four and one
so they point at the next membership function and fuzzy input respectively.
Line 7 loads the current value of the next system input. Pointers in X and Y already
point to the right places as a result of the automatic update function of the MEM in-
struction in line 5.
Line 8 reloads a loop count.
Lines 9 and 10 form a loop to fuzzify the seven labels of the second system input.
When the program drops to line 11, the Y index register is pointing at the next location
after the last fuzzy input, which is the first fuzzy output in this system.
System Output
S
i
F
i
i
1
=
n
∑
F
i
i
1
=
n
∑
----------------------
=
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: ......