Document toolboxDocument toolbox

(8.D.2.5) Logic Compare N Int32

About This Guide

This Application Note explains the use of the LogicCompareNInt32 module in the Audio Weaver Application.

The LogicCompareNInt32 Module

The LogicCompareNInt32 module can be found in Sound Design/Control folder or by using the search window in the module browser.

Figure 1. Location in the Module Browser.

The LogicCompareNInt32 module has one input pin and one output pin. Multiple signals coming in must be interleaved onto multiple channels. The input signals must be integers but they do not have to be boolean.

The LogicCompareNInt32 module allows construction of multiple comparisons between pairs of input signals. While there can be multiple inputs and outputs, the following constraints apply.

For each output channel:

  • There are two corresponding input channels.

  • There is one comparison that can be one of the following choices. The number in parentheses is the opcode that should be entered into the third column of the compareConfig array.

    • EQUAL (0)

    • NOTEQUAL (1)

    • LESSTHAN (2)

    • LESSOREQUAL (3)

    • GREATERTHAN (4)

    • GREATERTHANOREQUAL (5)

    • CONST 1 (6)

    • CONST 0 (7)

  • The output of every comparison block arrives at an output channel.

  • There is no internal series connection between any of the comparison blocks although a single input pin can route to multiple comparison block inputs.

Configuring the module as a single comparator

The simplest function, which is a single comparison, requires a single row in the compareConfig array.

When you first drop the module into your design, you will see this (turn on View->Module Variables).

Figure 2. LogicCompareNInt32 layout symbol

Open the Properties panel and select the Arguments tab. Confirm that the number of comparison operations is 1.

Figure 3. Set argument numComps

 

Now click on the Array:compareConfig tab. Set the entries as shown, then click “Apply”.

Figure 4. Edit array

Confirm that the updated Module Variables are shown:

Figure 5. Confirm settings

This implements the comparison:

out[1] = (In[0] <= In[1] ? 0: 1)

If the result of the evaluation is true, a one (1) will be written at the corresponding output wire, otherwise a zero (0).

If you really want just a single comparison, use the LogicCompareInt32 module. LogicCompareNInt32’s power is in representing several comparisons efficiently.

Multiple Comparisons

Two comparisons of two inputs each are implemented below. Although not shown here, it is possible to use the same input pin in multiple expressions. You can add more comparisons by increasing numComps.

Figure 6. Setting numComps for multiple comparisons

Figure 7. Array entries for multiple comparisons

Figure 8. Confirm settings

This implements the comparisons:

Out[1] = ( In[0] <= In[1] ? 0:1 )

Out[2] = ( In[2] < In[3] ? 0:1 )