Exemple #1
0
def install():
    import usi
    from usi.tools.args import parser

    parser.add_argument('-c', '--console', dest='console', action='store_true', default=False, help='Execute an interactive python console right after start of the sc_main')

    usi.on("start_of_initialization")(args)
    #usi.on("start_of_simulation")(start)
    #usi.set_default_pause_handler(start)
    print('alternative')
    usi.on("pause_of_simulation")(usi.execute_default_pause_handler)
Exemple #2
0
def install():
    import usi
    from usi.tools.args import parser

    parser.add_argument(
        '-c',
        '--console',
        dest='console',
        action='store_true',
        default=False,
        help=
        'Execute an interactive python console right after start of the sc_main'
    )

    usi.on("start_of_initialization")(args)
    #usi.on("start_of_simulation")(start)
    #usi.set_default_pause_handler(start)
    print('alternative')
    usi.on("pause_of_simulation")(usi.execute_default_pause_handler)
Exemple #3
0
from __future__ import print_function
from __future__ import absolute_import
import usi
import sys
import json
from . import parameter
from usi.tools.args import parser, get_args

"""Load initial model configuration"""
parser.add_argument('-o', '--option', dest='option', action='append', default=[], type=str, help='Give configuration option')
parser.add_argument('-j', '--json', dest='json', action='append', default=[], type=str, help='Read JSON configuration')
parser.add_argument('-l', '--list', dest='list', action='store_true', help='List options')

@usi.on("start_of_initialization")
def parse_args(*k, **kw):
    for jsonfile in get_args().json:
        with open(jsonfile) as openfile:
            values = json.load(openfile)
            parameter.writeValueDict('', values)

    for option in get_args().option:
        l = option.split('=')
        if len(l) == 2:
            name = l[0]
            value = l[1]
            #if parameter.exists(name):
            parameter.write(name, value)
            #else:
            #    print("Option does not exist: %s" % (name))
            #    sys.exit(1)
        else:
Exemple #4
0
      'main': 'mainIntrinsic32',
      'open': 'openIntrinsic32',
      'random': 'randomIntrinsic32',
      'read': 'readIntrinsic32',
      'rename' : 'renameIntrinsic32',
#      'sbrk': 'sbrkIntrinsic32',
      'stat': 'statIntrinsic32',
      'time': 'timeIntrinsic32',
      'times': 'timesIntrinsic32',
      'unlink': 'unlinkIntrinsic32',
      'usleep': 'usleepIntrinsic32',
      'utimes': 'utimesIntrinsic32',
      'write': 'writeIntrinsic32'
    }
}
parser.add_argument('-e', '--loadelf', dest='loadelf', action='append', default=[], type=str, help='Load Data from ELF file into memory')
parser.add_argument('-i', '--intrinsics', dest='intrinsics', action='append', default=[], type=str, help='Load intrinsics for an elf file to a processor')

def load_elf_into_scireg(filename, stores, base):
    with open(filename, "rb") as stream:
        elf = ELFFile(stream)
        for section in elf.iter_sections():
            if section.header["sh_flags"] & constants.SH_FLAGS.SHF_ALLOC:
                addr = section.header["sh_addr"] - base
                data = section.data()

                if isinstance(stores, usi.USIDelegate):
                    stores = [stores]
                for store in stores:
                    if isinstance(store, str):
                        store = store.encode('utf-8')
Exemple #5
0
        '_lstat': 'lstatIntrinsic32',
        '_open': 'openIntrinsic32',
        '_read': 'readIntrinsic32',
        '_rename': 'renameIntrinsic32',
        '_sbrk': 'sbrkIntrinsic32',
        '_stat': 'statIntrinsic32',
        '_sysconf': 'sysconfIntrinsic32',
        '_usleep': 'usleepIntrinsic32',
        '_utimes': 'utimesIntrinsic32',
        '_write': 'writeIntrinsic32'
    }
}
parser.add_argument('-e',
                    '--loadelf',
                    dest='loadelf',
                    action='append',
                    default=[],
                    type=str,
                    help='Load Data from ELF file into memory')
parser.add_argument('-i',
                    '--intrinsics',
                    dest='intrinsics',
                    action='append',
                    default=[],
                    type=str,
                    help='Load intrinsics for an elf file to a processor')


def load_elf_into_scireg(filename, stores, base):
    with open(filename, "rb") as stream:
        elf = ELFFile(stream)
Exemple #6
0
from __future__ import print_function
import logging
import sys
import usi
import usi.systemc
from usi.tools.args import parser, get_args
from . import console_reporter
from . import db_reporter

REPORT = console_reporter.report

parser.add_argument(
    '-r',
    '--reporter',
    dest='reporter',
    action='store',
    default='console',
    type=str,
    help=
    'Changes the backend for the reporter: console (default) or hdf5=<path>')
parser.add_argument('-v',
                    '--verbosity',
                    dest='verbosity',
                    action='store',
                    default=500,
                    type=int,
                    help='Changes the report verbosity')
parser.add_argument('-ei',
                    '--el_index',
                    dest='el_index',
                    action='store',
Exemple #7
0
from __future__ import print_function
import sys
import usi
from usi.tools.args import parser, get_args
from . import console_reporter
from . import db_reporter

REPORT = console_reporter.report

parser.add_argument('-r', '--reporter', dest='reporter', action='store', default='console', type=str, help='Changes the backend for the reporter: console (default) or hdf5=<path>')
parser.add_argument('-v', '--verbosity', dest='verbosity', action='store', default=500, type=int, help='Changes the report verbosity')

@usi.on('start_of_initialization')
def start_of_initialization(phase):
    global REPORT
    reporter = get_args().reporter
    verbosity = get_args().verbosity
    filename = None
    if reporter.startswith("hdf5="):
        filename = reporter[5:]
        db_reporter.logger = db_reporter.Logger(filename)
        REPORT = db_reporter.report
    elif reporter == "console":
        REPORT = console_reporter.report
    else:
        print("Reporter unknown '%s'" % reporter)
        sys.exit(1)
    usi.on("report")(REPORT)

    print("Set verbosity to level %d" % verbosity)
    print("Old verbosity level was %d" % usi.set_verbosity(verbosity))