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

Subversion Repositories async_sdm_noc

[/] [async_sdm_noc/] [branches/] [init/] [vc/] [src/] [vca.v] - Blame information for rev 70

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 39 wsong0210
/*
2
 Asynchronous SDM NoC
3
 (C)2011 Wei Song
4
 Advanced Processor Technologies Group
5
 Computer Science, the Univ. of Manchester, UK
6
 
7
 Authors:
8
 Wei Song     wsong83@gmail.com
9
 
10
 License: LGPL 3.0 or later
11
 
12
 VC allocator.
13
 
14
 History:
15
 05/04/2010  Initial version. <wsong83@gmail.com>
16
 29/09/2010  Use the asynchronous PIM alg. (MNMA) <wsong83@gmail.com>
17
 03/10/2010  Add VCREN c2n gates to defer the withdrawal of request until data switch is withdrawn. <wsong83@gmail.com>
18
 02/06/2011  Clean up for opensource. <wsong83@gmail.com>
19
 
20
*/
21
 
22
// the router structure definitions
23
`include "define.v"
24
 
25
module vcalloc (/*AUTOARG*/
26
   // Outputs
27
   svcra, wvcra, nvcra, evcra, lvcra, sswa, wswa, nswa, eswa, lswa,
28
   sosr, wosr, nosr, eosr, losr,
29
   // Inputs
30
   svcr, nvcr, lvcr, wvcr, evcr, sswr, wswr, nswr, eswr, lswr, sosa,
31 45 wsong0210
   wosa, nosa, eosa, losa, rst_n
32 39 wsong0210
   );
33
 
34
   parameter VCN = 4;           // number of VCs
35
 
36
   input [VCN-1:0][3:0]            svcr, nvcr, lvcr; // VC requests from input VCs
37
   input [VCN-1:0][1:0]      wvcr, evcr;
38
   output [VCN-1:0]                 svcra,wvcra, nvcra, evcra, lvcra; // ack to VC requests
39
 
40
   input [VCN-1:0][1:0]      sswr, wswr, nswr, eswr, lswr; // SW requests from input VCs
41
   output [VCN-1:0][3:0]     sswa, nswa, lswa;             // ack/routing guide to input VCs
42
   output [VCN-1:0][1:0]     wswa, eswa;
43
 
44
   output [VCN-1:0]                 sosr, wosr, nosr, eosr, losr; // SW requests to output VCs
45
   input [VCN-1:0]                  sosa, wosa, nosa, eosa, losa;
46
 
47 45 wsong0210
   input                           rst_n; // active-low reset
48 39 wsong0210
 
49
   wire [VCN-1:0][3:0]               msvcr, mnvcr, mlvcr; // shuffled VC requests
50
   wire [VCN-1:0][1:0]               mwvcr, mevcr;
51
 
52
   wire [VCN-1:0][3:0][VCN-1:0]    wcfg, ecfg, lcfg; // configuration signals from VCA to Req CB
53
   wire [VCN-1:0][1:0][VCN-1:0]    scfg, ncfg;
54
 
55
   wire [VCN-1:0][3:0][VCN-1:0]    mwcfg, mecfg, mlcfg; // the cfg before the AND gates
56
   wire [VCN-1:0][1:0][VCN-1:0]    mscfg, mncfg;
57
 
58
   wire [VCN-1:0][3:0][VCN-1:0]    wcfga, ecfga, lcfga; // cfg ack from req CB
59
   wire [VCN-1:0][1:0][VCN-1:0]    scfga, ncfga;
60
 
61
`ifndef ENABLE_MRMA
62
   wire [1:0][VCN-1:0][VCN-1:0]    i2sr, i2nr; // input to output requests
63
   wire [3:0][VCN-1:0][VCN-1:0]    i2wr, i2er, i2lr;
64
`else
65
   wire [1:0][VCN-1:0]               i2sr, i2nr; // input to output requests
66
   wire [3:0][VCN-1:0]               i2wr, i2er, i2lr;
67
`endif
68
   wire [1:0][VCN-1:0]               i2sa, i2na; // ack for i2(dir)r
69
   wire [3:0][VCN-1:0]               i2wa, i2ea, i2la;
70
 
71
   // other wires for shuffle purposes
