Conversion primitives

Primitives that explicitly accomplish type conversion.

Complex data type

CxToCxRI
Convert a complex input to real and imaginary parts.
CxRIToCx
Convert real and imaginary inputs to a complex output.
RectToPolar
Convert real and imaginary inputs into magnitude and phase form. The phase output is in the range \fs1-\pi to \fs1\pi.
PolarToRect
Convert magnitude and phase to rectangular form.

Other data type formats

PCMBitCoder
Encode voice samples for a 64 kbps bit stream using CCITT Recommendation G.711. The input is one 8 kHz sample of voice data and the output is the eight-bit codeword (the low-order 8 bits of an integer) representing the quantized samples.
PCMBitDecoder
Decode 8-bit PCM codewords that were encoded using PCMBitCoder.
BitsToSymMSB
The integer input sequence is interpreted as a bit stream in which any non-zero value is a "1" bit. This primitive consumes NumberOfBits successive bits from the input, packs them into an integer, and outputs the resulting integer. The first received bit becomes the most significant bit of the output. If NumberOfBits is larger than the integer word size, then the first bits received will be lost. If NumberOfBits is smaller than the word size minus one, then the output integer will always be non-negative.
SymToBitsMSB
Read the least significant NumberOfBits bits from an integer input, and output the bits as integers serially on the output, most significant bit first.
BusToNum

This primitive accepts a number of input bit streams, where this number should not exceed the word size of an integer. Each bit stream has integer particles with values 0, 3, or anything else. These are interpreted as binary 0, tristate, or 1, respectively.

When the primitive fires, it reads one input bit from each input. If any of the input bits is tristate, the output will be the previous output (or the initial value of the Previous parameter if the firing is the first one). Otherwise, the bits are assembled into an integer word, assuming two's complement encoding, and sign extended. The resulting signed integer is sent to the output. This primitive is particularly useful for interfacing to digital logic simulation domains.

NumToBus
This primitive accepts an integer and outputs the low-order bits that make up the integer on a number of outputs, one bit per output. The number of outputs should not exceed the word size of an integer. This primitive is particularly useful for interfacing to digital logic simulation domains.

Automatic type conversion has limitations. If a given output port has more than one destination, then all destinations must have the same type input. This is true even if an explicit fork primitive is used. Explicit type conversions are needed to get around this limitation. For this reason, the library also contains a set of type conversions that behave exactly the same way the automatic type conversions behave.

IntToFix
Convert an integer input to a fixed-point output.
IntToFloat
Convert an integer input to a floating-point output.
IntToCx
Convert an integer input to a complex output.
FixToInt
Convert a fixed-point input to an integer output.
FixToFloat
Convert a fixed-point input to a floating-point output.
FixToCx
Convert a fixed-point input to a complex output.
FloatToInt
Convert a floating-point input to an integer output.
FloatToFix
Convert a floating-point input to a fixed-point output.
FloatToCx
Convert a floating-point input to a complex output.
CxToInt
Convert a complex input to an integer output.
CxToFix
Convert a complex input to a fixed-point output.
CxToFloat
Convert a complex input to a floating-point output.

Matrix conversion primitives

The following type conversions construct a new matrix of the destination type by converting each element of the old matrix as it is copied to the new one.

For FixMatrix types, the precision is specified as a parameter of the conversion primitive. The actual conversions are implemented using the cast conversion in the underlying class, except for the conversions to the FixMatrix type which are more complex because they involve possible changes in precision and require a rounding option. The primitives provided are:

IntToFix_M
Convert an integer input matrix to a fixed-point output matrix.
IntToFloat_M
Convert an integer input matrix to a floating-point output matrix.
IntToCx_M
Convert an integer input matrix to a complex output matrix.
FixToInt_M
Convert a fixed-point input matrix to an integer output matrix.
FixToFloat_M
Convert a fixed-point input matrix to a floating-point output matrix.
FixToCx_M
Convert a fixed-point input matrix to a complex output matrix.
FloatToInt_M
Convert a floating-point input matrix to an integer output matrix.
FloatToFix_M
Convert a floating-point input matrix to a fixed-point output matrix.
FloatToCx_M
Convert a floating-point input matrix to a complex output matrix.
CxToInt_M
Convert a complex input matrix to an integer output matrix.
CxToFix_M
Convert a complex input matrix to a fixed-point output matrix.
CxToFloat_M
Convert a complex input matrix to a floating-point output matrix.