diff --git a/flow/stimgen.py b/flow/stimgen.py index 93b22c878770ce29dee20d08d612c72c3a1e24c4..9a5d62ded97d926be3ee56d04431aef025ce68d5 100644 --- a/flow/stimgen.py +++ b/flow/stimgen.py @@ -17,22 +17,20 @@ class TransactionType(Enum): READ = 1 WRITE = 2 def __str__(self): - match self: - case TransactionType.READ: - return "R" - case TransactionType.WRITE: - return "W" + if (self == TransactionType.READ): + return "R" + elif (self == TransactionType.WRITE): + return "W" class TransactionSize(Enum): """ Enumerated Types for Transaction Types for ASCII Debug """ WORD = 1 HALFWORD = 2 def __str__(self): - match self: - case TransactionSize.WORD: - return "word" - case TransactionSize.HALFWORD: - return "halfword" + if (self == TransactionSize.WORD): + return "word" + elif (self == TransactionSize.HALFWORD): + return "halfword" class InputBlockStruct: def __init__(self): @@ -57,6 +55,28 @@ class WordStruct: self.block_num = block_num self.size = size +def adp_output(out_file, word_list): + """ + This function takes a list of 32 bit words and addresses and formats + the data into .cmd format for the ADP module + testbench + """ + + data = [] + for word in word_list: + if (word.data > 0): + data.append(["a", "{0:#0{1}x}".format(word.addr,10)]) + data.append([str(word.trans).lower(), "{0:#0{1}x}".format(word.data,10)]) + + table_str = tabulate.tabulate(data, headers=col_names, tablefmt="plain") + + with open(out_file, "w", encoding="UTF8", newline='') as f: + f.write("A") + f.write(table_str) + f.write(" A") + f.write("X") + f.write("!") + def fri_output(out_file, word_list): """ This function takes a list of 32 bit words and addresses and formats @@ -167,6 +187,10 @@ def stimulus_generation(stim_file, ref_file, input_start_address, input_size, ou read_addr += 0x4 + # Generate ADP Command File with Write Transactions + adp_file = os.environ["WRAP_ACC_DIR"] + "/simulate/stimulus/" + "adp_hash_stim.cmd" + adp_output(adp_file, output_word_list) + # Generate FRI File with Write Transactions fri_file = os.environ["WRAP_ACC_DIR"] + "/simulate/stimulus/" + "ahb_input_hash_stim.fri" fri_output(fri_file, output_word_list)