~ubuntu-branches/ubuntu/feisty/faust/feisty

« back to all changes in this revision

Viewing changes to compiler/signals/signals.hh

  • Committer: Bazaar Package Importer
  • Author(s): Mario Lang
  • Date: 2006-10-09 11:05:30 UTC
  • mfrom: (1.1.1 upstream) (2.1.1 edgy)
  • Revision ID: james.westby@ubuntu.com-20061009110530-zvktdvpq5zewdxso
Tags: 0.9.8-1
* New upstream release.
* Upgrade Standards-Version to 3.7.2.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19
19
 ************************************************************************
20
20
 ************************************************************************/
21
 
 
22
 
 
23
 
 
 
21
 
 
22
 
 
23
 
24
24
#ifndef _SIGNALS_
25
25
#define _SIGNALS_
26
26
 
27
27
#include "tlib.hh"
28
28
#include "binop.hh"
29
29
#include <assert.h>
 
30
#include <vector>
 
31
 
 
32
using namespace std;
30
33
 
31
34
 
32
35
////////////////////////////////////////////////////////////////////////
33
36
/**
34
37
 * Les Signaux.
35
 
 * Les diff�rents constructeurs de signaux 
 
38
 * Les diff�rents constructeurs de signaux
36
39
 */
37
40
///////////////////////////////////////////////////////////////////////
38
41
 
39
42
// les constantes
40
 
Tree sigInt(int n);                                     
41
 
Tree sigReal(double n);                 
42
 
                
 
43
Tree sigInt(int n);
 
44
Tree sigReal(float n);
 
45
 
43
46
bool  isSigInt(Tree t, int* i);
44
47
bool  isSigReal(Tree t, float* r);
45
48
 
46
49
 
47
50
// les entr�es sorties
48
 
Tree sigInput(int i);                                   
49
 
Tree sigOutput(int i, Tree t);                  
 
51
Tree sigInput(int i);
 
52
Tree sigOutput(int i, Tree t);
50
53
 
51
54
bool  isSigInput(Tree t, int* i);
52
55
bool  isSigOutput(Tree t, int* i, Tree& t0);
53
56
 
54
57
// delay
55
 
Tree  sigDelay1(Tree t);                                
 
58
Tree  sigDelay1(Tree t);
56
59
bool  isSigDelay1(Tree t, Tree& t0);
57
60
 
58
 
Tree  sigFixDelay(Tree t0, Tree t1);               
59
 
bool  isSigFixDelay(Tree t, Tree& t0, Tree& t1); 
60
 
 
61
 
Tree  sigPrefix(Tree t0, Tree t1);                 
62
 
bool  isSigPrefix(Tree t, Tree& t0, Tree& t1); 
63
 
 
64
 
Tree  sigIota(Tree t0);                    
65
 
bool  isSigIota(Tree t, Tree& t0); 
66
 
                                
 
61
Tree  sigFixDelay(Tree t0, Tree t1);
 
62
bool  isSigFixDelay(Tree t, Tree& t0, Tree& t1);
 
63
 
 
64
Tree  sigPrefix(Tree t0, Tree t1);
 
65
bool  isSigPrefix(Tree t, Tree& t0, Tree& t1);
 
66
 
 
67
Tree  sigIota(Tree t0);
 
68
bool  isSigIota(Tree t, Tree& t0);
 
69
 
67
70
// Int and Float casting
68
 
Tree  sigIntCast(Tree t);                               
69
 
Tree  sigFloatCast(Tree t);     
70
 
                        
 
71
Tree  sigIntCast(Tree t);
 
72
Tree  sigFloatCast(Tree t);
 
73
 
71
74
bool  isSigIntCast(Tree t, Tree& x);
72
75
bool  isSigFloatCast(Tree t, Tree& x);
73
76
 
74
77
 
75
78
// tables
76
 
Tree sigRDTbl (Tree t, Tree i);         
 
79
Tree sigRDTbl (Tree t, Tree i);
77
80
Tree sigWRTbl (Tree id, Tree t, Tree i, Tree s);
78
 
Tree sigTable (Tree id, Tree n, Tree sig);              
 
81
Tree sigTable (Tree id, Tree n, Tree sig);
79
82
Tree sigGen   (Tree content);
80
83
 
81
84
bool isSigRDTbl (Tree s, Tree& t, Tree& i);
112
115
 
113
116
// Foreign Constants
114
117
 
115
 
Tree sigFConst          (Tree type, Tree name, Tree file); 
 
118
Tree sigFConst          (Tree type, Tree name, Tree file);
116
119
bool isSigFConst        (Tree s);
117
120
bool isSigFConst        (Tree s, Tree& type, Tree& name, Tree& file);
118
121
 
119
122
// emulation des anciennes fonctions
120
 
inline Tree sigAdd(Tree x, Tree y)      { return sigBinOp(kAdd, x, y); }                
121
 
inline Tree sigSub(Tree x, Tree y)      { return sigBinOp(kSub, x, y); }                        
122
 
inline Tree sigMul(Tree x, Tree y)      { return sigBinOp(kMul, x, y); }                        
123
 
inline Tree sigDiv(Tree x, Tree y)      { return sigBinOp(kDiv, x, y); }                        
124
 
inline Tree sigRem(Tree x, Tree y)      { return sigBinOp(kRem, x, y); } 
125
 
 
126
 
