source: trunk/platforms/tsarv4_generic_xbar/tsarv4_cluster_xbar/caba/source/src/tsarv4_cluster_xbar.cpp @ 167

Last change on this file since 167 was 167, checked in by kane, 13 years ago

delete all timeout reference (multi write buffer)

File size: 19.3 KB
Line 
1#include "../include/tsarv4_cluster_xbar.h"
2
3namespace soclib {
4namespace caba  {
5
6//////////////////////////////////////////////////////////////////////////
7//                 Constructor
8//////////////////////////////////////////////////////////////////////////
9template<typename vci_param, typename iss_t, int cmd_width, int rsp_width>
10TsarV4ClusterXbar<vci_param, iss_t, cmd_width, rsp_width>::TsarV4ClusterXbar(
11                        sc_module_name  insname,
12                        size_t          nprocs,
13                        size_t          x_id,
14                        size_t          y_id,
15                        size_t          cluster_id,
16                        const           soclib::common::MappingTable &mtd,
17                        const           soclib::common::MappingTable &mtc, 
18                        const           soclib::common::MappingTable &mtx, 
19                        size_t          x_width,
20                        size_t          y_width,
21                        size_t          tgtid_memc,
22                        size_t          tgtid_xicu,
23                        size_t          tgtid_fbuf,
24                        size_t          tgtid_mtty,
25                        size_t          tgtid_brom,
26                        size_t          tgtid_bdev,
27                        size_t          tgtid_mdma,
28                        size_t          memc_ways,
29                        size_t          memc_sets,
30                        size_t          l1_i_ways,
31                        size_t          l1_i_sets,
32                        size_t          l1_d_ways,
33                        size_t          l1_d_sets,
34                        size_t          xram_latency,
35                        bool            io,
36                        size_t          xfb,
37                        size_t          yfb,
38                        char*           disk_name,
39                        size_t          block_size,
40                        Loader          loader)
41      : soclib::caba::BaseModule(insname),
42        p_clk("clk"),
43        p_resetn("resetn"),
44
45        signal_dspin_cmd_l2g_d("signal_dspin_cmd_l2g_d"),
46        signal_dspin_cmd_g2l_d("signal_dspin_cmd_g2l_d"),
47        signal_dspin_cmd_l2g_c("signal_dspin_cmd_l2g_c"),
48        signal_dspin_cmd_g2l_c("signal_dspin_cmd_g2l_c"),
49        signal_dspin_rsp_l2g_d("signal_dspin_rsp_l2g_d"),
50        signal_dspin_rsp_g2l_d("signal_dspin_rsp_g2l_d"),
51        signal_dspin_rsp_l2g_c("signal_dspin_rsp_l2g_c"),
52        signal_dspin_rsp_g2l_c("signal_dspin_rsp_g2l_c"),
53
54        signal_vci_ini_d_bdev("signal_vci_ini_d_bdev"),
55        signal_vci_ini_d_mdma("signal_vci_ini_d_mdma"),
56
57        signal_vci_tgt_d_memc("signal_vci_tgt_d_memc"),
58        signal_vci_tgt_d_mtty("signal_vci_tgt_d_mtty"),
59        signal_vci_tgt_d_xicu("signal_vci_tgt_d_xicu"),
60        signal_vci_tgt_d_bdev("signal_vci_tgt_d_bdev"),
61        signal_vci_tgt_d_mdma("signal_vci_tgt_d_mdma"),
62        signal_vci_tgt_d_brom("signal_vci_tgt_d_brom"),
63        signal_vci_tgt_d_fbuf("signal_vci_tgt_d_fbuf"),
64
65        signal_vci_ini_c_memc("signal_vci_ini_c_memc"), 
66        signal_vci_tgt_c_memc("signal_vci_tgt_c_memc"),
67
68        signal_vci_xram("signal_vci_xram")
69
70{
71        // Vectors of ports definition
72
73        p_cmd_in        = alloc_elems<DspinInput<cmd_width> >("p_cmd_in", 2, 4);
74        p_cmd_out       = alloc_elems<DspinOutput<cmd_width> >("p_cmd_out", 2, 4);
75        p_rsp_in        = alloc_elems<DspinInput<rsp_width> >("p_rsp_in", 2, 4);
76        p_rsp_out       = alloc_elems<DspinOutput<rsp_width> >("p_rsp_out", 2, 4);
77
78        // Components definition
79
80        // on direct network : local srcid[proc] in [0...nprocs-1]
81        // on direct network : local srcid[mdma] = nprocs
82        // on direct network : local srcid[bdev] = nprocs + 1
83
84        // on coherence network : local srcid[proc] in [0...nprocs-1]
85        // on coherence network : local srcid[memc] = nprocs
86
87std::cout << "  - building proc_" << x_id << "_" << y_id << "-*" << std::endl;
88
89        for ( size_t p=0 ; p<nprocs ; p++ )
90        { 
91            std::ostringstream sproc;
92            sproc << "proc_" << x_id << "_" << y_id << "_" << p;
93            proc[p] = new VciCcXCacheWrapperV4<vci_param, iss_t>(
94                sproc.str().c_str(),
95                cluster_id*nprocs + p,
96                mtd, mtc,
97                IntTab(cluster_id,p),           // SRCID_D
98                IntTab(cluster_id,p),           // SRCID_C
99                IntTab(cluster_id,p),           // TGTID_C
100                l1_i_ways,l1_i_sets,16,         // ICACHE size
101                l1_d_ways,l1_d_sets,16,         // DCACHE size
102                16,                             // WBUF width
103                1                               // WBUF depth
104                );
105        }
106
107std::cout << "  - building memc_" << x_id << "_" << y_id << std::endl;
108
109        std::ostringstream smemc;
110        smemc << "memc_" << x_id << "_" << y_id;
111        memc = new VciMemCacheV4<vci_param>(
112                   smemc.str().c_str(),
113                   mtd, mtc, mtx,
114                   IntTab(cluster_id),                  // SRCID_X
115                   IntTab(cluster_id, nprocs),          // SRCID_C
116                   IntTab(cluster_id, tgtid_memc),      // TGTID_D
117                   IntTab(cluster_id, nprocs),          // TGTID_C
118                   memc_ways, memc_sets, 16,            // CACHE SIZE
119                   4096,                                // HEAP SIZE
120                   8,                                   // TRANSACTION TABLE DEPTH
121                   8);                                  // UPDATE TABLE DEPTH
122
123       
124std::cout << "  - building xram_" << x_id << "_" << y_id << std::endl;
125
126        std::ostringstream sxram;
127        sxram << "xram_" << x_id << "_" << y_id;
128        xram = new VciSimpleRam<vci_param>(
129                   sxram.str().c_str(),
130                   IntTab(cluster_id),
131                   mtx,
132                   loader,
133                   xram_latency);
134
135std::cout << "  - building xicu_" << x_id << "_" << y_id << std::endl;
136
137        size_t  nhwi = 8;                               // always 8 (or 9) ports, even if
138        if( io == true ) nhwi = 9;                      // there if less than 4 processors
139        std::ostringstream sicu;
140        sicu << "xicu_" << x_id << "_" << y_id;
141        xicu = new VciXicu<vci_param>(
142                  sicu.str().c_str(),
143                  mtd,                                  // mapping table
144                  IntTab(cluster_id, tgtid_xicu),       // TGTID_D
145                  0,                                    // number of timer IRQs
146                  nhwi,                                 // number of hard IRQs
147                  0,                                    // number of soft IRQs
148                  nprocs);                              // number of output IRQs
149
150std::cout << "  - building tty_" << x_id << "_" << y_id << std::endl;
151
152        // tty
153        std::ostringstream stty;
154        stty << "tty_" << x_id << "_" << y_id;
155        mtty = new VciMultiTty<vci_param>(
156                   stty.str().c_str(),
157                   IntTab(cluster_id, tgtid_mtty),
158                   mtd, stty.str().c_str(), NULL);
159       
160std::cout << "  - building dma_" << x_id << "_" << y_id << std::endl;
161
162        // dma
163        std::ostringstream sdma;
164        sdma << "dma_" << x_id << "_" << y_id;
165        mdma = new VciMultiDma<vci_param>(
166                   sdma.str().c_str(),
167                   mtd,
168                   IntTab(cluster_id, nprocs),          // SRCID
169                   IntTab(cluster_id, tgtid_mdma),      // TGTID
170                   64,                                  // burst size
171                   nprocs);                             // number of IRQs
172
173std::cout << "  - building xbard_" << x_id << "_" << y_id << std::endl;
174
175        // direct local crossbar
176        size_t nb_direct_initiators      = nprocs + 1;
177        size_t nb_direct_targets         = 4;
178        if( io == true )
179        {
180            nb_direct_initiators         = nprocs + 2;
181            nb_direct_targets            = 7;
182        }
183        std::ostringstream sd;
184        sd << "xbard_" << x_id << "_" << y_id;
185        xbard = new VciLocalCrossbar<vci_param>(
186                    sd.str().c_str(),
187                    mtd,
188                    IntTab(cluster_id),                 // cluster initiator index
189                    IntTab(cluster_id),                 // cluster target index
190                    nb_direct_initiators,               // number of initiators
191                    nb_direct_targets);                 // number of targets     
192       
193std::cout << "  - building xbarc_" << x_id << "_" << y_id << std::endl;
194
195        // coherence local crossbar
196        std::ostringstream sc;
197        sc << "xbarc_" << x_id << "_" << y_id;
198        xbarc = new VciLocalCrossbar<vci_param>(
199                    sc.str().c_str(),
200                    mtc,
201                    IntTab(cluster_id),                 // cluster initiator index
202                    IntTab(cluster_id),                 // cluster target index
203                    nprocs + 1,                         // number of initiators
204                    nprocs + 1);                        // number of targets
205       
206std::cout << "  - building wrappers in cluster_" << x_id << "_" << y_id << std::endl;
207
208        // direct initiator wrapper
209        std::ostringstream wid;
210        wid << "iniwrapperd_" << x_id << "_" << y_id;
211        iniwrapperd = new VciVdspinInitiatorWrapper<vci_param,cmd_width,rsp_width>(
212                          wid.str().c_str(),
213                          4,                            // cmd fifo depth
214                          4);                           // rsp fifo depth
215
216        // direct target wrapper
217        std::ostringstream wtd;
218        wtd << "tgtwrapperd_" << x_id << "_" << y_id;
219        tgtwrapperd = new VciVdspinTargetWrapper<vci_param,cmd_width,rsp_width>(
220                          wtd.str().c_str(),
221                          4,                            // cmd fifo depth
222                          4);                           // rsp fifo depth
223
224        // coherence initiator wrapper
225        std::ostringstream wic;
226        wic << "iniwrapperc_" << x_id << "_" << y_id;
227        iniwrapperc = new VciVdspinInitiatorWrapper<vci_param,cmd_width,rsp_width>(
228                          wic.str().c_str(),
229                          4,                            // cmd fifo depth
230                          4);                           // rsp fifo depth
231
232        // coherence target wrapper
233        std::ostringstream wtc;
234        wtc << "tgtwrapperc_" << x_id << "_" << y_id;
235        tgtwrapperc = new VciVdspinTargetWrapper<vci_param,cmd_width,rsp_width>(
236                          wtc.str().c_str(),
237                          4,                            // cmd fifo depth
238                          4);                           // rsp fifo depth
239
240std::cout << "  - building cmdrouter_" << x_id << "_" << y_id << std::endl;
241
242        // CMD router
243        std::ostringstream scmd;
244        scmd << "cmdrouter_" << x_id << "_" << y_id;
245        cmdrouter = new VirtualDspinRouter<cmd_width>(
246                        scmd.str().c_str(),
247                        x_id,y_id,                    // coordinate in the mesh
248                        x_width, y_width,             // x & y fields width
249                        4,4);                         // input & output fifo depths
250       
251std::cout << "  - building rsprouter_" << x_id << "_" << y_id << std::endl;
252
253        // RSP router
254        std::ostringstream srsp;
255        srsp << "rsprouter_" << x_id << "_" << y_id;
256        rsprouter = new VirtualDspinRouter<rsp_width>(
257                        srsp.str().c_str(),
258                        x_id,y_id,                    // coordinates in mesh
259                        x_width, y_width,             // x & y fields width
260                        4,4);                         // input & output fifo depths
261       
262        // IO cluster components
263        if ( io == true )
264        {
265            brom = new VciSimpleRam<vci_param>(
266                       "brom",
267                       IntTab(cluster_id, tgtid_brom),
268                       mtd,
269                       loader);
270
271            fbuf = new VciFrameBuffer<vci_param>(
272                       "fbuf",
273                       IntTab(cluster_id, tgtid_fbuf),
274                       mtd,
275                       xfb, yfb); 
276
277            bdev = new VciBlockDeviceTsarV4<vci_param>(
278                       "bdev",
279                       mtd,
280                       IntTab(cluster_id, nprocs+1),
281                       IntTab(cluster_id, tgtid_bdev),
282                       disk_name,
283                       block_size);
284        }
285
286std::cout << "  - all components constructed" << std::endl;
287
288        ////////////////////////////////////
289        // Connections are defined here
290        ////////////////////////////////////
291
292        // CMDROUTER and RSPROUTER
293        cmdrouter->p_clk                        (this->p_clk);
294        cmdrouter->p_resetn                     (this->p_resetn);
295        rsprouter->p_clk                        (this->p_clk);
296        rsprouter->p_resetn                     (this->p_resetn);
297        for(int x = 0; x < 2; x++)
298        {
299          for(int y = 0; y < 4; y++)
300          {
301            cmdrouter->p_out[x][y]              (this->p_cmd_out[x][y]);
302            cmdrouter->p_in[x][y]               (this->p_cmd_in[x][y]);
303            rsprouter->p_out[x][y]              (this->p_rsp_out[x][y]);
304            rsprouter->p_in[x][y]               (this->p_rsp_in[x][y]);
305          }
306        }
307       
308        cmdrouter->p_out[0][4]                  (signal_dspin_cmd_g2l_d);
309        cmdrouter->p_out[1][4]                  (signal_dspin_cmd_g2l_c);
310        cmdrouter->p_in[0][4]                   (signal_dspin_cmd_l2g_d);
311        cmdrouter->p_in[1][4]                   (signal_dspin_cmd_l2g_c);
312
313        rsprouter->p_out[0][4]                  (signal_dspin_rsp_g2l_d);
314        rsprouter->p_out[1][4]                  (signal_dspin_rsp_g2l_c);
315        rsprouter->p_in[0][4]                   (signal_dspin_rsp_l2g_d);
316        rsprouter->p_in[1][4]                   (signal_dspin_rsp_l2g_c);
317
318        // VCI/DSPIN WRAPPERS
319        iniwrapperd->p_clk                      (this->p_clk);
320        iniwrapperd->p_resetn                   (this->p_resetn);
321        iniwrapperd->p_vci                      (signal_vci_l2g_d);
322        iniwrapperd->p_dspin_out                (signal_dspin_cmd_l2g_d);
323        iniwrapperd->p_dspin_in                 (signal_dspin_rsp_g2l_d);
324
325        tgtwrapperd->p_clk                      (this->p_clk);
326        tgtwrapperd->p_resetn                   (this->p_resetn);
327        tgtwrapperd->p_vci                      (signal_vci_g2l_d);
328        tgtwrapperd->p_dspin_out                (signal_dspin_rsp_l2g_d);
329        tgtwrapperd->p_dspin_in                 (signal_dspin_cmd_g2l_d);
330
331        iniwrapperc->p_clk                      (this->p_clk);
332        iniwrapperc->p_resetn                   (this->p_resetn);
333        iniwrapperc->p_vci                      (signal_vci_l2g_c);
334        iniwrapperc->p_dspin_out                (signal_dspin_cmd_l2g_c);
335        iniwrapperc->p_dspin_in                 (signal_dspin_rsp_g2l_c);
336
337        tgtwrapperc->p_clk                      (this->p_clk);
338        tgtwrapperc->p_resetn                   (this->p_resetn);
339        tgtwrapperc->p_vci                      (signal_vci_g2l_c);
340        tgtwrapperc->p_dspin_out                (signal_dspin_rsp_l2g_c);
341        tgtwrapperc->p_dspin_in                 (signal_dspin_cmd_g2l_c);
342
343        // CROSSBAR direct
344        xbard->p_clk                            (this->p_clk);
345        xbard->p_resetn                         (this->p_resetn);
346        xbard->p_initiator_to_up                (signal_vci_l2g_d);
347        xbard->p_target_to_up                   (signal_vci_g2l_d);
348         
349        xbard->p_to_target[tgtid_memc]          (signal_vci_tgt_d_memc);
350        xbard->p_to_target[tgtid_xicu]          (signal_vci_tgt_d_xicu);
351        xbard->p_to_target[tgtid_mtty]          (signal_vci_tgt_d_mtty);
352        xbard->p_to_target[tgtid_mdma]          (signal_vci_tgt_d_mdma);
353         
354        xbard->p_to_initiator[nprocs]           (signal_vci_ini_d_mdma);
355        for ( size_t p=0 ; p<nprocs ; p++)
356        {
357            xbard->p_to_initiator[p]            (signal_vci_ini_d_proc[p]);
358        }
359
360        if ( io == true )
361        {
362            xbard->p_to_target[tgtid_brom]      (signal_vci_tgt_d_brom);
363            xbard->p_to_target[tgtid_bdev]      (signal_vci_tgt_d_bdev);
364            xbard->p_to_target[tgtid_fbuf]      (signal_vci_tgt_d_fbuf);
365           
366            xbard->p_to_initiator[nprocs+1]     (signal_vci_ini_d_bdev);
367        }
368       
369        // CROSSBAR coherence
370        xbarc->p_clk                            (this->p_clk);
371        xbarc->p_resetn                         (this->p_resetn);
372        xbarc->p_initiator_to_up                (signal_vci_l2g_c);
373        xbarc->p_target_to_up                   (signal_vci_g2l_c);
374        xbarc->p_to_initiator[nprocs]           (signal_vci_ini_c_memc);
375        xbarc->p_to_target[nprocs]              (signal_vci_tgt_c_memc);
376        for ( size_t p=0 ; p<nprocs ; p++)
377        {
378            xbarc->p_to_target[p]               (signal_vci_tgt_c_proc[p]);
379            xbarc->p_to_initiator[p]            (signal_vci_ini_c_proc[p]);
380        }
381
382        // Processors
383        for ( size_t p=0 ; p<nprocs ; p++)
384        {
385            proc[p]->p_clk                      (this->p_clk);
386            proc[p]->p_resetn                   (this->p_resetn);
387            proc[p]->p_vci_ini_rw               (signal_vci_ini_d_proc[p]);
388            proc[p]->p_vci_ini_c                (signal_vci_ini_c_proc[p]);
389            proc[p]->p_vci_tgt                  (signal_vci_tgt_c_proc[p]);
390            proc[p]->p_irq[0]                   (signal_proc_it[p]);
391            for ( size_t j = 1 ; j < 6 ; j++ )
392            {
393                proc[p]->p_irq[j]               (signal_false);
394            }
395        }
396       
397        // XICU
398        xicu->p_clk                             (this->p_clk);
399        xicu->p_resetn                          (this->p_resetn);
400        xicu->p_vci                             (signal_vci_tgt_d_xicu);
401        for ( size_t p=0 ; p<nprocs ; p++)
402        {
403            xicu->p_irq[p]                      (signal_proc_it[p]);
404        }
405        xicu->p_hwi[0]                          (signal_irq_mtty);
406        xicu->p_hwi[1]                          (signal_false);
407        xicu->p_hwi[2]                          (signal_false);
408        xicu->p_hwi[3]                          (signal_false);
409        for ( size_t p=0 ; p<nprocs ; p++)
410        {
411            xicu->p_hwi[p+4]                    (signal_irq_mdma[p]);
412        }
413        for ( size_t x=nprocs ; x<4 ; x++)
414        {
415            xicu->p_hwi[x+4]                    (signal_false);
416        }
417        if ( io == true )
418        {
419            xicu->p_hwi[8]                      (signal_irq_bdev);
420        }
421
422        // MEMC
423        memc->p_clk                             (this->p_clk);
424        memc->p_resetn                          (this->p_resetn);
425        memc->p_vci_ixr                         (signal_vci_xram);
426        memc->p_vci_tgt                         (signal_vci_tgt_d_memc);
427        memc->p_vci_ini                         (signal_vci_ini_c_memc);
428        memc->p_vci_tgt_cleanup                 (signal_vci_tgt_c_memc);
429
430        // XRAM
431        xram->p_clk                             (this->p_clk);
432        xram->p_resetn                          (this->p_resetn);
433        xram->p_vci                             (signal_vci_xram);
434
435        // MTTY
436        mtty->p_clk                             (this->p_clk);
437        mtty->p_resetn                          (this->p_resetn);
438        mtty->p_vci                             (signal_vci_tgt_d_mtty);
439        mtty->p_irq[0]                          (signal_irq_mtty);
440
441        // CDMA
442        mdma->p_clk                             (this->p_clk);
443        mdma->p_resetn                          (this->p_resetn);
444        mdma->p_vci_target                      (signal_vci_tgt_d_mdma);
445        mdma->p_vci_initiator                   (signal_vci_ini_d_mdma);
446        for (size_t p=0 ; p<nprocs ; p++)
447        {
448            mdma->p_irq[p]                       (signal_irq_mdma[p]);
449        }
450
451        // Components in IO cluster
452
453        if ( io == true )
454        {
455                // BDEV           
456                bdev->p_clk                      (this->p_clk);
457                bdev->p_resetn                   (this->p_resetn);
458                bdev->p_irq                      (signal_irq_bdev);
459                bdev->p_vci_target               (signal_vci_tgt_d_bdev);
460                bdev->p_vci_initiator            (signal_vci_ini_d_bdev);
461
462                // FBUF
463                fbuf->p_clk                       (this->p_clk);
464                fbuf->p_resetn                    (this->p_resetn);
465                fbuf->p_vci                       (signal_vci_tgt_d_fbuf);
466
467                // BROM
468                brom->p_clk                       (this->p_clk);
469                brom->p_resetn                    (this->p_resetn);
470                brom->p_vci                       (signal_vci_tgt_d_brom);
471
472        }
473} // end constructor
474
475///////////////////////////////////////////////////////////////////////////
476//    destructor
477///////////////////////////////////////////////////////////////////////////
478template<typename vci_param, typename iss_t, int cmd_width, int rsp_width>
479TsarV4ClusterXbar<vci_param, iss_t, cmd_width, rsp_width>::~TsarV4ClusterXbar() {}
480
481}}
Note: See TracBrowser for help on using the repository browser.