72
   wire [VCN-1:0][3:0][VCN-1:0]    svcram, nvcram, lvcram;
73
   wire [VCN-1:0][1:0][VCN-1:0]    wvcram, evcram;
74
   wire [VCN-1:0][3:0][VCN-1:0]    svcrami, nvcrami, lvcrami;
75
   wire [VCN-1:0][1:0][VCN-1:0]    wvcrami, evcrami;
76
   wire [VCN-1:0][3:0]               svcrai, nvcrai, lvcrai;
77
   wire [VCN-1:0][1:0]               wvcrai, evcrai;
78
   wire [VCN-1:0][3:0]               svcraii, nvcraii, lvcraii;
79
   wire [VCN-1:0][1:0]               wvcraii, evcraii;
80
 
81
`ifdef ENABLE_MRMA
82
   wire [VCN:0]             vcrst_n; // the buffered resets to avoid metastability
83
   wire [VCN-1:0]                   svcrdy, svcrdya; // south vc ready status
84
   wire [VCN-1:0]                   wvcrdy, wvcrdya; // west vc ready status
85
   wire [VCN-1:0]                   nvcrdy, nvcrdya; // north vc ready status
86
   wire [VCN-1:0]                   evcrdy, evcrdya; // east vc ready status
87
   wire [VCN-1:0]                   lvcrdy, lvcrdya; // local vc ready status
88
`endif
89
 
90
   genvar                i, j;
91
 
92
   generate
93
      for(i=0; i<VCN; i++) begin:SF
94
 
95
         assign svcra[i] = {svcrai[i][0]|svcrai[i][1]|svcrai[i][2]|svcrai[i][3]};
96
         assign wvcra[i] = {wvcrai[i][0]|wvcrai[i][1]};
97
         assign nvcra[i] = {nvcrai[i][0]|nvcrai[i][1]|nvcrai[i][2]|nvcrai[i][3]};
98
         assign evcra[i] = {evcrai[i][0]|evcrai[i][1]};
99
         assign lvcra[i] = {lvcrai[i][0]|lvcrai[i][1]|lvcrai[i][2]|lvcrai[i][3]};
100
 
101 45 wsong0210
         or VCRENn0( mnvcr[i][0], nvcr[i][0], (|nvcram[i][0])&rst_n);
102
         or VCRENl0( mlvcr[i][0], lvcr[i][0], (|lvcram[i][0])&rst_n);
103
         or VCRENs0( msvcr[i][0], svcr[i][0], (|svcram[i][0])&rst_n);
104
         or VCRENn1( mnvcr[i][1], nvcr[i][1], (|nvcram[i][1])&rst_n);
105
         or VCRENe0( mevcr[i][0], evcr[i][0], (|evcram[i][0])&rst_n);
106
         or VCRENl1( mlvcr[i][1], lvcr[i][1], (|lvcram[i][1])&rst_n);
107
         or VCRENs1( msvcr[i][1], svcr[i][1], (|svcram[i][1])&rst_n);
108
         or VCRENl2( mlvcr[i][2], lvcr[i][2], (|lvcram[i][2])&rst_n);
109
         or VCRENs2( msvcr[i][2], svcr[i][2], (|svcram[i][2])&rst_n);
110
         or VCRENw0( mwvcr[i][0], wvcr[i][0], (|wvcram[i][0])&rst_n);
111
         or VCRENn2( mnvcr[i][2], nvcr[i][2], (|nvcram[i][2])&rst_n);
112
         or VCRENl3( mlvcr[i][3], lvcr[i][3], (|lvcram[i][3])&rst_n);
113
         or VCRENs3( msvcr[i][3], svcr[i][3], (|svcram[i][3])&rst_n);
114
         or VCRENw1( mwvcr[i][1], wvcr[i][1], (|wvcram[i][1])&rst_n);
115
         or VCRENn3( mnvcr[i][3], nvcr[i][3], (|nvcram[i][3])&rst_n);
116
         or VCRENe1( mevcr[i][1], evcr[i][1], (|evcram[i][1])&rst_n);
117 39 wsong0210
 
118
         and VCAOs0 (svcrai[i][0], (|svcrami[i][0]), svcraii[i][0]);
