当前位置: 首页>>代码示例>>Python>>正文


Python log.SimLog类代码示例

本文整理汇总了Python中cocotb.log.SimLog的典型用法代码示例。如果您正苦于以下问题:Python SimLog类的具体用法?Python SimLog怎么用?Python SimLog使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了SimLog类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: E_process_second_input_round_test

def E_process_second_input_round_test(dut):
    """Test input processing with 32 word input"""
    log = SimLog("cocotb.%s" % dut._name)
    cocotb.fork(Clock(dut.clk_i, 10000).start())
    
    mockObject = Sha1Model()

    yield reset(dut)
    #yield load_data(dut, log, mockObject, 16)

    #mockObject.processInput()
    #mockObject.displayAll()
    
    yield load_data(dut, log, mockObject, 16)
    mockObject.processInput()
    yield load_data(dut, log, mockObject, 66)
    
    mockOut = "{:08x}".format(mockObject.W[16])
    compare1 = convert_hex(dut.pinput1.test_word_1.value).rjust(8, '0')
    compare2 = convert_hex(dut.pinput1.test_word_5.value).rjust(8, '0')
    
    if compare1 != mockOut:
        raise TestFailure(
            "First load incorrect: {0} != {1}".format(compare1, mockOut))
    elif compare2 != "{:08x}".format(mockObject.W[79]):
        raise TestFailure(
            "First load incorrect: {0} != {1}".format(compare2, "{:08x}".format(mockObject.W[79])))
    else:
        log.info("First load ok!") 
开发者ID:JarrettR,项目名称:FPGA-Cryptoparty,代码行数:29,代码来源:test_sha1.py

示例2: F_exhaust_mk_test

def F_exhaust_mk_test(dut):
    """
    Hits end of MK list before matching
    """
    log = SimLog("cocotb.%s" % dut._name)
    log.setLevel(logging.DEBUG)
    cocotb.fork(Clock(dut.clk_i, 1000).start())
    
    filename = '../test_data/wpa2-psk-linksys.hccap'
    start = '1000000000'
    end =   '1000000020'    #Comparison currently hardcoded as 1000000200

    dut.cs_i <= 1
    yield reset(dut)
    yield RisingEdge(dut.clk_i)
    
    yield load_file(dut, filename)
    yield load_mk(dut, start)
    yield load_mk(dut, end)
    
    #This clock isn't necessary while pipelining
    yield RisingEdge(dut.clk_i)
    
    yield wait_process(dut)
    
    if int(str(dut.pmk_valid), 2) == 0:
        raise TestFailure("Master key found, not good!")
    else:
        log.info("List done")
开发者ID:JarrettR,项目名称:FPGA-Cryptoparty,代码行数:29,代码来源:test_ztex.py

示例3: F_process_first_buffer_test

def F_process_first_buffer_test(dut):
    """Test data after processing the first message buffer"""
    log = SimLog("cocotb.%s" % dut._name)
    cocotb.fork(Clock(dut.clk_i, 10000).start())
    
    mockObject = Sha1Model()

    yield reset(dut)
    #yield load_data(dut, log, mockObject, 16)

    #mockObject.processInput()
    #mockObject.displayAll()
    
    yield load_data(dut, log, mockObject, 16)
    mockObject.processInput()
    mockObject.processBuffer()
    yield load_data(dut, log, mockObject, 65)
    yield load_data(dut, log, mockObject, 85)
    
    mockOut = "{:08x}".format(mockObject.H0)
    compare1 = convert_hex(dut.pbuffer1.test_word_4.value).rjust(8, '0')
    
    if compare1 != mockOut:
        raise TestFailure(
            "First buffer incorrect: {0} != {1}".format(compare1, mockOut))
    else:
        log.info("First buffer ok!") 
开发者ID:JarrettR,项目名称:FPGA-Cryptoparty,代码行数:27,代码来源:test_sha1.py

示例4: E_find_mk_test

def E_find_mk_test(dut):
    """
    Finds MK successfully
    """
    log = SimLog("cocotb.%s" % dut._name)
    log.setLevel(logging.DEBUG)
    cocotb.fork(Clock(dut.clk_i, 1000).start())
    
    filename = '../test_data/wpa2-psk-linksys.hccap'
    start = '1000000000'
    end =   '1000000300'    #Comparison currently hardcoded as 1000000200

    dut.cs_i <= 1
    yield reset(dut)
    yield RisingEdge(dut.clk_i)
    
    print_process_vars(dut)
    yield load_file(dut, filename)
    print_process_vars(dut)
    yield load_mk(dut, start)
    print_process_vars(dut)
    yield load_mk(dut, end)
    print_process_vars(dut)
    
    #This clock isn't necessary while pipelining
    yield RisingEdge(dut.clk_i)
    
    yield wait_process(dut)
    
    print_process_vars(dut)
    
    if int(str(dut.pmk_valid), 2) == 0:
        raise TestFailure("MK search failed")
    else:
        log.info("Master key found!")
