tests/puf_sram: add input args to automation script
This commit is contained in:
parent
83ca890ef7
commit
0de38c2a6f
@ -7,9 +7,16 @@
|
|||||||
# General Public License v2.1. See the file LICENSE in the top level
|
# General Public License v2.1. See the file LICENSE in the top level
|
||||||
# directory for more details.
|
# directory for more details.
|
||||||
|
|
||||||
|
import argparse
|
||||||
import puf_sram_if
|
import puf_sram_if
|
||||||
import numpy
|
import numpy
|
||||||
|
|
||||||
|
DEFAULT_POWER_CYCLES = 500
|
||||||
|
DEFAULT_OFF_TIME = 1
|
||||||
|
DEFAULT_BAUDRATE = 115200
|
||||||
|
DEFAULT_PORT = '/dev/ttyUSB0'
|
||||||
|
DEFAULT_INFO = True
|
||||||
|
|
||||||
|
|
||||||
def min_erntropy(all_meas):
|
def min_erntropy(all_meas):
|
||||||
p1 = numpy.zeros(len(all_meas[0]))
|
p1 = numpy.zeros(len(all_meas[0]))
|
||||||
@ -32,8 +39,22 @@ def min_erntropy(all_meas):
|
|||||||
|
|
||||||
|
|
||||||
def main_func():
|
def main_func():
|
||||||
puf_sram = puf_sram_if.PufSram()
|
p = argparse.ArgumentParser()
|
||||||
seeds = puf_sram.get_seed_list(n=500, off_time=1, allow_print=True)
|
p.add_argument("-n", "--number", type=int, default=DEFAULT_POWER_CYCLES,
|
||||||
|
help="Number of iterations, default: %s" % DEFAULT_POWER_CYCLES)
|
||||||
|
p.add_argument("-t", "--off_time", type=int, default=DEFAULT_OFF_TIME,
|
||||||
|
help="Off time, default: %s [s]" % DEFAULT_OFF_TIME)
|
||||||
|
p.add_argument("-p", "--port", type=str, default=DEFAULT_PORT,
|
||||||
|
help="Serial port, default: %s" % DEFAULT_PORT)
|
||||||
|
p.add_argument("-b", "--baudrate", type=int, default=DEFAULT_BAUDRATE,
|
||||||
|
help="Baudrate of the serial port, default: %d" % DEFAULT_BAUDRATE)
|
||||||
|
p.add_argument("-d", "--disable_output", default=DEFAULT_INFO, action='store_false',
|
||||||
|
help="Disable verbose output")
|
||||||
|
args = p.parse_args()
|
||||||
|
|
||||||
|
puf_sram = puf_sram_if.PufSram(port=args.port, baud=args.baudrate)
|
||||||
|
seeds = puf_sram.get_seed_list(n=args.number, off_time=args.off_time,
|
||||||
|
allow_print=args.disable_output)
|
||||||
seeds = [format(x, '0>32b') for x in seeds]
|
seeds = [format(x, '0>32b') for x in seeds]
|
||||||
H_min, H_min_rel = min_erntropy(seeds)
|
H_min, H_min_rel = min_erntropy(seeds)
|
||||||
|
|
||||||
|
|||||||
@ -12,12 +12,12 @@ import time
|
|||||||
|
|
||||||
class PufSram:
|
class PufSram:
|
||||||
|
|
||||||
def __init__(self, port='/dev/ttyUSB0', baud=115200):
|
def __init__(self, port, baud):
|
||||||
self.__dev = serial.Serial(port, baud, timeout=10)
|
self.__dev = serial.Serial(port, baud, timeout=10)
|
||||||
if(self.__dev.isOpen() is False):
|
if(self.__dev.isOpen() is False):
|
||||||
self.__dev.open()
|
self.__dev.open()
|
||||||
|
|
||||||
def repower(self, shutdown_time=1):
|
def repower(self, shutdown_time):
|
||||||
self.__dev.setRTS(True)
|
self.__dev.setRTS(True)
|
||||||
time.sleep(shutdown_time)
|
time.sleep(shutdown_time)
|
||||||
self.__dev.setRTS(False)
|
self.__dev.setRTS(False)
|
||||||
@ -38,7 +38,7 @@ class PufSram:
|
|||||||
return data
|
return data
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def get_seed_list(self, n=10000, off_time=1, allow_print=False):
|
def get_seed_list(self, n, off_time, allow_print):
|
||||||
data = list()
|
data = list()
|
||||||
for i in range(0, n):
|
for i in range(0, n):
|
||||||
self.repower(off_time)
|
self.repower(off_time)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user