119
         and VCAOs1 (svcrai[i][1], (|svcrami[i][1]), svcraii[i][1]);
120
         and VCAOs2 (svcrai[i][2], (|svcrami[i][2]), svcraii[i][2]);
121
         and VCAOs3 (svcrai[i][3], (|svcrami[i][3]), svcraii[i][3]);
122
         and VCAOw0 (wvcrai[i][0], (|wvcrami[i][0]), wvcraii[i][0]);
123
         and VCAOw1 (wvcrai[i][1], (|wvcrami[i][1]), wvcraii[i][1]);
124
         and VCAOn0 (nvcrai[i][0], (|nvcrami[i][0]), nvcraii[i][0]);
125
         and VCAOn1 (nvcrai[i][1], (|nvcrami[i][1]), nvcraii[i][1]);
126
         and VCAOn2 (nvcrai[i][2], (|nvcrami[i][2]), nvcraii[i][2]);
127
         and VCAOn3 (nvcrai[i][3], (|nvcrami[i][3]), nvcraii[i][3]);
128
         and VCAOe0 (evcrai[i][0], (|evcrami[i][0]), evcraii[i][0]);
129
         and VCAOe1 (evcrai[i][1], (|evcrami[i][1]), evcraii[i][1]);
130
         and VCAOl0 (lvcrai[i][0], (|lvcrami[i][0]), lvcraii[i][0]);
131
         and VCAOl1 (lvcrai[i][1], (|lvcrami[i][1]), lvcraii[i][1]);
132
         and VCAOl2 (lvcrai[i][2], (|lvcrami[i][2]), lvcraii[i][2]);
133
         and VCAOl3 (lvcrai[i][3], (|lvcrami[i][3]), lvcraii[i][3]);
134
 
135
         or VCAIs0  (svcraii[i][0], (~svcr[i][0]), (|svcram[i][0]));
136
         or VCAIs1  (svcraii[i][1], (~svcr[i][1]), (|svcram[i][1]));
137
         or VCAIs2  (svcraii[i][2], (~svcr[i][2]), (|svcram[i][2]));
138
         or VCAIs3  (svcraii[i][3], (~svcr[i][3]), (|svcram[i][3]));
139
         or VCAIw0  (wvcraii[i][0], (~wvcr[i][0]), (|wvcram[i][0]));
140
         or VCAIw1  (wvcraii[i][1], (~wvcr[i][1]), (|wvcram[i][1]));
141
         or VCAIn0  (nvcraii[i][0], (~nvcr[i][0]), (|nvcram[i][0]));
142
         or VCAIn1  (nvcraii[i][1], (~nvcr[i][1]), (|nvcram[i][1]));
143
         or VCAIn2  (nvcraii[i][2], (~nvcr[i][2]), (|nvcram[i][2]));
144
         or VCAIn3  (nvcraii[i][3], (~nvcr[i][3]), (|nvcram[i][3]));
145
         or VCAIe0  (evcraii[i][0], (~evcr[i][0]), (|evcram[i][0]));
146
         or VCAIe1  (evcraii[i][1], (~evcr[i][1]), (|evcram[i][1]));
147
         or VCAIl0  (lvcraii[i][0], (~lvcr[i][0]), (|lvcram[i][0]));
148
         or VCAIl1  (lvcraii[i][1], (~lvcr[i][1]), (|lvcram[i][1]));
149
         or VCAIl2  (lvcraii[i][2], (~lvcr[i][2]), (|lvcram[i][2]));
150
         or VCAIl3  (lvcraii[i][3], (~lvcr[i][3]), (|lvcram[i][3]));
151
 
152
`ifdef ENABLE_MRMA
153
            assign i2sr[0][i] = mnvcr[i][0];
154
            assign i2sr[1][i] = mlvcr[i][0];
155
            assign i2wr[0][i] = msvcr[i][0];
156
            assign i2wr[1][i] = mnvcr[i][1];
157
            assign i2wr[2][i] = mevcr[i][0];
158
            assign i2wr[3][i] = mlvcr[i][1];
159
            assign i2nr[0][i] = msvcr[i][1];
160
            assign i2nr[1][i] = mlvcr[i][2];
161
            assign i2er[0][i] = msvcr[i][2];
162
            assign i2er[1][i] = mwvcr[i][0];
163
            assign i2er[2][i] = mnvcr[i][2];
164
            assign i2er[3][i] = mlvcr[i][3];
165
            assign i2lr[0][i] = msvcr[i][3];
166
            assign i2lr[1][i] = mwvcr[i][1];
167
            assign i2lr[2][i] = mnvcr[i][3];
168
            assign i2lr[3][i] = mevcr[i][1];
169
`endif //  `ifndef ENABLE_MRMA
170
 
