Main Content

ufi

(Not recommended) Construct unsigned fixed-point numeric object

ufi is not recommended. Use fi instead.

Description

a = ufi is the default constructor and returns an unsigned fi object with no value, 16-bit word length, and 15-bit fraction length.

The fi object created by the ufi constructor function has data properties, fimath properties, and numerictype properties. These properties are described in detail in fi Properties, fimath Properties and numerictype Properties.

The fi object created by the ufi constructor function has no local fimath object. You can attach a fimath object to that fi object if you do not want to use the default fimath settings. For more information, see fimath Object Construction.

a = ufi(v) returns an unsigned fixed-point object with value v, 16-bit word length, and best-precision fraction length. Best-precision is when the fraction length is set automatically to accommodate the value v for the given word length.

example

a = ufi(v,w) returns an unsigned fixed-point object with value v, word length w, and best-precision fraction length.

example

a = ufi(v,w,f) returns an unsigned fixed-point object with value v, word length w, and fraction length f.

example

a = ufi(v,w,slope,bias) returns an unsigned fixed-point object with value v, word length w, slope, and bias.

a = ufi(v,w,slopeadjustmentfactor,fixedexponent,bias) returns an unsigned fixed-point object with value v, word length w, slopeadjustmentfactor, fixedexponent, and bias.

Examples

collapse all

Create a signed fi object with the default word length of 16 bits and best-precision fraction length.

a = ufi(pi)
a = 

    3.1416

          DataTypeMode: Fixed-point: binary point scaling
            Signedness: Unsigned
            WordLength: 16
        FractionLength: 14

If you omit the argument f, the fraction length is set automatically to the best precision possible.

a = ufi(pi,8)
a = 

    3.1406

          DataTypeMode: Fixed-point: binary point scaling
            Signedness: Unsigned
            WordLength: 8
        FractionLength: 6

Create an unsigned fi object with a value of pi, a word length of 8 bits, and a fraction length of 3 bits.

a = ufi(pi,8,3)
a = 

    3.1250

          DataTypeMode: Fixed-point: binary point scaling
            Signedness: Unsigned
            WordLength: 8
        FractionLength: 3

Default fimath properties are associated with a. When a fi object does not have a local fimath object, no fimath object properties are displayed in its output. To determine whether a fi object has a local fimath object, use the isfimathlocal function.

isfimathlocal(a)
ans =

  logical

   0

A returned value of 0 means the fi object does not have a local fimath object. When the isfimathlocal function returns a 1, the fi object has a local fimath object.

The value v can also be an array.

a = ufi((magic(3)/10),16,12)
a = 

    0.8000    0.1001    0.6001
    0.3000    0.5000    0.7000
    0.3999    0.8999    0.2000

          DataTypeMode: Fixed-point: binary point scaling
            Signedness: Unsigned
            WordLength: 16
        FractionLength: 12

Input Arguments

collapse all

Value of the unsigned fi object, specified as a scalar, vector, matrix, or multidimensional array.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | fi

Word length, in bits, of the unsigned fi object, specified as a scalar integer.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Fraction length, in bits, of the unsigned fi object, specified as a scalar integer. If you do not specify a fraction length, the signed fi object automatically uses the fraction length that gives the best precision while avoiding overflow for the specified value and word length.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Slope of the scaling, specified as a scalar integer. The following equation represents the real-world value of a slope bias scaled number.

real-world value=(slope×integer)+bias

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Bias of the scaling, specified as a scalar. The following equation represents the real-world value of a slope bias scaled number.

real-world value=(slope×integer)+bias

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

The slope adjustment factor of a slope bias scaled number. The following equation demonstrates the relationship between the slope, fixed exponent, and slope adjustment factor.

slope=slope adjustment factor×2fixed exponent

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

The fixed exponent of a slope bias scaled number. The following equation demonstrates the relationship between the slope, fixed exponent, and slope adjustment factor.

slope=slope adjustment factor×2fixed exponent

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Extended Capabilities

HDL Code Generation
Generate VHDL, Verilog and SystemVerilog code for FPGA and ASIC designs using HDL Coder™.

Version History

Introduced in R2009b