FAUST compiler  0.9.9.6b8
Functions | Variables
propagate.cpp File Reference
#include "propagate.hh"
#include "prim2.hh"
#include <assert.h>
#include "ppbox.hh"
#include "xtended.hh"
#include "labels.hh"
#include "Text.hh"
#include "ppsig.hh"
#include "names.hh"
Include dependency graph for propagate.cpp:

Go to the source code of this file.

Functions

siglist mix (const siglist &lsig, int nbus)
 propagate : box listOfSignal-> listOfSignal'
siglist split (const siglist &inputs, int nbus)
 split une liste de signaux sur n bus
siglist makeSigProjList (Tree t, int n)
 Fabrique une liste de n projections d'un groupe récursif.
siglist makeMemSigProjList (Tree t, int n)
 Fabrique une liste de n mem projections d'un groupe récursif.
siglist makeSigInputList (int n)
 Fabrique une liste de n entrées.
siglist makeList (Tree t)
siglist listRange (const siglist &l, int i, int j)
siglist listConcat (const siglist &a, const siglist &b)
Tree listConvert (const siglist &a)
 Convert an stl list of signals into a tree list of signals.
siglist listLift (const siglist &l)
siglist propagate (Tree slotenv, Tree path, Tree box, const siglist &lsig)
 Propagate computes the outputs signals of a block-diagram according to a list of input signals.
Tree boxPropagateSig (Tree path, Tree box, const siglist &lsig)

Variables

static int gDummyInput = 10000

Function Documentation

Tree boxPropagateSig ( Tree  path,
Tree  box,
const siglist lsig 
)

Definition at line 445 of file propagate.cpp.

References listConvert(), nil, and propagate().

Referenced by eval2double(), eval2int(), isBoxNumeric(), main(), mapPrepareEqSig(), and numericBoxSimplification().

{
    return listConvert(propagate(nil, path, box, lsig));
}

Here is the call graph for this function:

Here is the caller graph for this function:

siglist listConcat ( const siglist a,
const siglist b 
)

Definition at line 117 of file propagate.cpp.

Referenced by propagate().

{
    int n1 = a.size();
    int n2 = b.size();
    siglist r(n1+n2);
    
    for (int x=0; x<n1; x++) r[x] = a[x];
    for (int x=0; x<n2; x++) r[x+n1] = b[x];
    return r;
}

Here is the caller graph for this function:

Tree listConvert ( const siglist a)

Convert an stl list of signals into a tree list of signals.

Definition at line 131 of file propagate.cpp.

References cons(), and nil.

Referenced by boxPropagateSig(), and propagate().

{
    int     n = a.size();
    Tree    t=nil;
    while (n--) t = cons(a[n],t);
    return t;
}

Here is the call graph for this function:

Here is the caller graph for this function:

siglist listLift ( const siglist l)

Definition at line 146 of file propagate.cpp.

References lift().

Referenced by propagate().

{
    int         n = l.size();
    siglist     r(n);
    
    for(int i = 0; i<n; i++) r[i] = lift(l[i]);
    return r;
}

Here is the call graph for this function:

Here is the caller graph for this function:

siglist listRange ( const siglist l,
int  i,
int  j 
)

Definition at line 110 of file propagate.cpp.

Referenced by propagate().

{
    siglist r(j-i);
    for (int x = i; x < j; x++) r[x-i] = l[x];
    return r;
}

Here is the caller graph for this function:

siglist makeList ( Tree  t) [inline]

Definition at line 103 of file propagate.cpp.

Referenced by propagate().

{
    siglist l(1);
    l[0] = t;
    return l;
}

Here is the caller graph for this function:

siglist makeMemSigProjList ( Tree  t,
int  n 
)

Fabrique une liste de n mem projections d'un groupe récursif.

Definition at line 87 of file propagate.cpp.

References sigDelay1(), and sigProj().

Referenced by propagate().