171
         for(j=0; j<VCN; j++) begin : CO
172
`ifndef ENABLE_MRMA
173
            assign i2sr[0][i][j] = mnvcr[i][0];
174
            assign i2sr[1][i][j] = mlvcr[i][0];
175
            assign i2wr[0][i][j] = msvcr[i][0];
176
            assign i2wr[1][i][j] = mnvcr[i][1];
177
            assign i2wr[2][i][j] = mevcr[i][0];
178
            assign i2wr[3][i][j] = mlvcr[i][1];
179
            assign i2nr[0][i][j] = msvcr[i][1];
180
            assign i2nr[1][i][j] = mlvcr[i][2];
181
            assign i2er[0][i][j] = msvcr[i][2];
182
            assign i2er[1][i][j] = mwvcr[i][0];
183
            assign i2er[2][i][j] = mnvcr[i][2];
184
            assign i2er[3][i][j] = mlvcr[i][3];
185
            assign i2lr[0][i][j] = msvcr[i][3];
186
            assign i2lr[1][i][j] = mwvcr[i][1];
187
            assign i2lr[2][i][j] = mnvcr[i][3];
188
            assign i2lr[3][i][j] = mevcr[i][1];
189
`endif //  `ifndef ENABLE_MRMA
190
 
191
            assign svcram[i][0][j] = wcfga[j][0][i];
192
            assign svcram[i][1][j] = ncfga[j][0][i];
193
            assign svcram[i][2][j] = ecfga[j][0][i];
194
            assign svcram[i][3][j] = lcfga[j][0][i];
195
            assign wvcram[i][0][j] = ecfga[j][1][i];
196
            assign wvcram[i][1][j] = lcfga[j][1][i];
197
            assign nvcram[i][0][j] = scfga[j][0][i];
198
            assign nvcram[i][1][j] = wcfga[j][1][i];
199
            assign nvcram[i][2][j] = ecfga[j][2][i];
200
            assign nvcram[i][3][j] = lcfga[j][2][i];
201
            assign evcram[i][0][j] = wcfga[j][2][i];
202
            assign evcram[i][1][j] = lcfga[j][3][i];
203
            assign lvcram[i][0][j] = scfga[j][1][i];
204
            assign lvcram[i][1][j] = wcfga[j][3][i];
205
            assign lvcram[i][2][j] = ncfga[j][1][i];
206
            assign lvcram[i][3][j] = ecfga[j][3][i];
207
 
208
            assign svcrami[i][0][j] = mwcfg[j][0][i];
209
            assign svcrami[i][1][j] = mncfg[j][0][i];
210
            assign svcrami[i][2][j] = mecfg[j][0][i];
211
            assign svcrami[i][3][j] = mlcfg[j][0][i];
212
            assign wvcrami[i][0][j] = mecfg[j][1][i];
213
            assign wvcrami[i][1][j] = mlcfg[j][1][i];
214
            assign nvcrami[i][0][j] = mscfg[j][0][i];
215
            assign nvcrami[i][1][j] = mwcfg[j][1][i];
216
            assign nvcrami[i][2][j] = mecfg[j][2][i];
217
            assign nvcrami[i][3][j] = mlcfg[j][2][i];
218
            assign evcrami[i][0][j] = mwcfg[j][2][i];
219
            assign evcrami[i][1][j] = mlcfg[j][3][i];
220
            assign lvcrami[i][0][j] = mscfg[j][1][i];
221
            assign lvcrami[i][1][j] = mwcfg[j][3][i];
222
            assign lvcrami[i][2][j] = mncfg[j][1][i];
223
            assign lvcrami[i][3][j] = mecfg[j][3][i];
224
 
225
            and CFGENw0 (wcfg[j][0][i], svcr[i][0], mwcfg[j][0][i]);
