From 2bb8f8fd22277b1e9e0f7afcbb547169b0c390a8 Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Thu, 26 Mar 2020 11:03:43 +0100 Subject: [PATCH] test/gen_access_pattern: cleanup. --- test/gen_access_pattern.py | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/test/gen_access_pattern.py b/test/gen_access_pattern.py index 186dc1e..ba52145 100755 --- a/test/gen_access_pattern.py +++ b/test/gen_access_pattern.py @@ -1,26 +1,27 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import random import argparse def main(): - desc = """ - Generate random access pattern. - Each address in range [base, base+length) will be accessed only once, - but in random order. This ensures that no data will be overwritten. + description = """ + Generate random access pattern for LiteDRAM Pattern Generator/Checker. + + Each address in range [base, base+length) will be accessed only once, but in random order. + This ensures that no data will be overwritten. """ - parser = argparse.ArgumentParser(description=desc) - parser.add_argument('base', help='Base address') - parser.add_argument('length', help='Number of (address, data) pairs') - parser.add_argument('data_width', help='Width of data (used to determine max value)') - parser.add_argument('--seed', help='Use given random seed (int)') + parser = argparse.ArgumentParser(description=description) + parser.add_argument("base", help="Base address") + parser.add_argument("length", help="Number of (address, data) pairs") + parser.add_argument("data_width", help="Width of data (used to determine max value)") + parser.add_argument("--seed", help="Use given random seed (int)") args = parser.parse_args() if args.seed: random.seed(int(args.seed, 0)) - base = int(args.base, 0) - length = int(args.length, 0) + base = int(args.base, 0) + length = int(args.length, 0) data_width = int(args.data_width, 0) address = list(range(length)) @@ -28,7 +29,7 @@ def main(): data = [random.randrange(0, 2**data_width) for _ in range(length)] for a, d in zip(address, data): - print('0x{:08x},0x{:08x}'.format(a, d)) + print("0x{:08x}, 0x{:08x}".format(a, d)) if __name__ == "__main__": main()