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

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