开发者ID:JarrettR,项目名称:FPGA-Cryptoparty,代码行数:35,代码来源:test_ztex.py

示例5: A_gen_data_test

def A_gen_data_test(dut):
    """
    Tests that gen_tenhex generates sane values
    """
    log = SimLog("cocotb.%s" % dut._name)
    cocotb.fork(Clock(dut.clk_i, 10000).start())
    
    outStr = ''
    
    yield reset(dut)
    yield RisingEdge(dut.clk_i)
        
    for x in xrange(0xff):
        complete = int(dut.main1.gen1.complete_o.value)
        if complete != 0:
            raise TestFailure("Premature completion")
        
        outStr = '{:x}'.format(int(dut.main1.gen1.mk_test9.value)) + \
            '{:x}'.format(int(dut.main1.gen1.mk_test8.value)) + \
            '{:x}'.format(int(dut.main1.gen1.mk_test7.value)) + \
            '{:x}'.format(int(dut.main1.gen1.mk_test6.value)) + \
            '{:x}'.format(int(dut.main1.gen1.mk_test5.value)) + \
            '{:x}'.format(int(dut.main1.gen1.mk_test4.value)) + \
            '{:x}'.format(int(dut.main1.gen1.mk_test3.value)) + \
            '{:x}'.format(int(dut.main1.gen1.mk_test2.value)) + \
            '{:x}'.format(int(dut.main1.gen1.mk_test1.value)) + \
            '{:x}'.format(int(dut.main1.gen1.mk_test0.value))
       
        
        yield RisingEdge(dut.clk_i)
        
    if outStr != "00000000fe":
        raise TestFailure("Wrong loaded values!")
    else:
        log.info("Ok!")
开发者ID:JarrettR,项目名称:FPGA-Cryptoparty,代码行数:35,代码来源:test_wpa2.py

示例6: __init__

    def __init__(self, inst, parent):
        if hasattr(inst, "__name__"):
            self.__name__ = "%s" % inst.__name__
            self.log = SimLog("cocotb.coroutine.%s" % self.__name__, id(self))
        else:
            self.log = SimLog("cocotb.coroutine.fail")

        if sys.version_info[:2] >= (3, 5) and inspect.iscoroutine(inst):
            self._natively_awaitable = True
            self._coro = inst.__await__()
        else:
            self._natively_awaitable = False
            self._coro = inst
        self._started = False
        self._callbacks = []
        self._parent = parent
        self.__doc__ = parent._func.__doc__
        self.module = parent._func.__module__
        self.funcname = parent._func.__name__
        self._outcome = None

        if not hasattr(self._coro, "send"):
            self.log.error("%s isn't a valid coroutine! Did you use the yield "
                           "keyword?" % self.funcname)
            raise CoroutineComplete()
开发者ID:TC01,项目名称:cocotb,代码行数:25,代码来源:decorators.py

示例7: A_cache_data_test

def A_cache_data_test(dut):
    """
    Tests that initial data cache
    gets built and latched properly
    """
    log = SimLog("cocotb.%s" % dut._name)
    cocotb.fork(Clock(dut.clk_i, 10000).start())
    
    mockSha1 = wpa2slow.sha1.Sha1Model()
    mockObject = wpa2slow.hmac.HmacModel(mockSha1)
    
    yield reset(dut)
    size = random.randint(8, 64)
    print "Length: {:d}".format(size)
    yield load_random_data(dut, log, mockObject, size)

    #mockObject.displayAll()
    mockOut = "{}".format(mockObject.shaBo)

    print convert_hex(dut.test_word_1) + " " + convert_hex(dut.test_word_2) + " " + convert_hex(dut.test_word_3) + " " + convert_hex(dut.test_word_4) + " " + convert_hex(dut.test_word_5)

    if convert_hex(dut.test_word_1).zfill(8) != mockOut:
        raise TestFailure(
            "Load data is incorrect: {0} != {1}".format(convert_hex(dut.test_word_1), mockOut))
    else:
        log.info("Ok!")
开发者ID:JarrettR,项目名称:FPGA-Cryptoparty,代码行数:26,代码来源:test_hmac.py

示例8: A_load_config_test

