Previous topic

Modular Blocks

Next topic

Reaction Block

This Page

Module Block

module Block {
        input:
        output:
        propertyName:
        propertyDirection:
        propertyBlock:
        internalBlock:
        constraints:
        streams:
        meta:
}

signal Sum {
        default:        0 | 0.0                         # Integer | Real
        rate:           none | streamRate | AudioRate   # Asynchronous | Assigned in stream | Synchronous
        domain:         streamDomain | AudioDomain              # Assigned in stream | A Domian
}


[ 1 , 1 ] >> Sum ( size: auto reset: none ) >> Sum;             # auto is 2
[ 1. , 1. ] >> Sum ( size: auto reset: none ) >> Sum;
module Sum {
        input:          Inputs
        output:         Output
        propertyName:   [
                'size' ,
                'reset'
        ]
        propertyBlock:  [
                constant Size { value: 2 },
                trigger Reset {}
        ]
        internalBlock:  [
                hybrid Inputs [Size] {
                        type:           [ 'Stream Real', 'Stream Integer' ]
                        default :       [ 0.0 , 0 ]
                        rate:           streamRate
                        domain:         streamDomain
                        reset:          Reset
                },
                hybrid Output {
                        type:           [ 'Stream Real', 'Stream Integer' ]
                        default :       [ 0.0 , 0 ]
                        rate:           streamRate
                        domain:         streamDomain
                        reset:          Reset
                },
                reaction Adder {
                        output:         Sum
                        onExecution:    AdderReset              # Is this Add's or Adder's Reset? (SCOPE)
                        terminateWhen:  Terminate
                        internalBlock:  [
                                signal Index {
                                        default:        1
                                        rate:           none
                                        domain:         streamDomain
                                        reset:          AdderReset
                                },
                                hybrid Sum      {
                                        type:           [ 'Stream Real', 'Stream Integer' ]
                                        default:        [ 0.0 , 0 ]
                                        rate:           none
                                        domain:         streamDomain
                                        reset:          AdderReset
                                },
                                trigger AdderReset  { },
                                trigger Terminate { }
                        ]
                        streams:        [
                                Inputs[Index] + Sum >> Sum;
                                Index + 1 >> Index;
                                [ Index , Size ] >> Greater () >> Terminate;
                        ]
                }
        ]
        streams:        Adder () >> Output;
}