Skip to content
Snippets Groups Projects
Commit e76ad6f2 authored by David Mapstone's avatar David Mapstone
Browse files

Added m2d Output file for use with testbench

parent 461e0618
No related branches found
No related tags found
No related merge requests found
......@@ -26,12 +26,13 @@ class InputPacketStruct:
self.block_list.append(block)
class WordStruct:
def __init__(self, data = 0x0, addr = 0x0, packet_num = 0, block_num = 0, trans = "W"):
def __init__(self, data = 0x0, addr = 0x0, packet_num = 0, block_num = 0, trans = "W", size ="word" ):
self.data = data
self.addr = addr
self.trans = trans
self.packet_num = packet_num
self.block_num = block_num
self.size = size
def fri_output(out_file, word_list):
"""
......@@ -41,13 +42,14 @@ def fri_output(out_file, word_list):
"""
# Column Names
col_names = ["Transaction", "Address", "Data"]
col_names = ["Transaction", "Address", "Data", "Size"]
data = []
for word in word_list:
data.append([str(word.trans), str(hex(word.addr)), str(hex(word.data))])
if (word.data > 0):
data.append([str(word.trans), "{0:#0{1}x}".format(word.addr,10), "{0:#0{1}x}".format(word.data,10), str(word.size)])
table_str = tabulate.tabulate(data, headers=col_names, colalign=("center",), tablefmt="plain")
table_str = tabulate.tabulate(data, headers=col_names, tablefmt="plain")
with open(out_file, "w", encoding="UTF8", newline='') as f:
f.write(soclabs_header + "\n;")
......@@ -87,8 +89,6 @@ def stimulus_generation(in_file, start_address, size):
packet_list.append(temppacketstruct)
temppacketstruct = InputPacketStruct()
print(f"Number of Packets is: {len(packet_list)}")
# List of Ouptut Transactions
output_word_list = []
......@@ -102,7 +102,7 @@ def stimulus_generation(in_file, start_address, size):
# - Work Out Beginning Address = (end_address + 0x4) - Size
req_write_size = 0x40 * num_blocks
start_write_addr = start_address + size - req_write_size
print(f"Packet: {int(packet_num)} | Start Address: {hex(start_write_addr)}")
# print(f"Packet: {int(packet_num)} | Start Address: {hex(start_write_addr)}")
write_addr = start_write_addr
for block_num, block in enumerate(packet.block_list):
for word in block.word_list:
......@@ -110,20 +110,14 @@ def stimulus_generation(in_file, start_address, size):
output_word_list.append(word_data)
# Increment Address
write_addr += 0x4
# Test Print Out
prev_block_num = 0
for word in output_word_list:
if (word.packet_num > 0):
break
if (word.block_num != prev_block_num):
print("New Block")
print(f"{hex(word.addr)} {hex(word.data)} {word.trans}")
prev_block_num = word.block_num
# Generate FRI File with Write Transactions
out_file = os.environ["WRAP_ACC_DIR"] + "/simulate/stimulus/" + "ahb_input_hash_stim.fri"
fri_output(out_file, output_word_list)
fri_file = os.environ["WRAP_ACC_DIR"] + "/simulate/stimulus/" + "ahb_input_hash_stim.fri"
fri_output(fri_file, output_word_list)
# Call fm2conv.pl script
m2d_file = os.environ["WRAP_ACC_DIR"] + "/simulate/stimulus/" + "ahb_input_hash_stim.m2d"
os.system(f"fm2conv.pl -busWidth=32 -infile={fri_file} -outfile={m2d_file}")
if __name__ == "__main__":
......
This diff is collapsed.
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment