Creating and modifying a reference nv or cp type, Creating and modifying a reference, Nv or cp type – Echelon NodeBuilder Resource Editor User Manual

Page 42

Advertising
background image

Size

The size of the bitfield, in bits, from 1 to 8. The

bitfield size determines the maximum value the
field can contain. An unsigned bitfield of W bits

width can accept values 0..2

W

-1, a signed bitfield

of width W can hold values -2

W/2

..+2

W/2

-1

Offset

The offset of the bitfield within the byte. A full
byte is always required regardless of how many

bits in the bitfield are used. This value
determines where in the byte the values will be
set. This value can be from 0 to (8 – Size).

Signed/Unsigned

Specifies a signed or unsigned value. An unsigned

bitfield can only contain positive values. A signed
bitfield can contain positive or negative values

with negative numbers values stored using twos

complement notation. Twos complement notation
is created by converting the number to binary,

complementing each bit, and adding 1 to the

resultant binary number.

A signed bitfield with a width of 1 can contain

only two values: -1 (minus one) and 0 (zero). This

is often unwanted; the developer is likely to
require an unsigned bitfield of the same width,

accepting 0 (zero) and +1 (plus one). The use of

unsigned bitfields is recommended due to a
slightly better performance on the Neuron Chip,

but also in order to avoid the common mistake of

declaring bitfields with a width of one bit as
signed.

Unlike the ANSI-C and Neuron C programming languages, resource files do not support

anonymous bitfields (bitfields that are declared with signedness and width, but without a
name, e.g. int : 3;) or bitfields with a width of 0. To control the positioning of a
bitfield within the compound byte, set the offset value accordingly. If the Resource

Editor detects a gap between bitfields, it will display a warning describing the situation
and offer to leave the gap intact, or to close the gap by adjusting the offset preferences

accordingly. Do not allow automatic adjustment if you have purposefully laid out the

bitfields to match some specific requirement.

Creating and Modifying a Reference NV or CP Type

Network variable types, configuration property types, and fields within structure or

union types can be based on existing network variable types (but not configuration
property types) that are defined within the same resource file, within the standard

resource file, or within any other resource file that has a compatible program ID

template and scope selector. When this is done, if the referenced type changes in some
way (type size, fields, etc), any configuration property and network variable types that

reference it will automatically be changed as well. To create a type based on an existing

type, follow these steps:
1. Create a new type as described in Creating and Modifying a Network Variable or

Configuration Property Type. In step 3, set Data Type to reference. Reference
Information
appears in the dialog as shown in the following figure:

34

Creating and Modifying Resources

Advertising