def scale2(sum): din = [] din.extend(int_to_byte(float_to_ieee754(sum))) head,payload = sendMessage(0x42000000, 0x00010104, 0x00000001, din) _ret = ieee754_to_float(payload[0]) return _ret
def _unittest_TimeReset(self): self._inputWords = 0x0001 self._outputWords = 0x0001 self._time_hw_addr = 0x41000000 self._enableCycles = 0x00001000 head, payload = sendMessage(self._time_hw_addr, 0x00010100, 0x00000000, None)
def UNITTEST_TIME_CONFIGURE(self): global _time_value global _time_valid _time_value = 0 _time_valid = 0 din = [] din.extend(int_to_byte(self._enableCycles)) din.extend(int_to_byte((self._inputWords << 16) | self._outputWords)) head, payload = sendMessage(self._time_hw_addr, 0x00010204, 0x2, din)
def TEST_START(self): global _time_value global _time_valid _time_value = 0 _time_valid = 0 din = [] #print ("[INFO] Deprecated function version (supported until platform v4)") din.extend( int_to_byte((self._skipInputTicks << 16) | self._skipOutputTicks)) head, payload = sendMessage(self._hw_addr, 0x00010204, 0x00000001, din)
def _unittest_Reset(self): self._skipInputTicks = 0x0001 self._skipOutputTicks = 0x0001 self._hw_addr = 0x41000000 self._enableCycles = 0x00001000 self._clockRate = 0 self._testingFUBlock = 0 head, payload = sendMessage(self._hw_addr, 0x00010100, 0x00000000, None)
def sum_hist_pow(histIN): din = [] for it in histIN: din.extend(int_to_byte(float_to_ieee754(it))) head,payload = sendMessage(0x42000000, 0x00010204, 0x00000010, din) _ret = ieee754_to_float(payload[0]) return _ret
def TEST_SETUP(self): global _time_value global _time_valid _time_value = 0 _time_valid = 0 din = [] din.extend(int_to_byte(self._enableCycles)) din.extend( int_to_byte((self._skipInputTicks << 16) | self._skipOutputTicks)) din.extend(int_to_byte((self._clockRate << 24) | 0x000000)) #din.extend(int_to_byte(0x01000000)) head, payload = sendMessage(self._hw_addr, 0x00010204, 0x3, din)
def l2norm(histIN, histOUT): din = [] for it in histIN: din.extend(int_to_byte(float_to_ieee754(it))) head, payload = sendMessage(0x42000000, 0x00010704, 0x00000010, din) _ret = [] for indx in range(0,16): _ret.append(ieee754_to_float(payload[indx])) histOUT.extend(_ret)
def l2norm_print_inputTimes(): if _l2norm_callcountIN_vld: readings = _l2norm_callcountIN else: readings = l2norm_callCountInput() if readings == 0: print("{0}: No readings".format(sys._getframe().f_code.co_name)) else: print("Readings - {0}".format(sys._getframe().f_code.co_name)) for it in range(0, readings): head, payload = sendMessage(_hw_addr, 0x00020300, 0x00000000, None) time = int(payload[0], 16) print("\tTime {0}: {1}".format(it, time))
def l2norm_print_outputTimes(): if _l2norm_callcountOUT_vld: writings = _l2norm_callcountOUT else: writings = l2norm_callCountOutput() if writings == 0: print("{0}: No writings".format(sys._getframe().f_code.co_name)) else: print("Writings - {0}".format(sys._getframe().f_code.co_name)) for it in range(0, writings): head, payload = sendMessage(_hw_addr, 0x00030300, 0x00000000, None) time = int(payload[0], 16) print("\tTime {0}: {1}".format(it, time))
def unittest_TimeGetTime(self): global _time_valid global _time_value if _time_valid == 1: return _time_value head, payload = sendMessage(self._time_hw_addr, 0x00010300, 0x00000000, None) time = payload[0] #self._unittest_TimeReset() _time_valid = 1 _time_value = time return time
def mult_hist_scale(histAUX, scale, histOUT): din = [] for it in histAUX: din.extend(int_to_byte(float_to_ieee754(it))) din.extend(int_to_byte(float_to_ieee754(scale))) head,payload = sendMessage(0x42000000, 0x00010304, 0x00000011, din) print(head) _ret = [] for indx in range(0,16): _ret.append(ieee754_to_float(payload[indx])) histOUT.extend(_ret)
def unittest_TimeGetTime(self): global _time_valid global _time_value if _time_valid == 1: return _time_value head, payload = sendMessage(self._hw_addr, 0x00010300, 0x00000000, None) time = payload[0] #self._unittest_TimeReset() _time_valid = 1 if self._testingFUBlock == 0: _time_value = int(str(time), 16) else: _time_value = int(str(time), 16) - (int(self._testingFUBlock) - 1) return _time_value
def PRINT_FAILURES_ASSERT_FLOAT_LT(): if _float_lt_failurecount_vld: failures = _float_lt_failurecount else: failures = ASSERT_FLOAT_LT_FAILURECOUNT() if failures == 0: print("{0}: No failures".format(sys._getframe().f_code.co_name)) else: print("Failures - {0}".format(sys._getframe().f_code.co_name)) for it in range(0, failures): head, payload = sendMessage(_hw_addr, 0x000B2E00, 0x00000000, None) callCount = int(payload[0], 16) print("\tcallCount {0}".format(callCount)) time = int(payload[1], 16) print("\tTime {0}".format(time)) expected = ieee754_to_float(payload[2]) print("\tExpected {0}".format(expected)) actual = ieee754_to_float(payload[3]) print("\tActual {0}".format(actual))
def scale2_print_failures(): if _scale2_failurecount_vld: failures = int(_scale2_failurecount, 16) else: failures = int(scale2_failureCount(), 16) if failures == 0: print("{0}: No failures".format(sys._getframe().f_code.co_name)) else: print("Failures - {0}".format(sys._getframe().f_code.co_name)) for it in range(0, failures): head, payload = sendMessage(_hw_addr, 0x00020600, 0x00000000, None) callCount = int(payload[0], 16) print("\tcallCount {0}".format(callCount)) time = int(payload[1], 16) print("\tTime {0}".format(time)) expected = ieee754_to_float(payload[2]) print("\tExpected {0}".format(expected)) actual = ieee754_to_float(payload[3]) print("\tActual {0}".format(actual))
def l2norm_print_failures(): if _l2norm_failurecount_vld: failures = _l2norm_failurecount else: failures = l2norm_failureCount() if failures == 0: print("{0}: No failures".format(sys._getframe().f_code.co_name)) else: print("Failures - {0}".format(sys._getframe().f_code.co_name)) for it in range(0, failures): head, payload = sendMessage(_hw_addr, 0x00030500, 0x00000000, None) callCount = int(payload[0], 16) print("\tcallCount {0}".format(callCount)) actual = ieee754_to_float(payload[1]) print("\tActual {0}".format(actual)) expected = ieee754_to_float(payload[2]) print("\tExpected {0}".format(expected)) time = int(payload[3], 16) print("\tTime {0}".format(time)) delay = int(payload[4], 16) print("\tDelay {0}".format(delay))
def scale2_failureCount(): head, payload = sendMessage(_hw_addr, 0x00020400, 0x00000000, None) _scale2_failurecount = payload[0] _scale2_failurecount_vld = 1 return _scale2_failurecount
def scale2_callCount(): head, payload = sendMessage(_hw_addr, 0x00020300, 0x00000000, None) _scale2_callcount = payload[0] _scale2_callcount_vld = 1 return _scale2_callcount
def scale2_expect(a): din = [] din.extend(int_to_byte(float_to_ieee754(a))) head, payload = sendMessage(_hw_addr, 0x00020204, 0x00000001, din)
def ASSERT_FLOAT_EQ_CALLCOUNT(): head, payload = sendMessage(0x42000000, 0x000B1700, 0x00000000, None) _callcount = int(payload[0], 16) return _callcount
def l2norm_failureCount(): head, payload = sendMessage(_hw_addr, 0x00030400, 0x00000000, None) _l2norm_failurecount = int(payload[0], 16) _l2norm_failurecount_vld = 1 return _l2norm_failurecount
def l2norm_callCountOutput(): head, payload = sendMessage(_hw_addr, 0x00030200, 0x00000000, None) _l2norm_callcountOUT = int(payload[0], 16) _l2norm_callcountOUT_vld = 1 return _l2norm_callcountOUT
def l2norm_expect(size, o): din = [] for it in o: din.extend(int_to_byte(float_to_ieee754(it))) head, payload = sendMessage(_hw_addr, 0x00030104, size, din)
def l2norm_stimuli(size, i): din = [] for it in i: din.extend(int_to_byte(float_to_ieee754(it))) head, payload = sendMessage(_hw_addr, 0x00020104, size, din)
def ASSERT_FLOAT_LT_FAILURECOUNT(): head, payload = sendMessage(_hw_addr, 0x000B2C00, 0x00000000, None) _float_lt_failurecount = int(payload[0], 16) _float_lt_failurecount_vld = 1 return _float_lt_failurecount
def scale2_callTime(): head, payload = sendMessage(_hw_addr, 0x00020500, 0x00000000, None) _time = payload[0] return _time
def l2norm_intervalDelay(i): din = [] din.extend(int_to_byte(i)) head, payload = sendMessage(_hw_addr, 0x00030604, 0x00000001, din)
def ASSERT_FLOAT_LT_CALLCOUNT(): head, payload = sendMessage(_hw_addr, 0x000B2B00, 0x00000000, None) _callcount = int(payload[0], 16) return _callcount