source: trunk/platforms/tsarv4_generic_ring/tsarv4_cluster_ring/caba/source/src/tsarv4_cluster_ring.cpp @ 169

Last change on this file since 169 was 169, checked in by simerabe, 13 years ago

adding parameters for new vci_cc_xcache_wrapper_v4 version (cmp)

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