def A_load_config_test(dut):
    """
    Test correct start/end parameters get loaded into DUT
    """
    log = SimLog("cocotb.%s" % dut._name)
    #log.setLevel(logging.DEBUG)
    cocotb.fork(Clock(dut.clk_i, 1000).start())
    
    mk_start = '1222222222'
    mk_end = '1222222f22'
    
    #Todo: fix this garbage when GHDL implements arrays in their VPI
    dut.test_start_val0 <= ord(mk_start[0])
    dut.test_start_val1 <= ord(mk_start[1])
    dut.test_start_val2 <= ord(mk_start[2])
    dut.test_start_val3 <= ord(mk_start[3])
    dut.test_start_val4 <= ord(mk_start[4])
    dut.test_start_val5 <= ord(mk_start[5])
    dut.test_start_val6 <= ord(mk_start[6])
    dut.test_start_val7 <= ord(mk_start[7])
    dut.test_start_val8 <= ord(mk_start[8])
    dut.test_start_val9 <= ord(mk_start[9])
    
    dut.test_end_val0 <= ord(mk_end[0])
    dut.test_end_val1 <= ord(mk_end[1])
    dut.test_end_val2 <= ord(mk_end[2])
    dut.test_end_val3 <= ord(mk_end[3])
    dut.test_end_val4 <= ord(mk_end[4])
    dut.test_end_val5 <= ord(mk_end[5])
    dut.test_end_val6 <= ord(mk_end[6])
    dut.test_end_val7 <= ord(mk_end[7])
    dut.test_end_val8 <= ord(mk_end[8])
    dut.test_end_val9 <= ord(mk_end[9])
    
    dut.init_load_i <= 1
    yield RisingEdge(dut.clk_i)
    dut.rst_i <= 1
    
    yield RisingEdge(dut.clk_i)
    dut.rst_i <= 0
    yield RisingEdge(dut.clk_i)
    dut.init_load_i <= 0
    
    yield wait_process(dut)
    #print_mk(dut) 
    
    if mk_end[1] != chr(int(str(dut.test_mk_val1), 2)):
        raise TestFailure("MK Final Value 1 Mismatch")
    if mk_end[3] != chr(int(str(dut.test_mk_val3), 2)):
        raise TestFailure("MK Final Value 3 Mismatch")
    if mk_end[7] != chr(int(str(dut.test_mk_val7), 2)):
        raise TestFailure("MK Final Value 7 Mismatch")
    if mk_end[9] != chr(int(str(dut.test_mk_val9), 2)):
        raise TestFailure("MK Final Value 9 Mismatch")
    else:
        log.info("MK Generation Ok!")
开发者ID:JarrettR,项目名称:FPGA-Cryptoparty,代码行数:56,代码来源:test_gentenhex.py

示例9: __init__

    def __init__(self):

        self.log = SimLog("cocotb.scheduler")
        if _debug:
            self.log.setLevel(logging.DEBUG)

        # Use OrderedDict here for deterministic behavior (gh-934)

        # A dictionary of pending coroutines for each trigger,
        # indexed by trigger
        self._trigger2coros = collections.OrderedDict()

        # A dictionary mapping coroutines to the trigger they are waiting for
        self._coro2trigger = collections.OrderedDict()

        # Our main state
        self._mode = Scheduler._MODE_NORMAL

        # A dictionary of pending writes
        self._writes = collections.OrderedDict()

        self._pending_coros = []
        self._pending_triggers = []
        self._pending_threads = []
        self._pending_events = []   # Events we need to call set on once we've unwound

        self._terminate = False
        self._test_result = None
        self._entrypoint = None
        self._main_thread = threading.current_thread()

        self._is_reacting = False

        self._write_coro_inst = None
        self._writes_pending = Event()
开发者ID:cmarqu,项目名称:cocotb,代码行数:35,代码来源:scheduler.py

示例10: __init__

 def __init__(self):
     self._outcome = None
     self.thread = None
     self.event = Event()
     self.state = external_state.INIT
     self.cond = threading.Condition()
     self._log = SimLog("cocotb.external.thead.%s" % self.thread, id(self))
开发者ID:TC01,项目名称:cocotb,代码行数:7,代码来源:scheduler.py

示例11: __init__

    def __init__(self, callback=None, event=None):
        """
        Constructor for a monitor instance

        callback will be called with each recovered transaction as the argument

        If the callback isn't used, received transactions will be placed on a
        queue and the event used to notify any consumers.
        """
        self._event = event
        self._wait_event = None
        self._recvQ = []
        self._callbacks = []
        self.stats = MonitorStatistics()
        self._wait_event = Event()

        # Subclasses may already set up logging
        if not hasattr(self, "log"):
            self.log = SimLog("cocotb.monitor.%s" % (self.__class__.__name__))

        if callback is not None:
            self.add_callback(callback)

        # Create an independent coroutine which can receive stuff
        self._thread = cocotb.scheduler.add(self._monitor_recv())
开发者ID:cpehle,项目名称:cocotb,代码行数:25,代码来源:__init__.py

示例12: RunningTest

