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

Last change on this file since 261 was 261, checked in by alain, 12 years ago

The tsarv4_generic_mmu platform has been modified to use the
vci_multi_dma and vci_block_device components supporting bursts
for unaligned memory buffers.

File size: 22.8 KB
Line 
1//////////////////////////////////////////////////////////////////////////////
2// File: tsarv4_cluster_mmu.c
3// Author: Alain Greiner
4// Copyright: UPMC/LIP6
5// Date : march 2011
6// This program is released under the GNU public license
7//////////////////////////////////////////////////////////////////////////////
8// This file define a TSAR cluster architecture with virtual memory:
9// - It uses the virtual_dspin_router as distributed global interconnect
10// - It uses the vci_local_crossbar as local interconnect
11// - It uses the vci_cc_vcache_wrapper_v4
12// - It uses the vci_mem_cache_v4
13// - It contains a private RAM with a variable latency to emulate the L3 cache
14// - It can contains 1, 2 or 4 processors
15// - Each processor has a private dma channel (vci_multi_dma)
16// - It uses the vci_xicu interrupt controller
17// - The peripherals MTTY, BDEV, FBUF, and the boot BROM are in the cluster
18//   containing address 0xBFC00000.
19// - The Multi-TTY component controls up to 15 terminals.
20// - Each Multi-DMA component controls up to 8 DMA channels.
21// - The DMA IRQs are connected to IRQ_IN[8]...IRQ_IN[15]
22// - The TTY IRQs are connected to IRQ_IN[16]...IRQ_IN[30]
23// - The BDEV IRQ is connected to IRQ_IN[31]
24//////////////////////////////////////////////////////////////////////////////////
25
26#include "../include/tsarv4_cluster_mmu.h"
27
28namespace soclib {
29namespace caba  {
30
31//////////////////////////////////////////////////////////////////////////
32//                 Constructor
33//////////////////////////////////////////////////////////////////////////
34template<typename vci_param, typename iss_t, int cmd_width, int rsp_width>
35TsarV4ClusterMmu<vci_param, iss_t, cmd_width, rsp_width>::TsarV4ClusterMmu(
36         sc_module_name                     insname,
37         size_t                             nb_procs,
38         size_t                             nb_ttys,
39         size_t                             nb_dmas,
40         size_t                             x_id,
41         size_t                             y_id,
42         size_t                             cluster_id,
43         const soclib::common::MappingTable &mtd,
44         const soclib::common::MappingTable &mtc, 
45         const soclib::common::MappingTable &mtx, 
46         size_t                             x_width,
47         size_t                             y_width,
48         size_t                             tgtid_memc,
49         size_t                             tgtid_xicu,
50         size_t                             tgtid_fbuf,
51         size_t                             tgtid_mtty,
52         size_t                             tgtid_brom,
53         size_t                             tgtid_bdev,
54         size_t                             tgtid_mdma,
55         size_t                             memc_ways,
56         size_t                             memc_sets,
57         size_t                             l1_i_ways,
58         size_t                             l1_i_sets,
59         size_t                             l1_d_ways,
60         size_t                             l1_d_sets,
61         size_t                             xram_latency,
62         bool                               io,
63         size_t                             xfb,
64         size_t                             yfb,
65         char*                              disk_name,
66         size_t                             block_size,
67         const Loader                      &loader,
68         uint32_t                           frozen_cycles,
69         uint32_t                           debug_start_cycle,
70         bool                               memc_debug_ok,
71         bool                               proc_debug_ok)
72            : soclib::caba::BaseModule(insname),
73            p_clk("clk"),
74            p_resetn("resetn")
75
76{
77    // Vectors of ports definition
78
79    p_cmd_in        = alloc_elems<DspinInput<cmd_width> >("p_cmd_in", 2, 4);
80    p_cmd_out       = alloc_elems<DspinOutput<cmd_width> >("p_cmd_out", 2, 4);
81    p_rsp_in        = alloc_elems<DspinInput<rsp_width> >("p_rsp_in", 2, 4);
82    p_rsp_out       = alloc_elems<DspinOutput<rsp_width> >("p_rsp_out", 2, 4);
83
84    // Components definition
85
86    // on direct network : local srcid[proc] in [0..nb_procs-1]
87    // on direct network : local srcid[mdma] = nb_procs
88    // on direct network : local srcid[bdev] = nb_procs + 1
89
90    // on coherence network : local srcid[proc] in [0...nb_procs-1]
91    // on coherence network : local srcid[memc] = nb_procs
92
93    std::cout << "  - building proc_" << x_id << "_" << y_id << "-*" << std::endl;
94
95    for (size_t p = 0; p < nb_procs; p++)
96    { 
97        std::ostringstream sproc;
98        sproc << "proc_" << x_id << "_" << y_id << "_" << p;
99        proc[p] = new VciCcVCacheWrapperV4<vci_param, iss_t>(
100                      sproc.str().c_str(),
101                      cluster_id*nb_procs + p,
102                      mtd,                            // Mapping Table Direct
103                      mtc,                            // Mapping Table Coherence
104                      IntTab(cluster_id,p),           // SRCID_D
105                      IntTab(cluster_id,p),           // SRCID_C
106                      IntTab(cluster_id,p),           // TGTID_C
107                      8,                              // ITLB ways
108                      8,                              // ITLB sets
109                      8,                              // DTLB ways
110                      8,                              // DTLB sets
111                      l1_i_ways,l1_i_sets,16,         // ICACHE size
112                      l1_d_ways,l1_d_sets,16,         // DCACHE size
113                      4,                              // WBUF nlines
114                      4,                              // WBUF nwords
115                      x_width,
116                      y_width,
117                      nb_procs,                       // MEMC local index
118                      frozen_cycles,                  // max frozen cycles
119                      debug_start_cycle,
120                      proc_debug_ok);
121    }
122
123    std::cout << "  - building memc_" << x_id << "_" << y_id << std::endl;
124
125    std::ostringstream smemc;
126    smemc << "memc_" << x_id << "_" << y_id;
127    memc = new VciMemCacheV4<vci_param>(
128                     smemc.str().c_str(),
129                     mtd, mtc, mtx,
130                     IntTab(cluster_id),              // SRCID_X
131                     IntTab(cluster_id, nb_procs),    // SRCID_C
132                     IntTab(cluster_id, tgtid_memc),  // TGTID_D
133                     IntTab(cluster_id, nb_procs),    // TGTID_C
134                     memc_ways, memc_sets, 16,        // CACHE SIZE
135                     4096,                            // HEAP SIZE
136                     8,                               // TRANSACTION TABLE DEPTH
137                     8,                               // UPDATE TABLE DEPTH
138                     debug_start_cycle,
139                     memc_debug_ok);
140
141    std::cout << "  - building xram_" << x_id << "_" << y_id << std::endl;
142
143    std::ostringstream sxram;
144    sxram << "xram_" << x_id << "_" << y_id;
145    xram = new VciSimpleRam<vci_param>(
146                     sxram.str().c_str(),
147                     IntTab(cluster_id),
148                     mtx,
149                     loader,
150                     xram_latency);
151
152    std::cout << "  - building xicu_" << x_id << "_" << y_id << std::endl;
153
154    std::ostringstream sicu;
155    sicu << "xicu_" << x_id << "_" << y_id;
156    xicu = new VciXicu<vci_param>(
157                     sicu.str().c_str(),
158                     mtd,                               // mapping table
159                     IntTab(cluster_id, tgtid_xicu),    // TGTID_D
160                     nb_procs,                          // number of timer IRQs
161                     32,                                // number of hard IRQs
162                     0,                                 // number of soft IRQs
163                     nb_procs);                         // number of output IRQs
164
165    std::cout << "  - building dma_" << x_id << "_" << y_id << std::endl;
166
167    std::ostringstream sdma;
168    sdma << "dma_" << x_id << "_" << y_id;
169    mdma = new VciMultiDma<vci_param>(
170                     sdma.str().c_str(),
171                     mtd,
172                     IntTab(cluster_id, nb_procs),        // SRCID
173                     IntTab(cluster_id, tgtid_mdma),      // TGTID
174                     64,                                  // burst size
175                     nb_procs);                           // number of IRQs
176
177    std::cout << "  - building xbard_" << x_id << "_" << y_id << std::endl;
178
179    size_t nb_direct_initiators      = nb_procs + 1;
180    size_t nb_direct_targets         = 3;
181    if ( io )
182    {
183        nb_direct_initiators         = nb_procs + 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
196    std::cout << "  - building xbarc_" << x_id << "_" << y_id << std::endl;
197
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                     nb_procs + 1,                 // number of initiators
206                     nb_procs + 1);                // number of targets
207
208    std::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
242    std::cout << "  - building cmdrouter_" << x_id << "_" << y_id << std::endl;
243
244    std::ostringstream scmd;
245    scmd << "cmdrouter_" << x_id << "_" << y_id;
246    cmdrouter = new VirtualDspinRouter<cmd_width>(
247                     scmd.str().c_str(),
248                     x_id,y_id,                    // coordinate in the mesh
249                     x_width, y_width,             // x & y fields width
250                     4,4);                         // input & output fifo depths
251
252    std::cout << "  - building rsprouter_" << x_id << "_" << y_id << std::endl;
253
254    // RSP router
255    std::ostringstream srsp;
256    srsp << "rsprouter_" << x_id << "_" << y_id;
257    rsprouter = new VirtualDspinRouter<rsp_width>(
258                     srsp.str().c_str(),
259                     x_id,y_id,                    // coordinates in mesh
260                     x_width, y_width,             // x & y fields width
261                     4,4);                         // input & output fifo depths
262
263    // IO cluster components
264    if ( io )
265    {
266        std::cout << "  - building brom" << std::endl;
267
268        brom = new VciSimpleRam<vci_param>(
269                        "brom",
270                        IntTab(cluster_id, tgtid_brom),
271                        mtd,
272                        loader);
273
274        std::cout << "  - building fbuf" << std::endl;
275
276        fbuf = new VciFrameBuffer<vci_param>(
277                        "fbuf",
278                        IntTab(cluster_id, tgtid_fbuf),
279                        mtd,
280                        xfb, yfb); 
281
282        std::cout << "  - building fbuf" << std::endl;
283
284        bdev = new VciBlockDeviceTsarV4<vci_param>(
285                        "bdev",
286                        mtd,
287                        IntTab(cluster_id, nb_procs+1),
288                        IntTab(cluster_id, tgtid_bdev),
289                        disk_name,
290                        block_size,
291                        64);            // burst size
292
293        std::cout << "  - building mtty" << std::endl;
294
295        std::vector<std::string> vect_names;
296        for( size_t tid = 0 ; tid < (nb_ttys) ; tid++ )
297        {
298            std::ostringstream term_name;
299            term_name <<  "term" << tid;
300            vect_names.push_back(term_name.str().c_str());
301        }
302        mtty = new VciMultiTty<vci_param>(
303                        "mtty",
304                        IntTab(cluster_id, tgtid_mtty),
305                        mtd, 
306                        vect_names);
307    }
308
309    std::cout << std::endl;
310
311    ////////////////////////////////////
312    // Connections are defined here
313    ////////////////////////////////////
314
315    // CMDROUTER and RSPROUTER
316    cmdrouter->p_clk                        (this->p_clk);
317    cmdrouter->p_resetn                     (this->p_resetn);
318    rsprouter->p_clk                        (this->p_clk);
319    rsprouter->p_resetn                     (this->p_resetn);
320    for (int x = 0; x < 2; x++)
321    {
322        for(int y = 0; y < 4; y++)
323        {
324            cmdrouter->p_out[x][y]          (this->p_cmd_out[x][y]);
325            cmdrouter->p_in[x][y]           (this->p_cmd_in[x][y]);
326            rsprouter->p_out[x][y]          (this->p_rsp_out[x][y]);
327            rsprouter->p_in[x][y]           (this->p_rsp_in[x][y]);
328        }
329    }
330
331    cmdrouter->p_out[0][4]                  (signal_dspin_cmd_g2l_d);
332    cmdrouter->p_out[1][4]                  (signal_dspin_cmd_g2l_c);
333    cmdrouter->p_in[0][4]                   (signal_dspin_cmd_l2g_d);
334    cmdrouter->p_in[1][4]                   (signal_dspin_cmd_l2g_c);
335
336    rsprouter->p_out[0][4]                  (signal_dspin_rsp_g2l_d);
337    rsprouter->p_out[1][4]                  (signal_dspin_rsp_g2l_c);
338    rsprouter->p_in[0][4]                   (signal_dspin_rsp_l2g_d);
339    rsprouter->p_in[1][4]                   (signal_dspin_rsp_l2g_c);
340
341    std::cout << "  - CMD & RSP routers connected" << std::endl;
342
343    // VCI/DSPIN WRAPPERS
344    iniwrapperd->p_clk                      (this->p_clk);
345    iniwrapperd->p_resetn                   (this->p_resetn);
346    iniwrapperd->p_vci                      (signal_vci_l2g_d);
347    iniwrapperd->p_dspin_out                (signal_dspin_cmd_l2g_d);
348    iniwrapperd->p_dspin_in                 (signal_dspin_rsp_g2l_d);
349
350    tgtwrapperd->p_clk                      (this->p_clk);
351    tgtwrapperd->p_resetn                   (this->p_resetn);
352    tgtwrapperd->p_vci                      (signal_vci_g2l_d);
353    tgtwrapperd->p_dspin_out                (signal_dspin_rsp_l2g_d);
354    tgtwrapperd->p_dspin_in                 (signal_dspin_cmd_g2l_d);
355
356    iniwrapperc->p_clk                      (this->p_clk);
357    iniwrapperc->p_resetn                   (this->p_resetn);
358    iniwrapperc->p_vci                      (signal_vci_l2g_c);
359    iniwrapperc->p_dspin_out                (signal_dspin_cmd_l2g_c);
360    iniwrapperc->p_dspin_in                 (signal_dspin_rsp_g2l_c);
361
362    tgtwrapperc->p_clk                      (this->p_clk);
363    tgtwrapperc->p_resetn                   (this->p_resetn);
364    tgtwrapperc->p_vci                      (signal_vci_g2l_c);
365    tgtwrapperc->p_dspin_out                (signal_dspin_rsp_l2g_c);
366    tgtwrapperc->p_dspin_in                 (signal_dspin_cmd_g2l_c);
367
368    std::cout << "  - VCI/DSPIN wrappers connected" << std::endl;
369
370    // CROSSBAR direct
371    xbard->p_clk                            (this->p_clk);
372    xbard->p_resetn                         (this->p_resetn);
373    xbard->p_initiator_to_up                (signal_vci_l2g_d);
374    xbard->p_target_to_up                   (signal_vci_g2l_d);
375
376    xbard->p_to_target[tgtid_memc]          (signal_vci_tgt_d_memc);
377    xbard->p_to_target[tgtid_xicu]          (signal_vci_tgt_d_xicu);
378    xbard->p_to_target[tgtid_mdma]          (signal_vci_tgt_d_mdma);
379
380    xbard->p_to_initiator[nb_procs]         (signal_vci_ini_d_mdma);
381
382    for (size_t p = 0; p < nb_procs; p++)
383    {
384        xbard->p_to_initiator[p]            (signal_vci_ini_d_proc[p]);
385    }
386
387    if ( io )
388    {
389        xbard->p_to_target[tgtid_mtty]      (signal_vci_tgt_d_mtty);
390        xbard->p_to_target[tgtid_brom]      (signal_vci_tgt_d_brom);
391        xbard->p_to_target[tgtid_bdev]      (signal_vci_tgt_d_bdev);
392        xbard->p_to_target[tgtid_fbuf]      (signal_vci_tgt_d_fbuf);
393
394        xbard->p_to_initiator[nb_procs+1]   (signal_vci_ini_d_bdev);
395    }
396
397    std::cout << "  - Direct crossbar connected" << std::endl;
398
399    // CROSSBAR coherence
400    xbarc->p_clk                            (this->p_clk);
401    xbarc->p_resetn                         (this->p_resetn);
402    xbarc->p_initiator_to_up                (signal_vci_l2g_c);
403    xbarc->p_target_to_up                   (signal_vci_g2l_c);
404    xbarc->p_to_initiator[nb_procs]         (signal_vci_ini_c_memc);
405    xbarc->p_to_target[nb_procs]            (signal_vci_tgt_c_memc);
406    for (size_t p = 0; p < nb_procs; p++) 
407    {
408        xbarc->p_to_target[p]               (signal_vci_tgt_c_proc[p]);
409        xbarc->p_to_initiator[p]            (signal_vci_ini_c_proc[p]);
410    }
411
412    std::cout << "  - Coherence crossbar connected" << std::endl;
413
414    // Processors
415    for (size_t p = 0; p < nb_procs; p++)
416    {
417        proc[p]->p_clk                      (this->p_clk);
418        proc[p]->p_resetn                   (this->p_resetn);
419        proc[p]->p_vci_ini_d                (signal_vci_ini_d_proc[p]);
420        proc[p]->p_vci_ini_c                (signal_vci_ini_c_proc[p]);
421        proc[p]->p_vci_tgt_c                (signal_vci_tgt_c_proc[p]);
422        proc[p]->p_irq[0]                   (signal_proc_it[p]);
423        for ( size_t j = 1 ; j < 6 ; j++)
424        {
425            proc[p]->p_irq[j]               (signal_false);
426        }
427    }
428
429    std::cout << "  - Processors connected" << std::endl;
430
431    // XICU
432    xicu->p_clk                         (this->p_clk);
433    xicu->p_resetn                      (this->p_resetn);
434    xicu->p_vci                         (signal_vci_tgt_d_xicu);
435    for ( size_t p=0 ; p<nb_procs ; p++)
436    {
437        xicu->p_irq[p]                  (signal_proc_it[p]);
438    }
439    for ( size_t i=0 ; i<32 ; i++)
440    {
441        if ( io ) // I/O cluster
442        {
443            if      (i < 8)                  xicu->p_hwi[i] (signal_false);
444            else if (i < (8 + nb_dmas))      xicu->p_hwi[i]     (signal_irq_mdma[i-8]);
445            else if (i < 16)                 xicu->p_hwi[i] (signal_false);
446            else if (i < (16 + nb_ttys))     xicu->p_hwi[i] (signal_irq_mtty[i-16]);
447            else if (i < 31)                 xicu->p_hwi[i]     (signal_false);
448            else                             xicu->p_hwi[i] (signal_irq_bdev);
449        }
450        else      // other clusters
451        {
452            if      (i < 8)                  xicu->p_hwi[i] (signal_false);
453            else if (i < (8 + nb_dmas))      xicu->p_hwi[i]     (signal_irq_mdma[i-8]);
454            else                             xicu->p_hwi[i]     (signal_false);
455        }
456    }
457
458    std::cout << "  - XICU connected" << std::endl;
459
460    // MEMC
461    memc->p_clk                         (this->p_clk);
462    memc->p_resetn                      (this->p_resetn);
463    memc->p_vci_ixr                     (signal_vci_xram);
464    memc->p_vci_tgt                     (signal_vci_tgt_d_memc);
465    memc->p_vci_ini                     (signal_vci_ini_c_memc);
466    memc->p_vci_tgt_cleanup             (signal_vci_tgt_c_memc);
467
468    std::cout << "  - MEMC connected" << std::endl;
469
470    // XRAM
471    xram->p_clk                         (this->p_clk);
472    xram->p_resetn                      (this->p_resetn);
473    xram->p_vci                                 (signal_vci_xram);
474
475    std::cout << "  - XRAM connected" << std::endl;
476
477    // CDMA
478    mdma->p_clk                         (this->p_clk);
479    mdma->p_resetn                      (this->p_resetn);
480    mdma->p_vci_target                  (signal_vci_tgt_d_mdma);
481    mdma->p_vci_initiator               (signal_vci_ini_d_mdma);
482    for (size_t i=0 ; i<nb_dmas ; i++)
483    {
484        mdma->p_irq[i]                  (signal_irq_mdma[i]);
485    }
486
487    std::cout << "  - MDMA connected" << std::endl;
488
489         // Components in I/O cluster
490
491         if ( io )
492         {
493        // BDEV           
494             bdev->p_clk                        (this->p_clk);
495        bdev->p_resetn                          (this->p_resetn);
496        bdev->p_irq                             (signal_irq_bdev);
497        bdev->p_vci_target                      (signal_vci_tgt_d_bdev);
498        bdev->p_vci_initiator                   (signal_vci_ini_d_bdev);
499
500        std::cout << "  - BDEV connected" << std::endl;
501
502        // FBUF
503        fbuf->p_clk                             (this->p_clk);
504        fbuf->p_resetn                          (this->p_resetn);
505        fbuf->p_vci                             (signal_vci_tgt_d_fbuf);
506
507        std::cout << "  - FBUF connected" << std::endl;
508
509        // BROM
510        brom->p_clk                             (this->p_clk);
511        brom->p_resetn                          (this->p_resetn);
512        brom->p_vci                             (signal_vci_tgt_d_brom);
513
514        std::cout << "  - BROM connected" << std::endl;
515
516        // MTTY
517        mtty->p_clk                             (this->p_clk);
518        mtty->p_resetn                          (this->p_resetn);
519        mtty->p_vci                             (signal_vci_tgt_d_mtty);
520        for ( size_t i=0 ; i<nb_ttys ; i++ )
521        {
522            mtty->p_irq[i]                      (signal_irq_mtty[i]);
523        }
524
525        std::cout << "  - MTTY connected" << std::endl;
526   }
527} // end constructor
528
529///////////////////////////////////////////////////////////////////////////
530//    destructor
531///////////////////////////////////////////////////////////////////////////
532template<typename vci_param, typename iss_t, int cmd_width, int rsp_width>
533TsarV4ClusterMmu<vci_param, iss_t, cmd_width, rsp_width>::~TsarV4ClusterMmu() {}
534
535}
536}
537
538
539// Local Variables:
540// tab-width: 3
541// c-basic-offset: 3
542// c-file-offsets:((innamespace . 0)(inline-open . 0))
543// indent-tabs-mode: nil
544// End:
545
546// vim: filetype=cpp:expandtab:shiftwidth=3:tabstop=3:softtabstop=3
547
548
549
Note: See TracBrowser for help on using the repository browser.