Main Content

ufi

(Not recommended) Construct unsigned fixed-point numeric object

ufi is not recommended. Use fi instead.

Syntax

a = ufi
a = ufi(v)
a = ufi(v,w)
a = ufi(v,w,f)
a = ufi(v,w,slope,bias)
a = ufi(v,w,slopeadjustmentfactor,fixedexponent,bias)

Description

You can use the ufi constructor function in the following ways:

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

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

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

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

  • 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.

fi objects created by the ufi constructor function have the following general types of properties:

Note

fi objects created by the ufi constructor function have no local fimath.

Examples

collapse all

For example, the following creates 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 =
     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

If you omit the argument f, it 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

If you omit w and f, they are set automatically to 16 bits and the best precision possible, respectively:

a = ufi(pi)
a =
 
    3.1416

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

Extended Capabilities

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

Version History

Introduced in R2009b