{
    siglist l(n);
    for (int i = 0; i < n; i++) l[i] = sigDelay1(sigProj(i, t));
    return l;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Fabrique une liste de n entrées.

Definition at line 96 of file propagate.cpp.

References sigInput().

Referenced by eval2double(), eval2int(), isBoxNumeric(), main(), mapPrepareEqSig(), and numericBoxSimplification().

{
    siglist l(n);
    for (int i = 0; i < n; i++) l[i] = sigInput(i);
    return l;
}

Here is the call graph for this function:

Here is the caller graph for this function:

siglist makeSigProjList ( Tree  t,
int  n 
)

Fabrique une liste de n projections d'un groupe récursif.

Definition at line 79 of file propagate.cpp.

References sigDelay0(), and sigProj().

Referenced by propagate().

{
    siglist l(n);
    for (int i = 0; i < n; i++) l[i] = sigDelay0(sigProj(i, t));
    return l;
}

Here is the call graph for this function:

Here is the caller graph for this function:

siglist mix ( const siglist lsig,
int  nbus 
)

propagate : box listOfSignal-> listOfSignal'

Propage une liste de signaux de l'entrée vers la sortie d'une boite La boite a été annotée aec son type mix une liste de signaux sur n bus

Definition at line 49 of file propagate.cpp.

References sigAdd(), and sigInt().

Referenced by propagate().

{
    int nlines  = lsig.size();
    
    siglist dst(nbus);
    
    for (int b=0; b<nbus; b++) {
        Tree t = (b<nlines) ? lsig[b] : sigInt(0);
        for (int i=b+nbus; i<nlines; i+=nbus) {
            t = sigAdd(t, lsig[i]);
        }
        dst[b] = t;
    }
    return dst;
}           

Here is the call graph for this function:

Here is the caller graph for this function:

siglist propagate ( Tree  slotenv,
Tree  path,
Tree  box,
const siglist lsig 
)

Propagate computes the outputs signals of a block-diagram according to a list of input signals.

Parameters:
slotenvinput signals associated with symbolic slots
pathstack of user interface groups : (type,label)*
boxblock-diagram where we propagate the signals
lsiglist of signals to be propagated into box
Returns:
list of resulting signals Old try for names propagation.

Definition at line 199 of file propagate.cpp.

References xtended::arity(), xtended::computeSigOutput(), cons(), ffarity(), gDummyInput, getBoxType(), getUserData(), isBoxButton(), isBoxCheckbox(), isBoxCut(), isBoxFConst(), isBoxFFun(), isBoxFVar(), isBoxHBargraph(), isBoxHGroup(), isBoxHSlider(), isBoxInt(), isBoxMerge(), isBoxNumEntry(), isBoxPar(), isBoxPrim0(), isBoxPrim1(), isBoxPrim2(), isBoxPrim3(), isBoxPrim4(), isBoxPrim5(), isBoxReal(), isBoxRec(), isBoxSeq(), isBoxSlot(), isBoxSplit(), isBoxSymbolic(), isBoxTGroup(), isBoxVBargraph(), isBoxVGroup(), isBoxVSlider(), isBoxWire(), lift(), listConcat(), listConvert(), listLift(), listRange(), makeList(), makeMemSigProjList(), makeSigProjList(), max(), min(), mix(), name(), normalizePath(), pushEnv(), rec(), ref(), searchEnv(), sigButton(), sigCheckbox(), sigFConst(), sigFFun(), sigFVar(), sigHBargraph(), sigHSlider(), sigInput(), sigInt(), sigNumEntry(), sigReal(), sigVBargraph(), sigVSlider(), split(), and tree().

Referenced by boxPropagateSig().

{
    int     i;
    double  r;
    prim0   p0;
    prim1   p1;
    prim2   p2;
    prim3   p3;
    prim4   p4;
    prim5   p5;
    
    Tree    t1, t2, ff, label, cur, min, max, step, type, name, file, slot, body;
    
    
    xtended* xt = (xtended*)getUserData(box);
    
    // Extended Primitives
    
    if (xt) {
        assert(lsig.size() == xt->arity());
        return makeList(xt->computeSigOutput(lsig));
    }
        
    // Numbers and Constants
    
    else if (isBoxInt(box, &i))     { 
        assert(lsig.size()==0); 
        return makeList(sigInt(i)); 
    }
    else if (isBoxReal(box, &r))    { 
        assert(lsig.size()==0); 
        return makeList(sigReal(r)); 
    }
    
    else if (isBoxFConst(box, type, name, file))    { 
        assert(lsig.size()==0); 
        return makeList(sigFConst(type, name, file)); 
    }
    
    else if (isBoxFVar(box, type, name, file))    { 
        assert(lsig.size()==0); 
        return makeList(sigFVar(type, name, file)); 
    }
    
    // Wire and Cut
    
    else if (isBoxCut(box))                 { 
        assert(lsig.size()==1); 
        return siglist(); 
    }
    
    else if (isBoxWire(box))                { 
        assert(lsig.size()==1); 
        return lsig;  
    }
    
    // Slots and Symbolic Boxes
    
    else if (isBoxSlot(box))                { 
        Tree sig;
        assert(lsig.size()==0); 
        if (!searchEnv(box,sig,slotenv)) {
            // test YO simplification des diagrames
            //fprintf(stderr, "propagate : internal error (slot undefined)\n");
            //exit(1);
            sig = sigInput(++gDummyInput);
        }
        return makeList(sig);
    }
    
    else if (isBoxSymbolic(box, slot, body))                { 
        assert(lsig.size()>0); 
        return propagate(pushEnv(slot,lsig[0],slotenv), path, body, listRange(lsig, 1, lsig.size()));
    }
    
    // Primitives
    
    else if (isBoxPrim0(box, &p0))          { 
        assert(lsig.size()==0); 
        return makeList( p0() );  
    }
    
    else if (isBoxPrim1(box, &p1))              { 
        assert(lsig.size()==1); 
        return makeList( p1(lsig[0]) );  
    }
    
    else if (isBoxPrim2(box, &p2))              { 
//      printf("prim2 recoit : "); print(lsig); printf("\n");
        assert(lsig.size()==2); 
        return makeList( p2(lsig[0],lsig[1]) );  
    }
    
    else if (isBoxPrim3(box, &p3))              { 
        assert(lsig.size()==3); 
        return makeList( p3(lsig[0],lsig[1],lsig[2]) );  
    }
    
    else if (isBoxPrim4(box, &p4))              { 
        assert(lsig.size()==4); 
        return makeList( p4(lsig[0],lsig[1],lsig[2],lsig[3]) );  
    }
    
    else if (isBoxPrim5(box, &p5))              { 
        assert(lsig.size()==5); 
        return makeList( p5(lsig[0],lsig[1],lsig[2],lsig[3],lsig[4]) );  
    }
    
    else if (isBoxFFun(box, ff))                { 
        //cerr << "propagate en boxFFun of arity " << ffarity(ff) << endl;
        assert(int(lsig.size())==ffarity(ff)); 
        return makeList(sigFFun(ff, listConvert(lsig)));  
    }
    
    // User Interface Widgets
    
    else if (isBoxButton(box, label))   { 
        assert(lsig.size()==0); 
        return makeList(sigButton(normalizePath(cons(label, path)))); 
    }
    
    else if (isBoxCheckbox(box, label))     { 
        assert(lsig.size()==0); 
        return makeList(sigCheckbox(normalizePath(cons(label, path)))); 
    }
    
    else if (isBoxVSlider(box, label, cur, min, max, step))     { 
        assert(lsig.size()==0); 
        return makeList(sigVSlider(normalizePath(cons(label, path)), cur, min, max, step)); 
    }
    
    else if (isBoxHSlider(box, label, cur, min, max, step))     { 
        assert(lsig.size()==0); 
        return makeList(sigHSlider(normalizePath(cons(label, path)), cur, min, max, step)); 
    }
    
    else if (isBoxNumEntry(box, label, cur, min, max, step))    { 
        assert(lsig.size()==0); 
        return makeList(sigNumEntry(normalizePath(cons(label, path)), cur, min, max, step)); 
    }
    
    else if (isBoxVBargraph(box, label, min, max))  { 
        assert(lsig.size()==1); 
        return makeList(sigVBargraph(normalizePath(cons(label, path)), min, max, lsig[0])); 
    }
    
    else if (isBoxHBargraph(box, label, min, max))  { 
        assert(lsig.size()==1); 
        return makeList(sigHBargraph(normalizePath(cons(label, path)), min, max, lsig[0])); 
    }
    
    // User Interface Groups
    
    else if (isBoxVGroup(box, label, t1))   { 
        return propagate(slotenv,cons(cons(tree(0),label), path), t1, lsig); 
    }
    
    else if (isBoxHGroup(box, label, t1))   { 
        return propagate(slotenv, cons(cons(tree(1),label), path), t1, lsig); 
    }
    
    else if (isBoxTGroup(box, label, t1))   { 
        return propagate(slotenv, cons(cons(tree(2),label), path), t1, lsig); 
    }
    
    // Block Diagram Composition Algebra
    
    else if (isBoxSeq(box, t1, t2))     { 
        int in1, out1, in2, out2;
        getBoxType(t1, &in1, &out1);
        getBoxType(t2, &in2, &out2);

        assert(out1==in2);

        if (out1 == in2) {
            return propagate(slotenv, path, t2, propagate(slotenv, path,t1,lsig));
        } else if (out1 > in2) {
            siglist lr = propagate(slotenv, path, t1,lsig);
            return listConcat(propagate(slotenv, path, t2, listRange(lr, 0, in2)), listRange(lr, in2, out1));
        } else {
            return propagate(slotenv, path, t2, listConcat( propagate(slotenv, path, t1, listRange(lsig,0,in1)), listRange(lsig,in1,in1+in2-out1) ) );
        }
    }
    
    else if (isBoxPar(box, t1, t2))     { 
        int in1, out1, in2, out2;
        getBoxType(t1, &in1, &out1);
        getBoxType(t2, &in2, &out2);
            
        return listConcat(  propagate(slotenv, path, t1, listRange(lsig, 0,  in1)), 
                            propagate(slotenv, path, t2, listRange(lsig, in1, in1+in2)) );
    }
    
    else if (isBoxSplit(box, t1, t2))   { 
        int in1, out1, in2, out2;
        getBoxType(t1, &in1, &out1);
        getBoxType(t2, &in2, &out2);
        
        siglist l1 = propagate(slotenv, path, t1, lsig);
        siglist l2 = split(l1, in2);
        return propagate(slotenv, path, t2, l2);
    }
    
    else if (isBoxMerge(box, t1, t2))   { 
        int in1, out1, in2, out2;
        getBoxType(t1, &in1, &out1);
        getBoxType(t2, &in2, &out2);
        
        siglist l1 = propagate(slotenv, path, t1, lsig);
        siglist l2 = mix(l1, in2);
        return propagate(slotenv, path, t2, l2);
    }
/*  
    else if (isBoxRec(box, t1, t2))     { 
        int in1, out1, in2, out2;
        getBoxType(t1, &in1, &out1);
        getBoxType(t2, &in2, &out2);
        
        siglist l0 = makeSigProjList(ref(1), in2);
        siglist l1 = propagate(slotenv, path, t2, l0);
        siglist l2 = propagate(slotenv, path, t1, listConcat(l1,listLift(lsig)));
        Tree g = rec(listConvert(l2));
        return makeSigProjList(g, out1);
    }
*/  
    else if (isBoxRec(box, t1, t2))     {
        // Bug Corrected
        int in1, out1, in2, out2;
        getBoxType(t1, &in1, &out1);
        getBoxType(t2, &in2, &out2);

        Tree slotenv2 = lift(slotenv); // the environment must also be lifted

        siglist l0 = makeMemSigProjList(ref(1), in2);
        siglist l1 = propagate(slotenv2, path, t2, l0);
        siglist l2 = propagate(slotenv2, path, t1, listConcat(l1,listLift(lsig)));
        Tree g = rec(listConvert(l2));
        return makeSigProjList(g, out1);
    }

    cout << "ERROR in file " << __FILE__ << ':' << __LINE__ << ", unrecognised box expression : " << boxpp(box) << endl;
    exit(1);
    return siglist();
}

Here is the caller graph for this function:

siglist split ( const siglist inputs,
int  nbus 
)

split une liste de signaux sur n bus

Definition at line 66 of file propagate.cpp.

Referenced by propagate().

{
    int nlines  = inputs.size();
    
    siglist outputs(nbus);
    
    for (int b=0; b<nbus; b++) {
        outputs[b] = inputs[b % nlines];
    }
    return outputs;
}           

Here is the caller graph for this function:


Variable Documentation

int gDummyInput = 10000 [static]

Definition at line 155 of file propagate.cpp.

Referenced by propagate().