DOCA0275EN-00

Computation Blocks

Overview

The FBD editor uses various computation blocks accessible through the Computation bar in the Toolbox:

Block

Description

Compare

Add

Division

Multiplication

Subtraction

NOTE: Placing cursor over the icon will reveal a tool tip defining the icon. This will help you distinguish which type of block is represented by that icon.

Compare Block

The block compares two 16-bit register values.

FBD symbol

Arguments

Description

Inputs

  • X: 16-bit unsigned register value (0 to 65,535).

  • Y: 16-bit unsigned register value (0 to 65,535).

Outputs

  • X < Y: ON/OFF temporary bit that is ON if the value X is less than the value Y.

  • X = Y: ON/OFF temporary bit that is ON if the value X is equal to the value Y.

  • X > Y: ON/OFF temporary bit that is ON if the value X is greater than the value Y.

Add Block

The block performs an unsigned addition of two 16-bit register values.

FBD symbol

Arguments or Example

Description

Inputs

  • X: 16-bit unsigned register value (0 to 65,535).

  • Y: 16-bit unsigned register value (0 to 65,535).

Outputs

  • Z: 16-bit unsigned register result (Z = X + Y).

  • Overflow: ON or OFF value which when set ON caries a value of 65,536. The value is initialized to OFF.

Example

Assuming X = 60,000 and Y = 7,000, the overflow will be ON because 60,000 + 7,000 = 67,000, which is superior to 65,536. The result Z is then equal to 1,464 (1,464 + 65,356 = 67,000).

Subtraction Block

The block performs an unsigned subtraction of two 16-bit register values.

FBD symbol

Arguments or Example

Description

Inputs

  • X: 16-bit unsigned register value (0 to 65,535).

  • Y: 16-bit unsigned register value (0 to 65,535).

Outputs

  • Z: 16-bit unsigned register result (Z = X – Y).

  • Underflow: ON or OFF value, which when set ON, caries a value of negative 65,536. The value is initialized to OFF.

Example

Assuming X = 5 and Y = 10, the underflow will be ON because the result is negative. The result Z is then equal to 65,531 (65,531 – 65,536 = –5)

Multiplication Block

The block performs an unsigned multiplication of two 16-bit register values.

FBD symbol

Arguments or Example

Description

Inputs

  • X: 16-bit unsigned register value (0 to 65,535)

  • Y: 16-bit unsigned register value (0 to 65,535)

Outputs

  • Z(h): 16 most significant bits of the 32-bit result,

    Z(h) = (X * Y) / 65,536

  • Z(l): 16 least significant bits of the 32-bit result,

    Z(l) = (X * Y) – Z(h) * 65,536

Example

Assuming X = 20,000 and Y = 10, the result will be Z(h) = 3 and Z(l) = 3,392 because 200,000 = 3 * 65,536 + 3,392

Division Block

The block performs an unsigned division of two 16-bit register values.

FBD symbol

Arguments or Example

Description

Inputs

  • X(h): 16 most significant bits of an unsigned register value (0 to 65,535).

  • X(l): 16 least significant bits of an unsigned register value (0 to 65,535).

  • Y: 16-bit unsigned register divisor (0–65,535).

Outputs

  • Z(h): 16 most significant bits of the 32-bit quotient,

    Z(h) = (X / Y) / 65,536

  • Z(l): 16 least significant bits of the 32-bit quotient,

    Z(l) = (X / Y) – Z(h) * 65,536

  • Detected Error: ON or OFF value, which is set ON when a division by zero occurs. This value is initialized to OFF.

Example

Assuming X(h) = 3, X(l) = 3,392 and Y = 40, the result will be Z(h) = 0 and Z(l) = 5,000 because X(h) * 65,536 + X(l) = 3 * 65,536 + 3,392 = 200,000 and 200,000 /Y = 5,000 = 0 * 65,536 + 5,000

QR Code is a registered trademark of DENSO WAVE INCORPORATED in Japan and other countries.

Was this helpful?