Changeset 420 for branches/v4


Ignore:
Timestamp:
Jun 25, 2013, 5:16:29 PM (11 years ago)
Author:
porquet
Message:

various modifications to the platform

  • make simulation parameters a structure instead of global variables
  • choice between tsar_boot and dummy_boot (linux directly loaded in RAM)
  • change the default target (current target 0, the memcache, doesn't handle errors properly)
Location:
branches/v4/platforms/tsarv4_mono_mmu_ioc
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/v4/platforms/tsarv4_mono_mmu_ioc/Makefile

    r419 r420  
    1212        soclib-cc $(SOCLIB_CC_ARGS) -P -p $(SOCLIB_DESC) -o $(SIMULATOR_BINARY)
    1313
     14run_tsar_boot: all tsar_boot.bin disk.img
     15        $(SIMULATOR_CMD) --rom tsar_boot.bin --dsk disk.img
     16
     17run_dummy_boot: all vmlinux disk.img
     18        $(SIMULATOR_CMD) --rom vmlinux --dsk disk.img --dummy-boot
     19
    1420cscope.out:
    1521        soclib-cc -p $(SOCLIB_DESC) --tags
  • branches/v4/platforms/tsarv4_mono_mmu_ioc/top.cpp

    r410 r420  
    8686 */
    8787
    88 char *soft_path = NULL;
    89 char *bd_path = NULL;
    90 bool trace_enabled = false;
    91 size_t trace_start_cycle = 0;
    92 
    93 /*
    94  * arguments parsing
    95  */
    96 
    97 void args_parse(unsigned int argc, char *argv[])
     88struct param_s {
     89    char *rom_path;
     90    char *dsk_path;
     91    bool dummy_boot;
     92    bool trace_enabled;
     93    size_t trace_start_cycle;
     94};
     95
     96#define PARAM_INITIALIZER   \
     97{                           \
     98    .rom_path = NULL,      \
     99    .dsk_path = NULL,        \
     100    .dummy_boot = false,    \
     101    .trace_enabled = false, \
     102    .trace_start_cycle = 0  \
     103}
     104
     105static inline void print_param(const struct param_s &param)
    98106{
    99     if (argc > 1)
    100     {
    101         for (size_t n = 1; n < argc; n = n + 2)
    102         {
    103             if ((strcmp(argv[n], "-soft") == 0) && ((n + 1) < argc))
    104             {
    105                 assert((soft_path = strdup(argv[n + 1]))
    106                         && "insufficient memory");
    107             }
    108             else if ((strcmp(argv[n], "-img") == 0) && ((n + 1) < argc))
    109             {
    110                 assert((bd_path = strdup(argv[n + 1]))
    111                         && "insufficient memory");
    112             }
    113             else if ((strcmp(argv[n], "-trace") == 0) && ((n + 1) < argc))
    114             {
    115                 trace_enabled = true;
    116                 trace_start_cycle = atoi(argv[n + 1]);
    117             }
    118             else
    119             {
    120                 std::cout << "Error: don't understand option " << argv[n] << std::endl;
    121                 std::cout << "Accepted arguments are :" << std::endl;
    122                 std::cout << "-soft pathname" << std::endl;
    123                 std::cout << "-img pathname" << std::endl;
    124                 std::cout << "[-trace trace_start_cycle]" << std::endl;
    125                 exit(0);
    126             }
    127         }
    128     }
    129 
    130     assert(soft_path && "-soft is not optional");
    131     assert(bd_path && "-img is not optional");
    132107    std::cout << std::endl;
    133108    std::cout << "simulation parameters:" << std::endl;
    134     std::cout << "  soft = "        << soft_path << std::endl;
    135     std::cout << "  img = "         << bd_path << std::endl;
    136     std::cout << "  trace = "       << trace_enabled << std::endl;
     109    std::cout << "  rom         = " << param.rom_path << std::endl;
     110    std::cout << "  dummy boot  = " << param.dummy_boot << std::endl;
     111    std::cout << "  dsk         = " << param.dsk_path << std::endl;
     112    std::cout << "  trace       = " << param.trace_enabled << std::endl;
     113    if (param.trace_enabled)
     114        std::cout << "    start cyc = " << param.trace_start_cycle << std::endl;
     115
    137116    std::cout << std::endl;
     117}
     118
     119
     120/*
     121 * arguments parsing
     122 */
     123
     124void args_parse(unsigned int argc, char *argv[], struct param_s &param)
     125{
     126    for (size_t n = 1; n < argc; n = n + 2)
     127    {
     128        if ((strcmp(argv[n], "--rom") == 0) && ((n + 1) < argc))
     129        {
     130            assert((param.rom_path = strdup(argv[n + 1]))
     131                    && "insufficient memory");
     132        }
     133        else if ((strcmp(argv[n], "--dsk") == 0) && ((n + 1) < argc))
     134        {
     135            assert((param.dsk_path = strdup(argv[n + 1]))
     136                    && "insufficient memory");
     137        }
     138        else if (strcmp(argv[n], "--dummy-boot") == 0)
     139        {
     140            param.dummy_boot = true;
     141            /* we don't have an extra argument */
     142            n = n - 1;
     143        }
     144        else if ((strcmp(argv[n], "--trace") == 0) && ((n + 1) < argc))
     145        {
     146            param.trace_enabled = true;
     147            param.trace_start_cycle = atoi(argv[n + 1]);
     148        }
     149        else
     150        {
     151            std::cout << "Error: don't understand option " << argv[n] << std::endl;
     152            std::cout << "Accepted arguments are :" << std::endl;
     153            std::cout << "--rom pathname" << std::endl;
     154            std::cout << "--dsk pathname" << std::endl;
     155            std::cout << "[--dummy-boot]" << std::endl;
     156            std::cout << "[-trace trace_start_cycle]" << std::endl;
     157            exit(0);
     158        }
     159    }
     160
     161    /* check parameters */
     162    assert(param.rom_path && "--rom is not optional");
     163    assert(param.dsk_path && "--dsk is not optional");
     164
     165    print_param(param);
    138166}
    139167
     
    151179#endif
    152180
     181    struct param_s param = PARAM_INITIALIZER;
     182
    153183    /* parse arguments */
    154     args_parse(argc, argv);
     184    args_parse(argc, argv, param);
    155185
    156186    /*
     
    181211
    182212    Loader loader;
    183     loader.load_file(soft_path);
     213    loader.load_file(param.rom_path);
    184214
    185215#ifdef CONFIG_GDB_SERVER
     
    189219    typedef Mips32ElIss proc_iss;
    190220#endif
     221
     222    if (param.dummy_boot == true)
     223    {
     224        /* boot linux image directly */
     225        const BinaryFileSymbol *bfs = loader.get_symbol_by_name("kernel_entry");
     226        std::cout << "setResetAdress: " << std::hex << bfs->address() << std::endl;
     227        proc_iss::setResetAddress(bfs->address());
     228    }
    191229
    192230    VciCcVCacheWrapperV4<vci_param, proc_iss > proc("ccvcache",
     
    205243                1,          // memory cache local id
    206244                1000,       // max frozen cycles
    207                 trace_start_cycle,
    208                 trace_enabled);
     245                param.trace_start_cycle,
     246                param.trace_enabled);
    209247
    210248    VciSimpleRam<vci_param> xram("xram", IntTab(0), maptabd, loader);
     
    217255            16, 256, 16,    // cache size
    218256            1024, 4, 4,     // HEAP size, TRT size, UPT size
    219             trace_start_cycle, trace_enabled);
     257            param.trace_start_cycle, param.trace_enabled);
    220258
    221259    VciSimhelper<vci_param> vciexit("vciexit", IntTab(2), maptabd);
     
    227265
    228266    VciBlockDeviceTsarV4<vci_param> iobd("iobd", maptabd, IntTab(1), IntTab(5),
    229             bd_path); // mapped_file[, block_size=512, latency=0]
     267            param.dsk_path); // mapped_file[, block_size=512, latency=0]
    230268
    231269    VciVgmn<vci_param> ringd("ringd", maptabd,
    232             2, 6,   // #initiators, #targets
    233             2, 8);  // min_latency, FIFO depth
     270            2, 6,       // #initiators, #targets
     271            2, 8,       // min_latency, FIFO depth
     272            IntTab(1)); // default target
    234273
    235274    VciVgmn<vci_param> ringc("ringc", maptabc,
     
    350389    signal_resetn = true;
    351390
    352     if (trace_enabled)
     391    if (param.trace_enabled)
    353392    {
    354         if (trace_start_cycle > 1)
     393        if (param.trace_start_cycle > 1)
    355394            // simulate without output until trace_start_cycle
    356             sc_start(sc_time(trace_start_cycle, SC_NS));
     395            sc_start(sc_time(param.trace_start_cycle, SC_NS));
    357396
    358397        // enable debugging output
    359         for (size_t n = trace_start_cycle ;; n++)
     398        for (size_t n = param.trace_start_cycle ;; n++)
    360399        {
    361400            std::cout << "****************** cycle " << std::dec << n
Note: See TracChangeset for help on using the changeset viewer.