From 6b03e41063527f5255b7ba750ebbd86b1da243f1 Mon Sep 17 00:00:00 2001 From: Matthew <106996253+Matthew-Otto@users.noreply.github.com> Date: Tue, 4 Jun 2024 14:57:10 -0500 Subject: [PATCH] fix random data len bug --- bin/hw_debug_test.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/bin/hw_debug_test.py b/bin/hw_debug_test.py index 4c4b5986f..b8f7db90f 100755 --- a/bin/hw_debug_test.py +++ b/bin/hw_debug_test.py @@ -125,18 +125,17 @@ def main(): def random_hex(reg_name): + pad = XLEN // 4 if reg_name in nonstandard_register_lengths: size = nonstandard_register_lengths[reg_name] - pad = (XLEN-size) // 4 else: size = XLEN - pad = 0 if random_stimulus: - return f"0x{'0'*pad}{random.getrandbits(size):x}" + return "0x" + f"{random.getrandbits(size):x}".rjust(pad, "0") else: data = 0xa5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5 - return f"0x{'0'*pad}{(data & (2**size-1)):x}" + return "0x" + f"{(data & (2**size-1)):x}".rjust(pad, "0") main()