diff --git a/calyx-py/calyx/queue_data_gen.py b/calyx-py/calyx/queue_data_gen.py index 9d4012b455..f2ec45eb39 100644 --- a/calyx-py/calyx/queue_data_gen.py +++ b/calyx-py/calyx/queue_data_gen.py @@ -52,7 +52,14 @@ def no_err_cmds_list(queue_size, num_cmds): commands += (push_goal - total_pop_count) * [0] break - assert len(commands) == num_cmds + # If the total number of commands is not `num_cmds`, pad it with `peek`s. + # This is because the `commands` list must have `num_cmds` items. + commands += (num_cmds - len(commands)) * [1] + # The above command will add either zero or one `peek` command to the end. + + assert ( + len(commands) == num_cmds + ), f"Length of commands list was {len(commands)}, expected {num_cmds}" return commands @@ -110,6 +117,7 @@ def dump_json(num_cmds, use_rank: bool, no_err: bool, queue_size: Optional[int] else: print(json.dumps(commands | values | ans_mem, indent=2)) + if __name__ == "__main__": # Accept a flag that we pass to dump_json. # This says whether we should use the special no_err helper.