source: branches/v5/platforms/tsar_mono_mmu_dspin_coherence/top.cpp @ 332

Last change on this file since 332 was 332, checked in by joannou, 11 years ago

Updated top.cpp in tsar_mono_mmu_dspin_coherence to respect new file names for
the vci_cc_vcache_wrapper_dspin_coherence and vci_mem_cache_dspin_coherence
components

File size: 12.0 KB
Line 
1#include <systemc>
2#include <sys/time.h>
3#include <iostream>
4#include <cstdlib>
5#include <cstdarg>
6
7#ifdef _OPENMP
8#include <omp.h>
9#endif
10
11#include "mapping_table.h"
12#include "mips32.h"
13#include "vci_simple_ram.h"
14#include "vci_multi_tty.h"
15#include "vci_vgmn.h"
16#include "vci_mem_cache_dspin_coherence.h"
17#include "vci_cc_vcache_wrapper_dspin_coherence.h"
18#include "vci_xicu.h"
19#include "vci_simhelper.h"
20#include "vci_multi_dma.h"
21
22// VCI format
23
24#define    cell_width            4
25#define    address_width            32
26#define    plen_width            8
27#define    error_width           2
28#define    clen_width            1
29#define    rflag_width           1
30#define    srcid_width          14
31#define    pktid_width           4
32#define    trdid_width           4
33#define    wrplen_width          1
34
35//   segments definition in direct space
36
37#define    XICU_BASE    0xd8200000
38#define    XICU_SIZE    0x00001000
39
40#define    MDMA_BASE    0xe8000000
41#define    MDMA_SIZE    0x00000014
42
43#define    MTTY_BASE    0xd0200000
44#define    MTTY_SIZE    0x00000010
45
46#define    EXIT_BASE    0xe0000000
47#define    EXIT_SIZE    0x00000010
48
49#define    BOOT_BASE    0xbfc00000
50#define    BOOT_SIZE    0x00040000
51
52#define    MEMC_BASE    0x00000000
53#define    MEMC_SIZE    0x02000000
54
55/////////////////////////////////
56int _main(int argc, char *argv[])
57{
58
59using namespace sc_core;
60using namespace soclib::common;
61using namespace soclib::caba;
62
63#ifdef _OPENMP
64        omp_set_dynamic(false);
65        omp_set_num_threads(1);
66        std::cerr << "Built with openmp version " << _OPENMP << std::endl;
67#endif
68
69    char        soft_name[256]  = "test.elf";   // pathname to binary code
70    size_t      ncycles         = 1000000000;   // max number of simulation cycles
71    bool        trace_ok        = false;
72    size_t      from_cycle      = 0;            // debug start cycle
73    size_t      max_frozen      = 100000;               // max number of frozen cycles
74    size_t      nprocs          = 1;   
75
76    /////////////// command line arguments ////////////////
77    if (argc > 1)
78    {
79        for( int n=1 ; n<argc ; n=n+2 )
80        {
81            if( (strcmp(argv[n],"-NCYCLES") == 0) && (n+1<argc) )
82            {
83                ncycles = atoi(argv[n+1]);
84            }
85            else if( (strcmp(argv[n],"-SOFT") == 0) && (n+1<argc) )
86            {
87                strcpy(soft_name, argv[n+1]);
88            }
89            else if( (strcmp(argv[n],"-TRACE") == 0) && (n+1<argc) )
90            {
91                trace_ok = true;
92                from_cycle = atoi(argv[n+1]);
93            }
94            else if( (strcmp(argv[n],"-MAXFROZEN") == 0) && (n+1<argc) )
95            {
96                max_frozen = atoi(argv[n+1]);
97            }
98            else
99            {
100                std::cout << "   Arguments on the command line are (key,value) couples." << std::endl;
101                std::cout << "   The order is not important." << std::endl;
102                std::cout << "   Accepted arguments are :" << std::endl << std::endl;
103                std::cout << "     -SOFT pathname_for_embedded_soft" << std::endl;
104                std::cout << "     -NCYCLES number_of_simulated_cycles" << std::endl;
105                std::cout << "     -TRACE debug_start_cycle" << std::endl;
106                exit(0);
107            }
108        }
109    }
110
111    // Define VCI parameters
112    typedef VciParams<cell_width,
113                                    plen_width,
114                                    address_width,
115                                    error_width,
116                                    clen_width,
117                                    rflag_width,
118                                    srcid_width,
119                                    pktid_width,
120                                    trdid_width,
121                                    wrplen_width> vci_param;
122
123    // Define processor type
124    typedef soclib::common::Mips32ElIss proc_iss;
125
126    // Mapping table for direct network
127    soclib::common::MappingTable maptabd(32, IntTab(6), IntTab(6), 0xF0000000);
128    maptabd.add(Segment("memc_d" , MEMC_BASE , MEMC_SIZE , IntTab(0), true));
129    maptabd.add(Segment("boot_d" , BOOT_BASE , BOOT_SIZE , IntTab(1), true));
130    maptabd.add(Segment("exit_d" , EXIT_BASE , EXIT_SIZE , IntTab(2), false));
131    maptabd.add(Segment("mtty_d" , MTTY_BASE , MTTY_SIZE , IntTab(3), false));
132    maptabd.add(Segment("xicu_d" , XICU_BASE , XICU_SIZE , IntTab(4), false));
133    maptabd.add(Segment("mdma_d" , MDMA_BASE , MDMA_SIZE , IntTab(5), false));
134    std::cout << maptabd << std::endl;
135
136    // Mapping table for coherence network
137    soclib::common::MappingTable maptabc(32, IntTab(srcid_width), IntTab(srcid_width), 0xF0000000);
138    maptabc.add(
139        Segment( "proc_c"
140                , 0x0000000
141                , 0x10
142                , IntTab(0)
143                , false
144        )
145    );
146
147    maptabc.add(
148        Segment( "memc_c"
149                , nprocs << (address_width - srcid_width)
150                , 0x10
151                , IntTab(nprocs)
152                , false
153        )
154    );
155    std::cout << maptabc << std::endl;
156       
157    // Signals
158
159    sc_clock        signal_clk                  ("signal_clk");
160    sc_signal<bool> signal_resetn               ("isgnal_resetn");
161   
162    sc_signal<bool> signal_mdma_irq             ("signal_mdma_irq");
163    sc_signal<bool> signal_mtty_irq             ("signal_mtty_irq");
164    sc_signal<bool> signal_proc_irq             ("signal_proc_irq"); 
165    sc_signal<bool> signal_false                ("signal_false");
166
167    VciSignals<vci_param> signal_vci_ini_d_proc ("vci_ini_d_proc");
168    // dspin coherence network
169    DspinSignals<33>      signal_dspin_from_proc ("dspin_from_proc");
170    DspinSignals<40>      signal_dspin_from_memc ("dspin_from_memc");
171
172    VciSignals<vci_param> signal_vci_tgt_d_mtty ("signal_vci_tgt_d_mtty");
173
174    VciSignals<vci_param> signal_vci_tgt_d_exit ("signal_vci_tgt_d_exit");
175
176    VciSignals<vci_param> signal_vci_tgt_d_xicu ("signal_vci_tgt_d_xicu");
177
178    VciSignals<vci_param> signal_vci_ini_d_mdma ("signal_vci_ini_d_mdma");
179    VciSignals<vci_param> signal_vci_tgt_d_mdma ("signal_vci_tgt_d_mdma");
180
181    VciSignals<vci_param> signal_vci_tgt_d_brom ("signal_vci_tgt_d_brom");
182
183
184    VciSignals<vci_param> signal_vci_ini_c_memc ("signal_vci_ini_c_memc");
185    VciSignals<vci_param> signal_vci_tgt_d_memc ("signal_vci_tgt_d_memc");
186    VciSignals<vci_param> signal_vci_tgt_c_memc ("signal_vci_tgt_c_memc");
187
188    VciSignals<vci_param> signal_vci_xram       ("signal_vci_xram");
189
190    // Components
191
192    soclib::common::Loader loader(soft_name);
193
194    VciCcVCacheWrapper<vci_param, proc_iss > 
195    proc("proc", 
196         0,                     // proc_id
197         maptabd,               // direct space
198         maptabc,               // coherence space
199         IntTab(0),             // srcid_d
200         IntTab(0),             // srcid_c
201         IntTab(0),             // tgtid_c
202         8,8,                   // itlb size
203         8,8,                   // dtlb size
204         4,64,16,               // icache size
205         4,64,16,               // dcache size
206         4, 4,                  // wbuf size
207         0, 0,                  // x, y Width
208         nprocs,                // memory cache local id
209         max_frozen,            // max frozen cycles
210         from_cycle, trace_ok);
211
212    VciSimpleRam<vci_param> 
213    rom("rom", 
214         IntTab(1),             // tgtid_d
215         maptabd, 
216         loader);
217
218    VciSimpleRam<vci_param> 
219    xram("xram", 
220         IntTab(0),             // tgtid_d(RAM) = tgtid_d(MEMC)
221         maptabd, 
222         loader);
223
224    VciMemCache<vci_param> 
225    memc("memc",
226         maptabd,
227         maptabc,
228         maptabd,
229         IntTab(0),             // srcid_x
230         IntTab(1),             // srcid_c
231         IntTab(0),             // tgtid_d
232         IntTab(1),             // tgtid_c
233         16,256,16,             // cache size
234         1024,                  // HEAP size
235         4,                     // TRT size
236         4,                     // UPT size
237         from_cycle, trace_ok);
238       
239    VciSimhelper<vci_param> 
240    vciexit("vciexit",
241         IntTab(2),             // tgtid_d
242         maptabd);
243
244    VciXicu<vci_param> 
245    xicu("xicu", 
246         maptabd,
247         IntTab(4),             // tgtid_d
248         1,                     // number of timers
249         2,                     // number of hard interrupts
250         0,                     // number of soft interrupts
251         1);                    // number of output IRQs
252
253    VciMultiTty<vci_param> 
254    mtty("mtty", 
255         IntTab(3),             // tgtid_d
256         maptabd, 
257         "mtty0", NULL);
258
259    VciMultiDma<vci_param>
260    mdma("mdma", 
261         maptabd, 
262         IntTab(1),             // srcid_d
263         IntTab(5),             // tgtid_d
264         64,                    // burst size
265         1);                    // number of channels
266       
267    VciVgmn<vci_param> 
268    ringd("ringd",
269         maptabd, 
270         2,                     // number of initiators
271         6,                     // number of targets
272         2, 
273         8);
274/*
275    VciVgmn<vci_param>
276    ringc("ringc",
277         maptabc,
278         2,                     // number of initiators
279         2,                     // number of targets
280         2,
281         8);
282*/
283
284    // net-list
285    proc.p_clk(signal_clk); 
286    proc.p_resetn               (signal_resetn); 
287    proc.p_irq[0]               (signal_proc_irq); 
288    proc.p_irq[1]               (signal_false); 
289    proc.p_irq[2]               (signal_false); 
290    proc.p_irq[3]               (signal_false); 
291    proc.p_irq[4]               (signal_false); 
292    proc.p_irq[5]               (signal_false); 
293    proc.p_vci_ini_d    (signal_vci_ini_d_proc);
294    proc.p_dspin_in             (signal_dspin_from_memc);
295    proc.p_dspin_out    (signal_dspin_from_proc);
296
297    rom.p_clk                   (signal_clk);
298    rom.p_resetn                (signal_resetn);
299    rom.p_vci                   (signal_vci_tgt_d_brom);
300
301    xicu.p_resetn               (signal_resetn);
302    xicu.p_clk                  (signal_clk);
303    xicu.p_vci                  (signal_vci_tgt_d_xicu);
304    xicu.p_hwi[0]               (signal_mtty_irq);
305    xicu.p_hwi[1]               (signal_mdma_irq);
306    xicu.p_irq[0]               (signal_proc_irq);
307
308    mdma.p_clk                  (signal_clk);
309    mdma.p_resetn               (signal_resetn);
310    mdma.p_vci_target           (signal_vci_tgt_d_mdma);
311    mdma.p_vci_initiator        (signal_vci_ini_d_mdma);
312    mdma.p_irq[0]               (signal_mdma_irq); 
313
314    mtty.p_clk                  (signal_clk);
315    mtty.p_resetn               (signal_resetn);
316    mtty.p_vci                  (signal_vci_tgt_d_mtty);
317    mtty.p_irq[0]               (signal_mtty_irq); 
318
319    vciexit.p_clk               (signal_clk);
320    vciexit.p_resetn            (signal_resetn);
321    vciexit.p_vci               (signal_vci_tgt_d_exit);
322
323    memc.p_clk                  (signal_clk);
324    memc.p_resetn               (signal_resetn);
325    memc.p_vci_tgt              (signal_vci_tgt_d_memc);
326    memc.p_dspin_in         (signal_dspin_from_proc);
327    memc.p_dspin_out    (signal_dspin_from_memc);
328    memc.p_vci_ixr              (signal_vci_xram);
329
330    xram.p_clk                  (signal_clk);
331    xram.p_resetn               (signal_resetn);
332    xram.p_vci                  (signal_vci_xram);
333       
334/*
335    ringc.p_clk                 (signal_clk);
336    ringc.p_resetn              (signal_resetn);
337    ringc.p_to_initiator[0]     (signal_vci_ini_c_proc);
338    ringc.p_to_initiator[1]     (signal_vci_ini_c_memc);
339    ringc.p_to_target[0]        (signal_vci_tgt_c_proc);
340    ringc.p_to_target[1]        (signal_vci_tgt_c_memc);
341*/
342
343    ringd.p_clk                 (signal_clk);
344    ringd.p_resetn              (signal_resetn);
345    ringd.p_to_initiator[0]     (signal_vci_ini_d_proc);
346    ringd.p_to_initiator[1]     (signal_vci_ini_d_mdma);
347    ringd.p_to_target[0]        (signal_vci_tgt_d_memc);
348    ringd.p_to_target[1]        (signal_vci_tgt_d_brom);
349    ringd.p_to_target[2]        (signal_vci_tgt_d_exit);
350    ringd.p_to_target[3]        (signal_vci_tgt_d_mtty);
351    ringd.p_to_target[4]        (signal_vci_tgt_d_xicu);
352    ringd.p_to_target[5]        (signal_vci_tgt_d_mdma);
353       
354    // simulation loop
355
356    sc_start(sc_core::sc_time(0, SC_NS));
357    signal_resetn = false;
358
359    sc_start(sc_core::sc_time(1, SC_NS));
360    signal_resetn = true;
361       
362    signal_false = false;
363
364    for ( size_t n=1 ; n<ncycles ; n++ )
365    {
366        if ( trace_ok and (n > from_cycle) )
367        {
368            std::cout << "****************** cycle " << std::dec << n
369                      << " ************************************************" << std::endl;
370            proc.print_trace();
371            memc.print_trace();
372            signal_vci_ini_d_proc.print_trace("proc_ini_d");
373            signal_dspin_from_memc.print_trace("proc_dspin_in_c");
374            signal_dspin_from_proc.print_trace("proc_dspin_out_c");
375            signal_vci_tgt_d_memc.print_trace("memc_tgt_d");
376            signal_vci_tgt_c_memc.print_trace("memc_tgt_c");
377            signal_vci_ini_c_memc.print_trace("memc_ini_c");
378            if ( signal_proc_irq.read() ) std::cout << "---- IRQ ----" << std::endl;
379        }
380        sc_start(sc_core::sc_time(1, SC_NS));
381    }
382    return EXIT_SUCCESS;
383}
384
385int sc_main (int argc, char *argv[])
386{
387        try {
388                return _main(argc, argv);
389        } catch (std::exception &e) {
390                std::cout << e.what() << std::endl;
391        } catch (...) {
392                std::cout << "Unknown exception occured" << std::endl;
393                throw;
394        }
395        return 1;
396}
Note: See TracBrowser for help on using the repository browser.