Math Logic Commands
Overview
The custom logic editor uses the following math commands:
-
ON_ADD
-
ON_SUB
-
ON_MUL
-
ON_DIV
ON_ADD
The ON_ADD
command performs unsigned addition when the 1-bit accumulator transitions
from 0 to 1. It adds the value from Argument 1 to the 16-bit accumulator
value, then posts the result back to the value in Argument 1.
Status register:
-
Indicates an overflow if the result of the addition process exceeds 65,535
-
Indicates the status of the 1-bit-accumulator from the previous scan
Arguments |
Representation |
---|---|
2 |
|
Input Argument |
Type |
Range/Bit |
Description |
---|---|---|---|
|
|
0–65,535 |
Value to add to the 16-bit accumulator |
Output Argument |
Type |
Range/Bit |
Description |
---|---|---|---|
|
|
0–65,535 |
Result of the addition operation |
|
|
Bit0 |
Overflow: the result of the addition is greater than 65,535. In this case, the result of the addition is equal to Argument 1 + 65,536. |
Bit3 |
1-bit accumulator history bit |
ON_SUB
The ON_SUB
command performs unsigned subtraction when the 1-bit accumulator
transitions from 0 to 1. It subtracts the 16-bit accumulator value
from the value in Argument 1, then posts the result back to the value
in Argument 1.
Status register:
-
Indicates an underflow if the result of the subtraction process is less than 0
-
Indicates the status of the 1-bit-accumulator from the previous scan
Arguments |
Representation |
---|---|
2 |
|
Input Argument |
Type |
Range/Bit |
Description |
---|---|---|---|
|
|
0–65,535 |
Value to subtract from the 16-bit accumulator |
Output Argument |
Type |
Range/Bit |
Description |
---|---|---|---|
|
|
0–65,535 |
Result of the subtraction operation |
|
|
Bit0 |
Underflow: the result of the subtraction is less than 0. In this case, the true result of the operation equals the value output to Argument 1 - 65,536. |
Bit3 |
1-bit accumulator history bit |
ON_MUL
The ON_MUL
command performs unsigned multiplication when the 1-bit accumulator
transitions from 0 to 1. The ON_MUL
procedure multiplies the value from Argument 2 against the 16-bit
accumulator value, then posts the result back to Argument 1 (most
significant word) and Argument 2 (least significant word).
Status register indicates the status of the 1-bit accumulator from the previous scan.
Arguments |
Representation |
---|---|
3 |
|
Input Argument |
Type |
Range/Bit |
Description |
---|---|---|---|
|
|
0–65,535 |
Value to be multiply with the 16-bit accumulator |
Output Argument |
Type |
Range/Bit |
Description |
---|---|---|---|
|
|
0–65,535 |
Result of the multiplication operation:
|
|
|
Bit3 |
1-bit accumulator history bit |
ON_DIV
The ON_DIV
command performs unsigned division
when the 1-bit accumulator transitions from 0 to 1. The ON_DIV
procedure divides the combined value
of Argument 1 and Argument 2 by the 16-bit accumulator value, then
posts the result back to Argument 1 (most significant word) and Argument
2 (least significant word).
Status register indicates:
-
An overflow if division is by 0
-
The status of the 1-bit accumulator from the previous scan
Arguments |
Representation |
---|---|
3 |
|
Input Argument |
Type |
Range/Bit |
Description |
---|---|---|---|
|
|
0–65,535 |
Value to be divided by the 16-bit accumulator |
Output Argument |
Type |
Range/Bit |
Description |
---|---|---|---|
|
|
0–65,535 |
Result of the division operation:
|
|
|
Bit0 |
Division by 0 |
Bit3 |
1-bit accumulator history bit |