# shift2mask

Convert shift to mask vector for shift register configuration

## Syntax

`mask = shift2mask(prpoly,shift)`

## Description

`mask = shift2mask(prpoly,shift)`

returns
the mask that is equivalent to the shift (or offset) specified by `shift`

,
for a linear feedback shift register whose connections are specified
by the primitive polynomial `prpoly`

. The `prpoly`

input
can have one of these formats:

A binary vector that lists the coefficients of the primitive polynomial in order of descending powers

An integer scalar whose binary representation gives the coefficients of the primitive polynomial, where the least significant bit is the constant term

The `shift`

input is an integer scalar.

**Note**

To save time, `shift2mask`

does not check that `prpoly`

is
primitive. If it is not primitive, the output is not meaningful. To
find primitive polynomials, use `primpoly`

or
see [2].

### Definition of Equivalent Mask

The equivalent mask for the shift s is the remainder after dividing
the polynomial x^{s} by the primitive polynomial.
The vector `mask`

represents the remainder polynomial
by listing the coefficients in order of descending powers.

### Shifts, Masks, and Pseudonoise Sequence Generators

Linear feedback shift registers are part of an implementation of a pseudonoise sequence generator. Below is a schematic diagram of a pseudonoise sequence generator. All adders perform addition modulo 2.

The primitive polynomial determines the state of each switch
labeled g_{k}, and the mask determines the state
of each switch labeled m_{k}. The lower half of
the diagram shows the implementation of the shift, which delays the
starting point of the output sequence. If the shift is zero, the m_{0} switch
is closed while all other m_{k} switches are open.
The table below indicates how the shift affects the shift register's
output.

T = 0 | T = 1 | T = 2 | ... | T = s | T = s+1 | |
---|---|---|---|---|---|---|

Shift
= 0 | x_{0} | x_{1} | x_{2} | ... | x_{s} | x_{s+1} |

Shift
= s > 0 | x_{s} | x_{s+1} | x_{s+2} | ... | x_{2s} | x_{2s+1} |

If you have Communications Toolbox™ software and want to
generate a pseudonoise sequence in a Simulink^{®} model, see the PN Sequence Generator block reference page.

## Examples

## References

[1] Lee, J. S., and L. E. Miller, *CDMA
Systems Engineering Handbook*, Boston, Artech House, 1998.

[2] Simon, Marvin K., Jim K. Omura, et al., *Spread
Spectrum Communications Handbook*, New York, McGraw-Hill,
1994.

## See Also

`mask2shift`

| `deconv`

| `isprimitive`

| `primpoly`

**Introduced before R2006a**