inline Tree sigAND(Tree x, Tree y)      { return sigBinOp(kAND, x, y); }                        
127
 
inline Tree sigOR(Tree x, Tree y)       { return sigBinOp(kOR, x, y); }                         
128
 
inline Tree sigXOR(Tree x, Tree y)      { return sigBinOp(kXOR, x, y); } 
129
 
 
130
 
inline Tree sigLeftShift(Tree x, Tree y)        { return sigBinOp(kLsh, x, y); }                
 
123
inline Tree sigAdd(Tree x, Tree y)      { return sigBinOp(kAdd, x, y); }
 
124
inline Tree sigSub(Tree x, Tree y)      { return sigBinOp(kSub, x, y); }
 
125
inline Tree sigMul(Tree x, Tree y)      { return sigBinOp(kMul, x, y); }
 
126
inline Tree sigDiv(Tree x, Tree y)      { return sigBinOp(kDiv, x, y); }
 
127
inline Tree sigRem(Tree x, Tree y)      { return sigBinOp(kRem, x, y); }
 
128
 
 
129
inline Tree sigAND(Tree x, Tree y)      { return sigBinOp(kAND, x, y); }
 
130
inline Tree sigOR(Tree x, Tree y)       { return sigBinOp(kOR, x, y); }
 
131
inline Tree sigXOR(Tree x, Tree y)      { return sigBinOp(kXOR, x, y); }
 
132
 
 
133
inline Tree sigLeftShift(Tree x, Tree y)        { return sigBinOp(kLsh, x, y); }
131
134
inline Tree sigRightShift(Tree x, Tree y)       { return sigBinOp(kRsh, x, y); }
132
 
                
133
 
inline Tree sigGT(Tree x, Tree y)       { return sigBinOp(kGT, x, y); }                 
134
 
inline Tree sigLT(Tree x, Tree y)       { return sigBinOp(kLT, x, y); }                         
135
 
inline Tree sigGE(Tree x, Tree y)       { return sigBinOp(kGE, x, y); }                         
136
 
inline Tree sigLE(Tree x, Tree y)       { return sigBinOp(kLE, x, y); } 
137
 
inline Tree sigEQ(Tree x, Tree y)       { return sigBinOp(kEQ, x, y); }                         
138
 
inline Tree sigNE(Tree x, Tree y)       { return sigBinOp(kNE, x, y); } 
 
135
 
 
136
inline Tree sigGT(Tree x, Tree y)       { return sigBinOp(kGT, x, y); }
 
137
inline Tree sigLT(Tree x, Tree y)       { return sigBinOp(kLT, x, y); }
 
138
inline Tree sigGE(Tree x, Tree y)       { return sigBinOp(kGE, x, y); }
 
139
inline Tree sigLE(Tree x, Tree y)       { return sigBinOp(kLE, x, y); }
 
140
inline Tree sigEQ(Tree x, Tree y)       { return sigBinOp(kEQ, x, y); }
 
141
inline Tree sigNE(Tree x, Tree y)       { return sigBinOp(kNE, x, y); }
139
142
 
140
143
// pattern matching pour les anciennes fonctions
141
144
bool isSigAdd   (Tree a, Tree&x, Tree&y);
149
152
Tree mulNums    (Tree a, Tree b);
150
153
Tree divNums    (Tree a, Tree b);
151
154
Tree divExtendedNums    (Tree a, Tree b);
152
 
Tree minusNum   (Tree a); 
153
 
Tree inverseNum (Tree a); 
 
155
Tree minusNum   (Tree a);
 
156
Tree inverseNum (Tree a);
154
157
 
155
158
// tests sur les signaux constants
156
159
inline bool isNum               (Tree a)        { assert(a); return isNum(a->node()); }
161
164
inline bool isMinusOne  (Tree a)        { assert(a); return isMinusOne(a->node()); }
162
165
 
163
166
//projection pour les groupes r�cursifs
164
 
Tree sigProj (int i, Tree rgroup);      
 
167
Tree sigProj (int i, Tree rgroup);
165
168
bool isProj (Tree t, int* i, Tree& rgroup);
166
169
 
167
 
inline bool isNum(Tree& t, num& n)
 
170
inline bool isNum(const Tree& t, num& n)
168
171
{
169
172
        float           f;
170
173
        int             i;
171
 
        
 
174
 
172
175
        if (isFloat(t->node(), &f)) { n = f; return true;  }
173
176
        if (isInt(t->node(), &i)) { n = i; return true;  }
174
177
        return false;
222
225
Tree sigTuple (int mode, Tree ls);
223
226
bool isSigTuple (Tree s, int* mode, Tree& ls);
224
227
 
225
 
// Access the components of a tuple. 
 
228
// Access the components of a tuple.
226
229
// ts is tuple of signals, idx is a scalar signal between 0..n
227
230
Tree sigTupleAccess(Tree ts, Tree idx);
228
231
bool isSigTupleAccess(Tree s, Tree& ts, Tree& idx);
232
235
 
233
236
 
234
237
 
 
238
/*****************************************************************************
 
239
                                                         access to sub signals of a signal
 
240
*****************************************************************************/
 
241
 
 
242
int     getSubSignals (Tree sig, vector<Tree>& vsigs);
 
243
 
 
244
 
235
245
 
236
246
#endif