source: trunk/platforms/tsarv4_generic_mmu/tsarv4_cluster_mmu/caba/source/src/tsarv4_cluster_mmu.cpp @ 234

Last change on this file since 234 was 234, checked in by almaless, 12 years ago

Bug-fix: use the loader's reference instead a copy of it. The ram components suppose the loader to be always alive (reload method) which leads to a segmentation fault. Although this issue can be resolved by making a private copy member of the loader and pass its reference to ram components, it necessaite more modifications.

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