226
            and CFGENn0 (ncfg[j][0][i], svcr[i][1], mncfg[j][0][i]);
227
            and CFGENe0 (ecfg[j][0][i], svcr[i][2], mecfg[j][0][i]);
228
            and CFGENl0 (lcfg[j][0][i], svcr[i][3], mlcfg[j][0][i]);
229
            and CFGENe1 (ecfg[j][1][i], wvcr[i][0], mecfg[j][1][i]);
230
            and CFGENl1 (lcfg[j][1][i], wvcr[i][1], mlcfg[j][1][i]);
231
            and CFGENs0 (scfg[j][0][i], nvcr[i][0], mscfg[j][0][i]);
232
            and CFGENw1 (wcfg[j][1][i], nvcr[i][1], mwcfg[j][1][i]);
233
            and CFGENe2 (ecfg[j][2][i], nvcr[i][2], mecfg[j][2][i]);
234
            and CFGENl2 (lcfg[j][2][i], nvcr[i][3], mlcfg[j][2][i]);
235
            and CFGENw2 (wcfg[j][2][i], evcr[i][0], mwcfg[j][2][i]);
236
            and CFGENl3 (lcfg[j][3][i], evcr[i][1], mlcfg[j][3][i]);
237
            and CFGENs1 (scfg[j][1][i], lvcr[i][0], mscfg[j][1][i]);
238
            and CFGENw3 (wcfg[j][3][i], lvcr[i][1], mwcfg[j][3][i]);
239
            and CFGENn1 (ncfg[j][1][i], lvcr[i][2], mncfg[j][1][i]);
240
            and CFGENe3 (ecfg[j][3][i], lvcr[i][3], mecfg[j][3][i]);
241
         end // block: CO 
242
      end // block: SF
243
   endgenerate
244
 
245
   // the requests crossbar
246 42 wsong0210
   rcb_vc #(.VCN(VCN))
247 39 wsong0210
   RSW (
248
        .ro    ( {losr, eosr, nosr, wosr, sosr} ),
249
        .srt   ( sswa                           ),
250
        .wrt   ( wswa                           ),
251
        .nrt   ( nswa                           ),
252
        .ert   ( eswa                           ),
253
        .lrt   ( lswa                           ),
254
        .ri    ( {lswr, eswr, nswr, wswr, sswr} ),
255
        .go    ( {losa, eosa, nosa, wosa, sosa} ),
256
        .wctl  ( wcfg                           ),
257
        .ectl  ( ecfg                           ),
258
        .lctl  ( lcfg                           ),
259
        .sctl  ( scfg                           ),
260
        .nctl  ( ncfg                           ),
261
        .wctla ( wcfga                          ),
262
        .ectla ( ecfga                          ),
263
        .lctla ( lcfga                          ),
264
        .sctla ( scfga                          ),
265
        .nctla ( ncfga                          )
266
        );
267
 
268
   // the VC allocators
269
`ifndef ENABLE_MRMA
270
   mnma #(.N(2*VCN), .M(VCN))
271
   SVA (
272
        .r     ( i2sr   ),
273
        .cfg   ( mscfg  ),
274
        .ra    (        )
275
        );
276
 
277
   mnma #(.N(4*VCN), .M(VCN))
278
   WVA (
279
        .r     ( i2wr   ),
280
        .cfg   ( mwcfg  ),
281
        .ra    (        )
282
        );
283
 
284
   mnma #(.N(2*VCN), .M(VCN))
285
   NVA (
286
        .r     ( i2nr   ),
287
        .cfg   ( mncfg  ),
288
        .ra    (        )
289
        );
290
 
291
   mnma #(.N(4*VCN), .M(VCN))
292
   EVA (
293
        .r     ( i2er   ),
294
        .cfg   ( mecfg  ),
295
        .ra    (        )
296
        );
297
 
298
   mnma #(.N(4*VCN), .M(VCN))
299
   LVA (
300
        .r     ( i2lr   ),
301
        .cfg   ( mlcfg  ),
302
        .ra    (        )
303
        );
304
`else // !`ifndef ENABLE_MRMA
305
   mrma #(.N(2*VCN), .M(VCN))
