Document toolboxDocument toolbox

(8.D.2.7) ControlOpV2

Overview

Control signal operations module

Discussion

The module computes control operations (e.g. control signals from CAN) which are simple arithmetic operations using two input values. A single row is devoted to each operation:

Column 1 specifies what operation should be performed:

op=0, CONST 0 (out = 0).

op=1, CONST 1 (out = 1).

op=2, Pass through (out = in1).

op=3, Sum (out = in1 + in2).

op=4, Diff (out = in1 - in2).

op=5, Average (out = (in1 + in2) / 2).

op=6, Time Derivative (out = (in1[n] - in1[n-1]) * SR)

op=7, Multiplication (out = in1 * in2).

op=8, Division (out = in1 / in2).

op=9, dB to linear (out = undb20(in1)).

op=10, Max (in1, in2)

op=11, Min (in1, in2)

op=12, Equal One Pass 2 (if (in1 == 1) --> out = in2, else out = 1)

op=13, Not Equal One Pass 2 (if (in1 != 1) --> out = in2, else out = 1)

op=14, Greater Than, (if (in1 >= in2) --> out = 1, else out = 0)

op=15, Boolean Invert (if (in1 < 0.5) --> out = 1, else out = 0)

op=16, FlipFlop1 - 1 for in1 = 1 until in2 = 1, else output 0

op=17, FlipFlop2 - 1 if in1 = 1 for sample count in in2, else output 0

Column 2 contains the channel index of the first input argument (0-based). Column 3 contains the channel index of the second input argument (0-based).

If an index is out of range or the op is out of range then the module outputs 0 for that operation.

This module supports only control data where block size is 1.

Type Definition

typedef struct _ModuleControlOpV2 {     ModuleInstanceDescriptor instance;            // Common Audio Weaver module instance structure     INT32 numOps;                                 // Number of operations to be computed     INT32 updateActive;                           // Specifies whether the configuration is updating (=1) or fixed (=0).     INT32* opType;                                // Controls the operations (opType). One row per operation.     INT32* chIdx1;                                // Controls the operations (channel index 1). One row per operation.     INT32* chIdx2;                                // Controls the operations (channel index 2). One row per operation.     FLOAT32* lastValue;                           // Previous sample value on all input channels     INT32* firstBlock;                            // Array of flags set on first block of each channel before lastValue is valid     INT32* triggerPulse1;                         // Array of flags set on in operation OP_FLIPFLOP1 to trigger pulse output     INT32* triggerPulse2;                         // Array of flags set on in operation OP_FLIPFLOP2 to trigger pulse output     INT32* prevTriggerState;                      // Array of flags set on in OP_FLIPFLOP2 to trigger pulse output     INT32* outPulseCnt;                           // Array of pulse high period count in samples for triggerPulse2 } ModuleControlOpV2Class;

 

Variables

Properties

Name

Type

Usage

isHidden

Default value

Range

Units

numOps

int

const

0

1

1:1:256

 

updateActive

int

parameter

1

1

0:1

 

opType

int*

parameter

0

[1 x 1]

Unrestricted

 

chIdx1

int*

parameter

0

[1 x 1]

Unrestricted

 

chIdx2

int*

parameter

0

[1 x 1]

Unrestricted

 

lastValue

float*

state

1

[1 x 1]

Unrestricted

 

firstBlock

int*

state

1

[1 x 1]

Unrestricted

 

triggerPulse1

int*

state

1

[1 x 1]

Unrestricted

 

triggerPulse2

int*

state

1

[1 x 1]

Unrestricted

 

prevTriggerState

int*

state

1

[1 x 1]

Unrestricted

 

outPulseCnt

int*

state

1

[1 x 1]

Unrestricted

 

Pins

Input Pins

Name: in

Description: Input signal

Data type: float

Channel range: Unrestricted

Block size range: 1

Sample rate range: Unrestricted

Complex support: Real

Output Pins

Name: out

Description: Output signal

Data type: float

MATLAB Usage

File Name: control_op_v2_module.m

Performs various arithmetic operations that are typically applied  to CAN control inputs. The opreation is applied to the two inputs,   which can be also multichannel. The second argument specifies how many   operations shall be performed. Each result is placed on a separate   output channel.    Arguments:     NAME - name of the module.     NUMOPS - number of operations to compute.  By default equals 1.

Â