Table Of Contents

Previous topic

Complex Block

Next topic

Hybrid Block

This Page

Constant Block

Declares a constant block or a constant block bundle using the keyword constant.

Signal Block

Declaration

# constant block
constant LABEL {
        value:  none
        meta:   none
}

# constant block bundle
constant LABEL [SIZE] {
        value:  none
        meta:   none
}
LABEL
definition:the label of the block
SIZE
definition:the size of the block bundle
type:constant integer port (CIP)

Shorthand Declaration

# constant block
BasicType >> LABEL;

# constant block bundle
BasicTypeList >> LABEL;
LABEL
definition:the label of the block
BasicType
definition:an integer, a real, or a string
BasicTypeList
definition:a list of integer, a list of real, or a list of string

Ports Table

               
Port Name Direction Type Connection Access Default Required
1 output output CIP, CRP, CSP (2) multiple LABEL >> none no (1)
assignment
2 value input CIP, CRP, CSP single >> LABEL none yes
property
3 meta input CSP single property none no
CIP
constant integer port
CRP
constant real port
CSP
constant string port

1 Warning issued during compilation if the port is left unconnected.

2 The port’s type is the same as value port’s type.


Description

A constant block can be assigned one of the basic types. Its value is assigned during declaration. Its output port type is the same as its value port type.


Code Examples

The following code declares a constant block called ‘SamplingRate’. The value property is assigned an Integer. The output port type of the block is constant integer.

constant SamplingRate {
        value:  2048
        meta:   'The sampling rate for analog input.'
}

# Shorthand Declaration
2048 >> SamplingRate;

The following code declares a constant block called ‘StandardPitch’. The value property is assigned a Real. The output port type of the block is constant real.

constant StandardPitch {
        value:  440.0
        meta:   'The musical pitch for all instrument.'
}

# Shorthand Declaration
440.0 >> StandardPitch;

The following code declares a constant block called ‘OutgoingIP’. The value property is assigned a String. The output port type of the block is constant string.

constant OutgoingIP {
        value:  '192.168.1.13'
        meta:   'The IP address of the server.'
}

# Shorthand Declaration
'192.168.1.13' >> OutgoingIP;

The following code declares a constant block bundle called ‘Frequencies’. The value property is assigned a Real list. The output port type of the block is constant real.

constant Frequencies [2] {
        value:  [440.0, 880.0]
        meta:   'Frequencies of A4 and A5.'
}

# Shorthand Declaration
[440.0, 880.0] >> Frequencies;