.. _constantDoc: .. index:: single: constant ============== Constant Block ============== Declares a **constant block** or a **constant block bundle** using the keyword ``constant``. * Declaration_ * `Shorthand Declaration`_ * `Ports Table`_ * Description_ * `Code Examples`_ .. figure:: Images/ConstantBlock.png :scale: 100% :alt: Signal Block :align: center ---- 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 :ref:`integer `, a :ref:`real `, or a :ref:`string ` **BasicTypeList** :definition: a list of :ref:`integer `, a list of :ref:`real `, or a list of :ref:`string ` ---- Ports Table =========== +------+-----------+-----------+--------------------------+------------+------------+---------------+---------------+ | | | | | | | | | +------+-----------+-----------+--------------------------+------------+------------+---------------+---------------+ | Port | Name | Direction | Type | Connection | Access | Default | Required | +======+===========+===========+==========================+============+============+===============+===============+ | 1 | output | output | CIP, CRP, CSP :sup:`(2)` | multiple | LABEL >> | ``none`` | no :sup:`(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 :sup:`1` Warning issued during compilation if the port is left unconnected. :sup:`2` The port's type is the same as ``value`` port's type. ---- Description =========== A ``constant`` block can be assigned one of the :ref:`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 :ref:`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 :ref:`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 :ref:`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 :ref:`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;