class RunningTest(RunningCoroutine):
    """Add some useful Test functionality to a RunningCoroutine."""

    class ErrorLogHandler(logging.Handler):
        def __init__(self, fn):
            self.fn = fn
            logging.Handler.__init__(self, level=logging.DEBUG)

        def handle(self, record):
            self.fn(self.format(record))

    def __init__(self, inst, parent):
        self.error_messages = []
        RunningCoroutine.__init__(self, inst, parent)
        self.log = SimLog("cocotb.test.%s" % self.__name__, id(self))
        self.started = False
        self.start_time = 0
        self.start_sim_time = 0
        self.expect_fail = parent.expect_fail
        self.expect_error = parent.expect_error
        self.skip = parent.skip
        self.stage = parent.stage

        self.handler = RunningTest.ErrorLogHandler(self._handle_error_message)
        cocotb.log.addHandler(self.handler)

    def _advance(self, outcome):
        if not self.started:
            self.error_messages = []
            self.log.info("Starting test: \"%s\"\nDescription: %s" %
                          (self.funcname, self.__doc__))
            self.start_time = time.time()
            self.start_sim_time = get_sim_time('ns')
            self.started = True
        try:
            self.log.debug("Sending {}".format(outcome))
            return outcome.send(self._coro)
        except TestComplete as e:
            if isinstance(e, TestFailure):
                self.log.warning(str(e))
            else:
                self.log.info(str(e))

            buff = StringIO()
            for message in self.error_messages:
                print(message, file=buff)
            e.stderr.write(buff.getvalue())
            raise
        except StopIteration:
            raise TestSuccess()
        except Exception as e:
            raise raise_error(self, "Send raised exception:")

    def _handle_error_message(self, msg):
        self.error_messages.append(msg)
开发者ID:cmarqu,项目名称:cocotb,代码行数:55,代码来源:decorators.py

示例13: __init__

 def __init__(self, name, filepath=None):
     self.name = name
     self._packets = {}
     self._filepath = filepath
     self.fullname = '\'' + self.name + '\''
     self.log = SimLog('cocotb.' + self.name)
     if self._filepath:
         self._source = open(self._filepath)
         self.log.debug("loaded file %s" % self._filepath)
     self.log.debug("Created feed!")
开发者ID:FinnG,项目名称:cocotb,代码行数:10,代码来源:__init__.py

示例14: H_continuous_buffer_test

def H_continuous_buffer_test(dut):
    """Loop message buffer several times"""
    log = SimLog("cocotb.%s" % dut._name)
    cocotb.fork(Clock(dut.clk_i, 10000).start())
    

    yield reset(dut)
    
    iterations = 30
    mockW = [0] * iterations
    compareW = [0] * iterations
    for i in xrange(iterations):
        mockObject = Sha1Model()
        #
    
        yield load_data(dut, log, mockObject, 16)
        mockObject.processInput()
        mockObject.processBuffer()
    
        #yield load_data(dut, log, mockObject, 73)
    
        #yield load_data(dut, log, None, 85)
    
        mockOut = "{:08x}".format(mockObject.H0)
        compare0 = convert_hex(dut.test_sha1_process_buffer0_o.value).rjust(8, '0')
        compare1 = convert_hex(dut.test_sha1_process_buffer_o.value).rjust(8, '0')
        #print mockOut + " - " + compare0 + " - " + compare1 + " - " + str(dut.w_processed_valid.value)
        
        mockW[i] = mockOut
        if i >= 11:
            compareW[i - 11] = compare1
        
    #print str(mockW[0:-11]).strip('[]')
    #print str(compareW[0:-11]).strip('[]')
       
    

    if mockW[0:-11] != compareW[0:-11]:
        raise TestFailure(
            "Continuous buffer incorrect: {0} != {1}".format(str(mockW[0:-11]).strip('[]'), str(compareW[0:-11]).strip('[]')))
    else:
        log.info("Continuous buffer ok!") 
开发者ID:JarrettR,项目名称:FPGA-Cryptoparty,代码行数:42,代码来源:test_sha1.py

示例15: __init__

    def __init__(self, inst, parent):
        if hasattr(inst, "__name__"):
            self.__name__ = "%s" % inst.__name__
            self.log = SimLog("cocotb.coroutine.%s" % self.__name__, id(self))
        else:
            self.log = SimLog("cocotb.coroutine.fail")
        self._coro = inst
        self._finished = False
        self._callbacks = []
        self._join = _Join(self)
        self._parent = parent
        self.__doc__ = parent._func.__doc__
        self.module = parent._func.__module__
        self.funcname = parent._func.__name__
        self.retval = None

        if not hasattr(self._coro, "send"):
            self.log.error("%s isn't a value coroutine! Did you use the yield keyword?"
                % self.funcname)
            raise CoroutineComplete(callback=self._finished_cb)
开发者ID:enchanter,项目名称:cocotb,代码行数:20,代码来源:decorators.py


注:本文中的cocotb.log.SimLog类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。