Mixing two signals in SigmaStudio

If you use SigmaStudio to create filter networks, you might look for a simple mixer to add two signals. The NxM mixer seems to be the tool for this. However, if you set all parameters directly at the DSP, there is a way that’s even less resource-intense: the switch. Have a look at the following configuration:

sigmastudio_mixers

There is a mono switch and a mono mixer. Isn’t the switch designed to only switch between inputs and not to mix them? You could think so. But internally, it is easier to implement a switch as a mixer than as a real switch. Let’s check the parameter definitions of these blocks:

/* Module mx3 - Mono Switch Nx1*/
#define MOD_MX3_COUNT 2
#define MOD_MX3_DEVICE "IC1"
#define MOD_MX3_ALG0_STAGE0_MONOSWITCHNOSLEW_ADDR 4
#define MOD_MX3_ALG0_STAGE0_MONOSWITCHNOSLEW_FIXPT 0x00000000
#define MOD_MX3_ALG0_STAGE0_MONOSWITCHNOSLEW_VALUE SIGMASTUDIOTYPE_FIXPOINT_CONVERT(0)
#define MOD_MX3_ALG0_STAGE0_MONOSWITCHNOSLEW_TYPE SIGMASTUDIOTYPE_FIXPOINT
#define MOD_MX3_ALG0_STAGE1_MONOSWITCHNOSLEW_ADDR 5
#define MOD_MX3_ALG0_STAGE1_MONOSWITCHNOSLEW_FIXPT 0x00800000
#define MOD_MX3_ALG0_STAGE1_MONOSWITCHNOSLEW_VALUE SIGMASTUDIOTYPE_FIXPOINT_CONVERT(1)
#define MOD_MX3_ALG0_STAGE1_MONOSWITCHNOSLEW_TYPE SIGMASTUDIOTYPE_FIXPOINT

/* Module mx4 - NxM Mixer*/
#define MOD_MX4_COUNT 4
#define MOD_MX4_DEVICE "IC1"
#define MOD_MX4_ALG0_NXNMIXER1940ALG100_ADDR 6
#define MOD_MX4_ALG0_NXNMIXER1940ALG100_FIXPT 0x00800000
#define MOD_MX4_ALG0_NXNMIXER1940ALG100_VALUE SIGMASTUDIOTYPE_FIXPOINT_CONVERT(1)
#define MOD_MX4_ALG0_NXNMIXER1940ALG100_TYPE SIGMASTUDIOTYPE_FIXPOINT
#define MOD_MX4_ALG0_NXNMIXER1940ALG100_ADDR 6
#define MOD_MX4_ALG0_NXNMIXER1940ALG100_FIXPT 0x00800000
#define MOD_MX4_ALG0_NXNMIXER1940ALG100_VALUE SIGMASTUDIOTYPE_FIXPOINT_CONVERT(1)
#define MOD_MX4_ALG0_NXNMIXER1940ALG100_TYPE SIGMASTUDIOTYPE_FIXPOINT
#define MOD_MX4_ALG0_NXNMIXER1940ALG101_ADDR 7
#define MOD_MX4_ALG0_NXNMIXER1940ALG101_FIXPT 0x00000000
#define MOD_MX4_ALG0_NXNMIXER1940ALG101_VALUE SIGMASTUDIOTYPE_FIXPOINT_CONVERT(1E-10)
#define MOD_MX4_ALG0_NXNMIXER1940ALG101_TYPE SIGMASTUDIOTYPE_FIXPOINT
#define MOD_MX4_ALG0_NXNMIXER1940ALG101_ADDR 7
#define MOD_MX4_ALG0_NXNMIXER1940ALG101_FIXPT 0x00000000
#define MOD_MX4_ALG0_NXNMIXER1940ALG101_VALUE SIGMASTUDIOTYPE_FIXPOINT_CONVERT(1E-10)
#define MOD_MX4_ALG0_NXNMIXER1940ALG101_TYPE SIGMASTUDIOTYPE_FIXPOINT

The Mono switch has two fixpoint parameters. Why does it need a fixpoint parameter? The easiest implementation for a switch would be a parameter that holds the active input. But on a DSP that’s not the most effective way to implement a switch. Therefore Analog Devices has decided to implement a switch as

output = input1 x param1 + input2 x param2

The way as SigmaStudio used this switch, one parameter is 1 and the other is 0. But they do not have to be 0 or 1. They can use any value between -16 and 16.  Negative numbers? Yes, even negative parameters are possible. Using a negative value will invert the signal. This gives us nice possibilities to mix two signals in-phase and even out-of-phase.

Another interesting fact: The implementation of he switch is less resource-intense than the mixer. The switch needs only 2 addresses in the parameter RAM instead of the 4 that the mixer needs. Also the code is one instruction shorter. That’s not much, but if your program is using almost all resources of the DSP, it might help to free up some instructions.

P.S. The trick using negative numbers to invert a signal works with many DSP blocks created by SigmaStudio.

1 thought on “Mixing two signals in SigmaStudio

Leave a Reply