mirror of
https://github.com/openhwgroup/cvw
synced 2025-02-11 06:05:49 +00:00
fix random data len bug
This commit is contained in:
parent
c565ae3a51
commit
6b03e41063
@ -125,18 +125,17 @@ def main():
|
|||||||
|
|
||||||
|
|
||||||
def random_hex(reg_name):
|
def random_hex(reg_name):
|
||||||
|
pad = XLEN // 4
|
||||||
if reg_name in nonstandard_register_lengths:
|
if reg_name in nonstandard_register_lengths:
|
||||||
size = nonstandard_register_lengths[reg_name]
|
size = nonstandard_register_lengths[reg_name]
|
||||||
pad = (XLEN-size) // 4
|
|
||||||
else:
|
else:
|
||||||
size = XLEN
|
size = XLEN
|
||||||
pad = 0
|
|
||||||
|
|
||||||
if random_stimulus:
|
if random_stimulus:
|
||||||
return f"0x{'0'*pad}{random.getrandbits(size):x}"
|
return "0x" + f"{random.getrandbits(size):x}".rjust(pad, "0")
|
||||||
else:
|
else:
|
||||||
data = 0xa5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5
|
data = 0xa5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5
|
||||||
return f"0x{'0'*pad}{(data & (2**size-1)):x}"
|
return "0x" + f"{(data & (2**size-1)):x}".rjust(pad, "0")
|
||||||
|
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
Loading…
Reference in New Issue
Block a user