OpenCores
URL https://opencores.org/ocsvn/spacewiresystemc/spacewiresystemc/trunk

Subversion Repositories spacewiresystemc

[/] [spacewiresystemc/] [trunk/] [systemC/] [tx_clock.h] - Blame information for rev 40

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 29 redbear
#ifndef SPW_TX_CLOCK_H
2
#define SPW_TX_CLOCK_H
3
 
4
class CLOCK_WIRE_SC;
5
 
6
SC_MODULE(CLOCK_WIRE_SC)
7
{
8
        sc_in<bool> CLOCK_TX;
9
        sc_in<bool> ENABLE;
10
        sc_out<bool> CLOCK_TX_OUT;
11
 
12
        void TX_CLOCK_M()
13
        {
14
                if(ENABLE)
15
                        CLOCK_TX_OUT = CLOCK_TX;
16
        }
17
        SC_CTOR(CLOCK_WIRE_SC)
18
        {
19
                SC_METHOD(TX_CLOCK_M);
20
                sensitive << CLOCK_TX << ENABLE.pos();
21
        }
22
};
23
 
24
class SPW_TX_CLOCK_SC;
25
 
26
SC_MODULE(SPW_TX_CLOCK_SC)
27
{
28
 
29
        sc_clock CLOCK_2MHZ;
30
        sc_clock CLOCK_10MHZ;
31
        sc_clock CLOCK_20MHZ;
32
        sc_clock CLOCK_50MHZ;
33
        sc_clock CLOCK_100MHZ;
34
        sc_clock CLOCK_150MHZ;
35
        sc_clock CLOCK_200MHZ;
36
        sc_clock CLOCK_201MHZ;
37
        sc_clock CLOCK_250MHZ;
38
        sc_clock CLOCK_280MHZ;
39
        sc_clock CLOCK_500MHZ;
40
 
41
        sc_in<sc_uint<10> > CLOCK_GEN;
42
        sc_in<bool> RESET;
43
        sc_out<bool> CLOCK_TX_OUT;
44
 
45
        CLOCK_WIRE_SC DUT_2MHZ;
46
        sc_signal<bool> CLOCK_TX_OUT_2MHZ_ENABLE;
47
        sc_signal<bool> CLOCK_TX_OUT_2MHZ;
48
 
49
        CLOCK_WIRE_SC DUT_10MHZ;
50
        sc_signal<bool> CLOCK_TX_OUT_10MHZ_ENABLE;
51
        sc_signal<bool> CLOCK_TX_OUT_10MHZ;
52
 
53
        CLOCK_WIRE_SC DUT_20MHZ;
54
        sc_signal<bool> CLOCK_TX_OUT_20MHZ_ENABLE;
55
        sc_signal<bool> CLOCK_TX_OUT_20MHZ;
56
 
57
        CLOCK_WIRE_SC DUT_50MHZ;
58
        sc_signal<bool> CLOCK_TX_OUT_50MHZ_ENABLE;
59
        sc_signal<bool> CLOCK_TX_OUT_50MHZ;
60
 
61
        CLOCK_WIRE_SC DUT_100MHZ;
62
        sc_signal<bool> CLOCK_TX_OUT_100MHZ_ENABLE;
63
        sc_signal<bool> CLOCK_TX_OUT_100MHZ;
64
 
65
        CLOCK_WIRE_SC DUT_150MHZ;
66
        sc_signal<bool> CLOCK_TX_OUT_150MHZ_ENABLE;
67
        sc_signal<bool> CLOCK_TX_OUT_150MHZ;
68
 
69
        CLOCK_WIRE_SC DUT_200MHZ;
70
        sc_signal<bool> CLOCK_TX_OUT_200MHZ_ENABLE;
71
        sc_signal<bool> CLOCK_TX_OUT_200MHZ;
72
 
73
        CLOCK_WIRE_SC DUT_201MHZ;
74
        sc_signal<bool> CLOCK_TX_OUT_201MHZ_ENABLE;
75
        sc_signal<bool> CLOCK_TX_OUT_201MHZ;
76
 
77
        CLOCK_WIRE_SC DUT_250MHZ;
78
        sc_signal<bool> CLOCK_TX_OUT_250MHZ_ENABLE;
79
        sc_signal<bool> CLOCK_TX_OUT_250MHZ;
80
 
81
        CLOCK_WIRE_SC DUT_280MHZ;
82
        sc_signal<bool> CLOCK_TX_OUT_280MHZ_ENABLE;
83
        sc_signal<bool> CLOCK_TX_OUT_280MHZ;
84
 
85
        void ENABLE()
86
        {
87
                //cout << CLOCK_GEN.read() << endl;
88
                switch(CLOCK_GEN.read())
89
                {
90
                        case 1:
91
                                CLOCK_TX_OUT_2MHZ_ENABLE   = true;
92
                                CLOCK_TX_OUT_10MHZ_ENABLE  = false;
93
                                CLOCK_TX_OUT_20MHZ_ENABLE  = false;
94
                                CLOCK_TX_OUT_50MHZ_ENABLE  = false;
95
                                CLOCK_TX_OUT_100MHZ_ENABLE = false;
96
                                CLOCK_TX_OUT_150MHZ_ENABLE = false;
97
                                CLOCK_TX_OUT_200MHZ_ENABLE = false;
98
                                CLOCK_TX_OUT_201MHZ_ENABLE = false;
99
                                CLOCK_TX_OUT_250MHZ_ENABLE = false;
100
                                CLOCK_TX_OUT_280MHZ_ENABLE = false;
101
                        break;
102
                        case 2:
103
                                CLOCK_TX_OUT_2MHZ_ENABLE   = false;
104
                                CLOCK_TX_OUT_10MHZ_ENABLE  = true;
105
                                CLOCK_TX_OUT_20MHZ_ENABLE  = false;
106
                                CLOCK_TX_OUT_50MHZ_ENABLE  = false;
107
                                CLOCK_TX_OUT_100MHZ_ENABLE = false;
108
                                CLOCK_TX_OUT_150MHZ_ENABLE = false;
109
                                CLOCK_TX_OUT_200MHZ_ENABLE = false;
110
                                CLOCK_TX_OUT_201MHZ_ENABLE = false;
111
                                CLOCK_TX_OUT_250MHZ_ENABLE = false;
112
                                CLOCK_TX_OUT_280MHZ_ENABLE = false;
113
                        break;
114
                        case 4:
115
                                CLOCK_TX_OUT_2MHZ_ENABLE   = false;
116
                                CLOCK_TX_OUT_10MHZ_ENABLE  = false;
117
                                CLOCK_TX_OUT_20MHZ_ENABLE  = true;
118
                                CLOCK_TX_OUT_50MHZ_ENABLE  = false;
119
                                CLOCK_TX_OUT_100MHZ_ENABLE = false;
120
                                CLOCK_TX_OUT_150MHZ_ENABLE = false;
121
                                CLOCK_TX_OUT_200MHZ_ENABLE = false;
122
                                CLOCK_TX_OUT_201MHZ_ENABLE = false;
123
                                CLOCK_TX_OUT_250MHZ_ENABLE = false;
124
                                CLOCK_TX_OUT_280MHZ_ENABLE = false;
125
                        break;
126
                        case 8:
127
                                CLOCK_TX_OUT_2MHZ_ENABLE   = false;
128
                                CLOCK_TX_OUT_10MHZ_ENABLE  = false;
129
                                CLOCK_TX_OUT_20MHZ_ENABLE  = false;
130
                                CLOCK_TX_OUT_50MHZ_ENABLE  = true;
131
                                CLOCK_TX_OUT_100MHZ_ENABLE = false;
132
                                CLOCK_TX_OUT_150MHZ_ENABLE = false;
133
                                CLOCK_TX_OUT_200MHZ_ENABLE = false;
134
                                CLOCK_TX_OUT_201MHZ_ENABLE = false;
135
                                CLOCK_TX_OUT_250MHZ_ENABLE = false;
136
                                CLOCK_TX_OUT_280MHZ_ENABLE = false;
137
                        break;
138
                        case 16:
139
                                CLOCK_TX_OUT_2MHZ_ENABLE   = false;
140
                                CLOCK_TX_OUT_10MHZ_ENABLE  = false;
141
                                CLOCK_TX_OUT_20MHZ_ENABLE  = false;
142
                                CLOCK_TX_OUT_50MHZ_ENABLE  = false;
143
                                CLOCK_TX_OUT_100MHZ_ENABLE = true;
144
                                CLOCK_TX_OUT_150MHZ_ENABLE = false;
145
                                CLOCK_TX_OUT_200MHZ_ENABLE = false;
146
                                CLOCK_TX_OUT_201MHZ_ENABLE = false;
147
                                CLOCK_TX_OUT_250MHZ_ENABLE = false;
148
                                CLOCK_TX_OUT_280MHZ_ENABLE = false;
149
                        break;
150
                        case 32:
151
                                CLOCK_TX_OUT_2MHZ_ENABLE   = false;
152
                                CLOCK_TX_OUT_10MHZ_ENABLE  = false;
153
                                CLOCK_TX_OUT_20MHZ_ENABLE  = false;
154
                                CLOCK_TX_OUT_50MHZ_ENABLE  = false;
155
                                CLOCK_TX_OUT_100MHZ_ENABLE = false;
156
                                CLOCK_TX_OUT_150MHZ_ENABLE = true;
157
                                CLOCK_TX_OUT_200MHZ_ENABLE = false;
158
                                CLOCK_TX_OUT_201MHZ_ENABLE = false;
159
                                CLOCK_TX_OUT_250MHZ_ENABLE = false;
160
                                CLOCK_TX_OUT_280MHZ_ENABLE = false;
161
                        break;
162
                        case 64:
163
                                CLOCK_TX_OUT_2MHZ_ENABLE   = false;
164
                                CLOCK_TX_OUT_10MHZ_ENABLE  = false;
165
                                CLOCK_TX_OUT_20MHZ_ENABLE  = false;
166
                                CLOCK_TX_OUT_50MHZ_ENABLE  = false;
167
                                CLOCK_TX_OUT_100MHZ_ENABLE = false;
168
                                CLOCK_TX_OUT_150MHZ_ENABLE = false;
169
                                CLOCK_TX_OUT_200MHZ_ENABLE = true;
170
                                CLOCK_TX_OUT_201MHZ_ENABLE = false;
171
                                CLOCK_TX_OUT_250MHZ_ENABLE = false;
172
                                CLOCK_TX_OUT_280MHZ_ENABLE = false;
173
                        break;
174
                        case 128:
175
                                CLOCK_TX_OUT_2MHZ_ENABLE   = false;
176
                                CLOCK_TX_OUT_10MHZ_ENABLE  = false;
177
                                CLOCK_TX_OUT_20MHZ_ENABLE  = false;
178
                                CLOCK_TX_OUT_50MHZ_ENABLE  = false;
179
                                CLOCK_TX_OUT_100MHZ_ENABLE = false;
180
                                CLOCK_TX_OUT_150MHZ_ENABLE = false;
181
                                CLOCK_TX_OUT_200MHZ_ENABLE = false;
182
                                CLOCK_TX_OUT_201MHZ_ENABLE = true;
183
                                CLOCK_TX_OUT_250MHZ_ENABLE = false;
184
                                CLOCK_TX_OUT_280MHZ_ENABLE = false;
185
                        break;
186
                        case 256:
187
                                CLOCK_TX_OUT_2MHZ_ENABLE   = false;
188
                                CLOCK_TX_OUT_10MHZ_ENABLE  = false;
189
                                CLOCK_TX_OUT_20MHZ_ENABLE  = false;
190
                                CLOCK_TX_OUT_50MHZ_ENABLE  = false;
191
                                CLOCK_TX_OUT_100MHZ_ENABLE = false;
192
                                CLOCK_TX_OUT_150MHZ_ENABLE = false;
193
                                CLOCK_TX_OUT_200MHZ_ENABLE = false;
194
                                CLOCK_TX_OUT_201MHZ_ENABLE = false;
195
                                CLOCK_TX_OUT_250MHZ_ENABLE = true;
196
                                CLOCK_TX_OUT_280MHZ_ENABLE = false;
197
                        break;
198
                        case 512:
199
                                CLOCK_TX_OUT_2MHZ_ENABLE   = false;
200
                                CLOCK_TX_OUT_10MHZ_ENABLE  = false;
201
                                CLOCK_TX_OUT_20MHZ_ENABLE  = false;
202
                                CLOCK_TX_OUT_50MHZ_ENABLE  = false;
203
                                CLOCK_TX_OUT_100MHZ_ENABLE = false;
204
                                CLOCK_TX_OUT_150MHZ_ENABLE = false;
205
                                CLOCK_TX_OUT_200MHZ_ENABLE = false;
206
                                CLOCK_TX_OUT_201MHZ_ENABLE = false;
207
                                CLOCK_TX_OUT_250MHZ_ENABLE = false;
208
                                CLOCK_TX_OUT_280MHZ_ENABLE = true;
209
                        break;
210
                        default:
211
                                CLOCK_TX_OUT_2MHZ_ENABLE   = false;
212
                                CLOCK_TX_OUT_10MHZ_ENABLE  = true;
213
                                CLOCK_TX_OUT_20MHZ_ENABLE  = false;
214
                                CLOCK_TX_OUT_50MHZ_ENABLE  = false;
215
                                CLOCK_TX_OUT_100MHZ_ENABLE = false;
216
                                CLOCK_TX_OUT_150MHZ_ENABLE = false;
217
                                CLOCK_TX_OUT_200MHZ_ENABLE = false;
218
                                CLOCK_TX_OUT_201MHZ_ENABLE = false;
219
                                CLOCK_TX_OUT_250MHZ_ENABLE = false;
220
                                CLOCK_TX_OUT_280MHZ_ENABLE = false;
221
                        break;
222
                }
223
        }
224
 
225
        void CLK_GEN()
226
        {
227
                if(!RESET)
228
                {
229
                        CLOCK_TX_OUT = CLOCK_TX_OUT_2MHZ;
230
                }
231
                else
232
                {
233
                        if(CLOCK_TX_OUT_2MHZ_ENABLE)
234
                                CLOCK_TX_OUT = CLOCK_TX_OUT_2MHZ;
235
                        else if(CLOCK_TX_OUT_10MHZ_ENABLE)
236
                                CLOCK_TX_OUT = CLOCK_TX_OUT_10MHZ;
237
                        else if(CLOCK_TX_OUT_20MHZ_ENABLE)
238
                                CLOCK_TX_OUT = CLOCK_TX_OUT_20MHZ;
239
                        else if(CLOCK_TX_OUT_50MHZ_ENABLE)
240
                                CLOCK_TX_OUT = CLOCK_TX_OUT_50MHZ;
241
                        else if(CLOCK_TX_OUT_100MHZ_ENABLE)
242
                                CLOCK_TX_OUT = CLOCK_TX_OUT_100MHZ;
243
                        else if(CLOCK_TX_OUT_150MHZ_ENABLE)
244
                                CLOCK_TX_OUT = CLOCK_TX_OUT_150MHZ;
245
                        else if(CLOCK_TX_OUT_200MHZ_ENABLE)
246
                                CLOCK_TX_OUT = CLOCK_TX_OUT_200MHZ;
247
                        else if(CLOCK_TX_OUT_201MHZ_ENABLE)
248
                                CLOCK_TX_OUT = CLOCK_TX_OUT_201MHZ;
249
                        else if(CLOCK_TX_OUT_250MHZ_ENABLE)
250
                                CLOCK_TX_OUT = CLOCK_TX_OUT_250MHZ;
251
                        else if(CLOCK_TX_OUT_280MHZ_ENABLE)
252
                                CLOCK_TX_OUT = CLOCK_TX_OUT_280MHZ;
253
                }
254
                #ifdef TESTE
255
                cout << "2MHZ"   << " " << CLOCK_TX_OUT_2MHZ_ENABLE   <<endl;
256
                cout << "10MHZ"  << " " << CLOCK_TX_OUT_10MHZ_ENABLE  <<endl;
257
                cout << "20MHZ"  << " " << CLOCK_TX_OUT_20MHZ_ENABLE  <<endl;
258
                cout << "50MHZ"  << " " << CLOCK_TX_OUT_50MHZ_ENABLE  <<endl;
259
                cout << "100MHZ" << " " << CLOCK_TX_OUT_100MHZ_ENABLE <<endl;
260
                cout << "150MHZ" << " " << CLOCK_TX_OUT_150MHZ_ENABLE <<endl;
261
                cout << "200MHZ" << " " << CLOCK_TX_OUT_200MHZ_ENABLE <<endl;
262
                cout << "201MHZ" << " " << CLOCK_TX_OUT_201MHZ_ENABLE <<endl;
263
                cout << "250MHZ" << " " << CLOCK_TX_OUT_250MHZ_ENABLE <<endl;
264
                cout << "280MHZ" << " " << CLOCK_TX_OUT_280MHZ_ENABLE <<endl;
265
                #endif
266
        }
267
 
268
        SC_CTOR(SPW_TX_CLOCK_SC):CLOCK_2MHZ("CLOCK_2MHZ",500,SC_NS),
269
                                 CLOCK_10MHZ("CLOCK_10MHZ",100,SC_NS),
270
                                 CLOCK_20MHZ("CLOCK_20MHZ",50,SC_NS),
271
                                 CLOCK_50MHZ("CLOCK_50MHZ",20,SC_NS),
272
                                 CLOCK_100MHZ("CLOCK_100MHZ",10,SC_NS),
273
                                 CLOCK_150MHZ("CLOCK_150MHZ",6.667,SC_NS),
274
                                 CLOCK_200MHZ("CLOCK_200MHZ",5,SC_NS),
275
                                 CLOCK_201MHZ("CLOCK_201MHZ",4.975,SC_NS),
276
                                 CLOCK_250MHZ("CLOCK_250MHZ",4,SC_NS),
277
                                 CLOCK_280MHZ("CLOCK_280MHZ",3.571,SC_NS),
278
                                 DUT_2MHZ("DUT_2MHZ"),
279
                                 DUT_10MHZ("DUT_10MHZ"),
280
                                 DUT_20MHZ("DUT_20MHZ"),
281
                                 DUT_50MHZ("DUT_50MHZ"),
282
                                 DUT_100MHZ("DUT_100MHZ"),
283
                                 DUT_150MHZ("DUT_150MHZ"),
284
                                 DUT_200MHZ("DUT_200MHZ"),
285
                                 DUT_201MHZ("DUT_201MHZ"),
286
                                 DUT_250MHZ("DUT_250MHZ"),
287
                                 DUT_280MHZ("DUT_280MHZ")
288
        {
289
                SC_METHOD(ENABLE);
290
                sensitive << CLOCK_GEN << RESET;
291
 
292
                SC_METHOD(CLK_GEN);
293
                sensitive << CLOCK_500MHZ;
294
 
295
                DUT_2MHZ.CLOCK_TX(CLOCK_2MHZ);
296
                DUT_2MHZ.ENABLE(CLOCK_TX_OUT_2MHZ_ENABLE);
297
                DUT_2MHZ.CLOCK_TX_OUT(CLOCK_TX_OUT_2MHZ);
298
 
299
                DUT_10MHZ.CLOCK_TX(CLOCK_10MHZ);
300
                DUT_10MHZ.ENABLE(CLOCK_TX_OUT_10MHZ_ENABLE);
301
                DUT_10MHZ.CLOCK_TX_OUT(CLOCK_TX_OUT_10MHZ);
302
 
303
                DUT_20MHZ.CLOCK_TX(CLOCK_20MHZ);
304
                DUT_20MHZ.ENABLE(CLOCK_TX_OUT_20MHZ_ENABLE);
305
                DUT_20MHZ.CLOCK_TX_OUT(CLOCK_TX_OUT_20MHZ);
306
 
307
                DUT_50MHZ.CLOCK_TX(CLOCK_50MHZ);
308
                DUT_50MHZ.ENABLE(CLOCK_TX_OUT_50MHZ_ENABLE);
309
                DUT_50MHZ.CLOCK_TX_OUT(CLOCK_TX_OUT_50MHZ);
310
 
311
                DUT_100MHZ.CLOCK_TX(CLOCK_100MHZ);
312
                DUT_100MHZ.ENABLE(CLOCK_TX_OUT_100MHZ_ENABLE);
313
                DUT_100MHZ.CLOCK_TX_OUT(CLOCK_TX_OUT_100MHZ);
314
 
315
                DUT_150MHZ.CLOCK_TX(CLOCK_150MHZ);
316
                DUT_150MHZ.ENABLE(CLOCK_TX_OUT_150MHZ_ENABLE);
317
                DUT_150MHZ.CLOCK_TX_OUT(CLOCK_TX_OUT_150MHZ);
318
 
319
                DUT_200MHZ.CLOCK_TX(CLOCK_200MHZ);
320
                DUT_200MHZ.ENABLE(CLOCK_TX_OUT_200MHZ_ENABLE);
321
                DUT_200MHZ.CLOCK_TX_OUT(CLOCK_TX_OUT_200MHZ);
322
 
323
                DUT_201MHZ.CLOCK_TX(CLOCK_201MHZ);
324
                DUT_201MHZ.ENABLE(CLOCK_TX_OUT_201MHZ_ENABLE);
325
                DUT_201MHZ.CLOCK_TX_OUT(CLOCK_TX_OUT_201MHZ);
326
 
327
                DUT_250MHZ.CLOCK_TX(CLOCK_250MHZ);
328
                DUT_250MHZ.ENABLE(CLOCK_TX_OUT_250MHZ_ENABLE);
329
                DUT_250MHZ.CLOCK_TX_OUT(CLOCK_TX_OUT_250MHZ);
330
 
331
                DUT_280MHZ.CLOCK_TX(CLOCK_280MHZ);
332
                DUT_280MHZ.ENABLE(CLOCK_TX_OUT_280MHZ_ENABLE);
333
                DUT_280MHZ.CLOCK_TX_OUT(CLOCK_TX_OUT_280MHZ);
334
        }
335
};
336
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.