Control primitives

Primitives that manipulate the flow of tokens, such as commutators and distributors, downsamplers and upsamplers, and forks.

All of these primitives are polymorphic, that is, they operate on any data type. Control primitives can be divided into three categories.

Single-rate operations

Copy input particles to each output. Note that a fork is automatically inserted in a schematic when a single output is sent to more than one input. However, when a delay is needed on one of the connections, then an explicit fork primitive must be used.
On each execution, read a block of N samples (default 64) and write them out backward.
Transpose a rasterized matrix (one that is read as a sequence of particles, row by row, and written in the same form). The number of particles produced and consumed equals the product of samplesInaRow and numberOfRows.
Pass the value of the train input to the output for the first trainLength samples, then pass the decision input to the output. This primitive is designed for use with adaptive equalizers that require a training sequence at start-up, but it can be used whenever one sequence is used during a start-up phase, and another sequence after that.

Multi-rate operations

Synchronously combine N input streams (where N is the number of inputs) into one output stream. The primitive consumes B input particles from each input (where B is the blockSize), and produces \fs1N\times B particles on the output. The first B particles on the output come from the first input, the next B particles from the next input, etc.
Decimate by a given factor (default 2). The phase tells which sample of the last factor samples to output. If phase is 0 (by default), the most recent sample is the output, while if phase is −1, the oldest sample is the output.

Note that phase has the opposite sense of the phase parameter in the UpSample primitive, but the same sense as the phase parameter in the FIRFloat primitive.

Synchronously split one input stream into N output streams, where N is the number of outputs. The primitive consumes \fs1N\times B input particles, where B is the blockSize parameter, and sends the first B particles to the first output, the next B particles to the next output, etc.
Repeat each input sample a specified number of times.
Up-sample by a given factor (default 2), giving inserted samples the value fill (default 0.0). The phase parameter (default 0) tells where to put the sample in an output block. A phase of 0 says to output the input sample first, followed by the inserted samples. The maximum phase is equal to factor −1. Although the fill parameter is a floating-point number, if the input is of some other type, such as complex, then the fill particle will be obtained by casting fill to the appropriate type.

Other operations


On each execution, this primitive reads a block of nread particles and writes them to the output with the given offset.

The number of particles written is given by nwrite. The output block contains all or part of the input block, depending on offset and nwrite.

The offset specifies where in the output block the first (oldest) particle in the input block will lie. If offset is positive, then the first offset output particles will be either particles consumed on previous firings (if use_past_inputs parameter is set to YES), or zero (otherwise). If offset is negative, then the first offset input particles will be discarded.

This primitive has the same functionality as the Chop primitive except the offset parameter is determined at run time by a control input.
Demultiplex one input onto any number of output streams. The primitive consumes B particles from the input, where B is the blockSize. These B particles are copied to exactly one output, determined by the control input. The other outputs get a zero of the appropriate type. Integers from 0 through \fs1N-1 are accepted at the control input, where N is the number of outputs. If control is outside this range, all outputs get zeros.
Multiplex any number of inputs onto one output stream. B particles are consumed on each input, where B is the blockSize. But only one of these blocks of particles is copied to the output. The one copied is determined by the control input. Integers from 0 through N − 1 are accepted at the control input, where N is the number of inputs. If control is outside this range, an error is signaled.