306
   SVA (
307
        .c     ( i2sr    ),
308
        .cfg   ( mscfg   ),
309
        .ca    (         ),
310
        .r     ( svcrdy  ),
311
        .ra    ( svcrdya ),
312 45 wsong0210
        .rst_n ( rst_n   )
313 39 wsong0210
        );
314
 
315
   mrma #(.N(4*VCN), .M(VCN))
316
   WVA (
317
        .c     ( i2wr    ),
318
        .cfg   ( mwcfg   ),
319
        .ca    (         ),
320
        .r     ( wvcrdy  ),
321
        .ra    ( wvcrdya ),
322 45 wsong0210
        .rst_n ( rst_n   )
323 39 wsong0210
        );
324
 
325
   mrma #(.N(2*VCN), .M(VCN))
326
   NVA (
327
        .c     ( i2nr    ),
328
        .cfg   ( mncfg   ),
329
        .ca    (         ),
330
        .r     ( nvcrdy  ),
331
        .ra    ( nvcrdya ),
332 45 wsong0210
        .rst_n ( rst_n   )
333 39 wsong0210
        );
334
 
335
   mrma #(.N(4*VCN), .M(VCN))
336
   EVA (
337
        .c     ( i2er    ),
338
        .cfg   ( mecfg   ),
339
        .ca    (         ),
340
        .r     ( evcrdy  ),
341
        .ra    ( evcrdya ),
342 45 wsong0210
        .rst_n ( rst_n   )
343 39 wsong0210
        );
344
 
345
   mrma #(.N(4*VCN), .M(VCN))
346
   LVA (
347
        .c     ( i2lr    ),
348
        .cfg   ( mlcfg   ),
349
        .ca    (         ),
350
        .r     ( lvcrdy  ),
351
        .ra    ( lvcrdya ),
352 45 wsong0210
        .rst_n ( rst_n   )
353 39 wsong0210
        );
354
 
355
   generate
356
      for(i=0; i<VCN; i++) begin: OPC
357
         delay DLY ( .q(vcrst_n[i+1]), .a(vcrst_n[i])); // dont touch
358
         assign svcrdy[i] = (~svcrdya[i])&vcrst_n[i+1];
359
         assign wvcrdy[i] = (~wvcrdya[i])&vcrst_n[i+1];
360
         assign nvcrdy[i] = (~nvcrdya[i])&vcrst_n[i+1];
361
         assign evcrdy[i] = (~evcrdya[i])&vcrst_n[i+1];
362
         assign lvcrdy[i] = (~lvcrdya[i])&vcrst_n[i+1];
363
      end
364
   endgenerate
365
 
366
   assign vcrst_n[0] = rst_n;
367
 
368
`endif // !`ifndef ENABLE_MRMA
369
 
370
endmodule // vcalloc
371
 
372
/*   logic of the control logic generated from petrify
373
 
374
// Verilog model for vca_ctl
375
// Generated by petrify 4.2 (compiled 15-Oct-03 at 3:06 PM)
376
// CPU time for synthesis (host <unknown>): 0.04 seconds
377
// Estimated area = 72.00
378
 
379
// The circuit is self-resetting and does not need reset pin.
380
 
381
module vca_ctl_net (
382
    vcri,
383
    cfg,
384
    vcrai,
385
    vcro,
386
    cfgen,
387
    vcrao
388
);
389
 
390
input vcri;
391
input cfg;
392
input vcrai;
393
 
394
output vcro;
395
output cfgen;
396
output vcrao;
397
 
398
 
399
// Functions not mapped into library gates:
400
// ----------------------------------------
401
 
402
// Equation: vcro = vcri + vcrai
403
or _U0 (vcro, vcrai, vcri);
404
 
405
// Equation: cfgen = vcri
406
buf _U1 (cfgen, vcri);
407
 
408
// Equation: vcrao = cfg (vcri' + vcrai)
409
not _U1 (_X1, vcri);
410
and _U2 (_X0, vcrai, cfg);
411
and _U3 (_X2, cfg, _X1);
412
or _U4 (vcrao, _X0, _X2);
413
 
414
 
415
// signal values at the initial state:
416
//     !vcri !cfg !vcrai !vcro !cfgen !vcrao
417
endmodule
418
*/

powered by: WebSVN 2.1.0

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