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

Last change on this file since 155 was 155, checked in by alain, 13 years ago

ntroducing the tsarv4_generic_ring platform

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                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                0);                             // WBUF timeout
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 dring_" << x_id << "_" << y_id << std::endl;
174
175        // direct ring
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 << "ringd_" << x_id << "_" << y_id;
185        ringd = new VciLocalRingFast<vci_param,cmd_width,rsp_width>(
186                    sd.str().c_str(),
187                    mtd,
188                    IntTab(cluster_id),                 // cluster index
189                    4,                                  // wrapper fifo depth
190                    4,                                  // gateway fifo depth
191                    nb_direct_initiators,               // number of initiators
192                    nb_direct_targets);                 // number of targets     
193       
194std::cout << "  - building cring_" << x_id << "_" << y_id << std::endl;
195
196        // coherence ring
197        std::ostringstream sc;
198        sc << "ringc_" << x_id << "_" << y_id;
199        ringc = new VciLocalRingFast<vci_param,cmd_width,rsp_width>(
200                    sc.str().c_str(),
201                    mtc,
202                    IntTab(cluster_id),                 // cluster index
203                    4,                                  // wrapper fifo depth
204                    4,                                  // gateway fifo depth
205                    nprocs + 1,                         // number of initiators
206                    nprocs + 1);                        // number of targets
207       
208std::cout << "  - building cmdrouter_" << x_id << "_" << y_id << std::endl;
209
210        // CMD router
211        std::ostringstream scmd;
212        scmd << "cmdrouter_" << x_id << "_" << y_id;
213        cmdrouter = new VirtualDspinRouter<cmd_width>(
214                        scmd.str().c_str(),
215                        x_id,y_id,                    // coordinate in the mesh
216                        x_width, y_width,             // x & y fields width
217                        4,4);                         // input & output fifo depths
218       
219std::cout << "  - building rsprouter_" << x_id << "_" << y_id << std::endl;
220
221        // RSP router
222        std::ostringstream srsp;
223        srsp << "rsprouter_" << x_id << "_" << y_id;
224        rsprouter = new VirtualDspinRouter<rsp_width>(
225                        srsp.str().c_str(),
226                        x_id,y_id,                    // coordinates in mesh
227                        x_width, y_width,             // x & y fields width
228                        4,4);                         // input & output fifo depths
229       
230        // IO cluster components
231        if ( io == true )
232        {
233            brom = new VciSimpleRam<vci_param>(
234                       "brom",
235                       IntTab(cluster_id, tgtid_brom),
236                       mtd,
237                       loader);
238
239            fbuf = new VciFrameBuffer<vci_param>(
240                       "fbuf",
241                       IntTab(cluster_id, tgtid_fbuf),
242                       mtd,
243                       xfb, yfb); 
244
245            bdev = new VciBlockDeviceTsarV4<vci_param>(
246                       "bdev",
247                       mtd,
248                       IntTab(cluster_id, nprocs+1),
249                       IntTab(cluster_id, tgtid_bdev),
250                       disk_name,
251                       block_size);
252        }
253
254std::cout << "  - all components constructed" << std::endl;
255
256        ////////////////////////////////////
257        // Connections are defined here
258        ////////////////////////////////////
259
260        // CMDROUTER and RSPROUTER
261        cmdrouter->p_clk                        (this->p_clk);
262        cmdrouter->p_resetn                     (this->p_resetn);
263        rsprouter->p_clk                        (this->p_clk);
264        rsprouter->p_resetn                     (this->p_resetn);
265        for(int x = 0; x < 2; x++)
266        {
267          for(int y = 0; y < 4; y++)
268          {
269            cmdrouter->p_out[x][y]              (this->p_cmd_out[x][y]);
270            cmdrouter->p_in[x][y]               (this->p_cmd_in[x][y]);
271            rsprouter->p_out[x][y]              (this->p_rsp_out[x][y]);
272            rsprouter->p_in[x][y]               (this->p_rsp_in[x][y]);
273          }
274        }
275       
276        cmdrouter->p_out[0][4]                  (signal_dspin_cmd_g2l_d);
277        cmdrouter->p_out[1][4]                  (signal_dspin_cmd_g2l_c);
278        cmdrouter->p_in[0][4]                   (signal_dspin_cmd_l2g_d);
279        cmdrouter->p_in[1][4]                   (signal_dspin_cmd_l2g_c);
280
281        rsprouter->p_out[0][4]                  (signal_dspin_rsp_g2l_d);
282        rsprouter->p_out[1][4]                  (signal_dspin_rsp_g2l_c);
283        rsprouter->p_in[0][4]                   (signal_dspin_rsp_l2g_d);
284        rsprouter->p_in[1][4]                   (signal_dspin_rsp_l2g_c);
285
286        // RINGD
287        ringd->p_clk                            (this->p_clk);
288        ringd->p_resetn                         (this->p_resetn);
289        ringd->p_gate_cmd_out                   (signal_dspin_cmd_l2g_d);
290        ringd->p_gate_cmd_in                    (signal_dspin_cmd_g2l_d);
291        ringd->p_gate_rsp_out                   (signal_dspin_rsp_l2g_d);
292        ringd->p_gate_rsp_in                    (signal_dspin_rsp_g2l_d);
293         
294        ringd->p_to_target[tgtid_memc]          (signal_vci_tgt_d_memc);
295        ringd->p_to_target[tgtid_xicu]          (signal_vci_tgt_d_xicu);
296        ringd->p_to_target[tgtid_mtty]          (signal_vci_tgt_d_mtty);
297        ringd->p_to_target[tgtid_mdma]          (signal_vci_tgt_d_mdma);
298         
299        ringd->p_to_initiator[nprocs]           (signal_vci_ini_d_mdma);
300        for ( size_t p=0 ; p<nprocs ; p++)
301        {
302            ringd->p_to_initiator[p]            (signal_vci_ini_d_proc[p]);
303        }
304
305        if ( io == true )
306        {
307            ringd->p_to_target[tgtid_brom]      (signal_vci_tgt_d_brom);
308            ringd->p_to_target[tgtid_bdev]      (signal_vci_tgt_d_bdev);
309            ringd->p_to_target[tgtid_fbuf]      (signal_vci_tgt_d_fbuf);
310           
311            ringd->p_to_initiator[nprocs+1]     (signal_vci_ini_d_bdev);
312        }
313       
314        // RINGC
315        ringc->p_clk                            (this->p_clk);
316        ringc->p_resetn                         (this->p_resetn);
317        ringc->p_gate_cmd_out                   (signal_dspin_cmd_l2g_c);
318        ringc->p_gate_cmd_in                    (signal_dspin_cmd_g2l_c);
319        ringc->p_gate_rsp_out                   (signal_dspin_rsp_l2g_c);
320        ringc->p_gate_rsp_in                    (signal_dspin_rsp_g2l_c);
321        ringc->p_to_initiator[nprocs]           (signal_vci_ini_c_memc);
322        ringc->p_to_target[nprocs]              (signal_vci_tgt_c_memc);
323        for ( size_t p=0 ; p<nprocs ; p++)
324        {
325            ringc->p_to_target[p]               (signal_vci_tgt_c_proc[p]);
326            ringc->p_to_initiator[p]            (signal_vci_ini_c_proc[p]);
327        }
328
329        // Processors
330        for ( size_t p=0 ; p<nprocs ; p++)
331        {
332            proc[p]->p_clk                      (this->p_clk);
333            proc[p]->p_resetn                   (this->p_resetn);
334            proc[p]->p_vci_ini_rw               (signal_vci_ini_d_proc[p]);
335            proc[p]->p_vci_ini_c                (signal_vci_ini_c_proc[p]);
336            proc[p]->p_vci_tgt                  (signal_vci_tgt_c_proc[p]);
337            proc[p]->p_irq[0]                   (signal_proc_it[p]);
338            for ( size_t j = 1 ; j < 6 ; j++ )
339            {
340                proc[p]->p_irq[j]               (signal_false);
341            }
342        }
343       
344        // XICU
345        xicu->p_clk                             (this->p_clk);
346        xicu->p_resetn                          (this->p_resetn);
347        xicu->p_vci                             (signal_vci_tgt_d_xicu);
348        for ( size_t p=0 ; p<nprocs ; p++)
349        {
350            xicu->p_irq[p]                      (signal_proc_it[p]);
351        }
352        xicu->p_hwi[0]                          (signal_irq_mtty);
353        xicu->p_hwi[1]                          (signal_false);
354        xicu->p_hwi[2]                          (signal_false);
355        xicu->p_hwi[3]                          (signal_false);
356        for ( size_t p=0 ; p<nprocs ; p++)
357        {
358            xicu->p_hwi[p+4]                    (signal_irq_mdma[p]);
359        }
360        for ( size_t x=nprocs ; x<4 ; x++)
361        {
362            xicu->p_hwi[x+4]                    (signal_false);
363        }
364        if ( io == true )
365        {
366            xicu->p_hwi[8]                      (signal_irq_bdev);
367        }
368
369        // MEMC
370        memc->p_clk                             (this->p_clk);
371        memc->p_resetn                          (this->p_resetn);
372        memc->p_vci_ixr                         (signal_vci_xram);
373        memc->p_vci_tgt                         (signal_vci_tgt_d_memc);
374        memc->p_vci_ini                         (signal_vci_ini_c_memc);
375        memc->p_vci_tgt_cleanup                 (signal_vci_tgt_c_memc);
376
377        // XRAM
378        xram->p_clk                             (this->p_clk);
379        xram->p_resetn                          (this->p_resetn);
380        xram->p_vci                             (signal_vci_xram);
381
382        // MTTY
383        mtty->p_clk                             (this->p_clk);
384        mtty->p_resetn                          (this->p_resetn);
385        mtty->p_vci                             (signal_vci_tgt_d_mtty);
386        mtty->p_irq[0]                          (signal_irq_mtty);
387
388        // CDMA
389        mdma->p_clk                             (this->p_clk);
390        mdma->p_resetn                          (this->p_resetn);
391        mdma->p_vci_target                      (signal_vci_tgt_d_mdma);
392        mdma->p_vci_initiator                   (signal_vci_ini_d_mdma);
393        for (size_t p=0 ; p<nprocs ; p++)
394        {
395            mdma->p_irq[p]                       (signal_irq_mdma[p]);
396        }
397
398        // Components in IO cluster
399
400        if ( io == true )
401        {
402                // BDEV           
403                bdev->p_clk                      (this->p_clk);
404                bdev->p_resetn                   (this->p_resetn);
405                bdev->p_irq                      (signal_irq_bdev);
406                bdev->p_vci_target               (signal_vci_tgt_d_bdev);
407                bdev->p_vci_initiator            (signal_vci_ini_d_bdev);
408
409                // FBUF
410                fbuf->p_clk                       (this->p_clk);
411                fbuf->p_resetn                    (this->p_resetn);
412                fbuf->p_vci                       (signal_vci_tgt_d_fbuf);
413
414                // BROM
415                brom->p_clk                       (this->p_clk);
416                brom->p_resetn                    (this->p_resetn);
417                brom->p_vci                       (signal_vci_tgt_d_brom);
418
419        }
420} // end constructor
421
422///////////////////////////////////////////////////////////////////////////
423//    destructor
424///////////////////////////////////////////////////////////////////////////
425template<typename vci_param, typename iss_t, int cmd_width, int rsp_width>
426TsarV4ClusterRing<vci_param, iss_t, cmd_width, rsp_width>::~TsarV4ClusterRing() {}
427
428}}
Note: See TracBrowser for help on using the repository browser.