diff --git a/calyx-py/calyx/queue_data_gen.py b/calyx-py/calyx/queue_data_gen.py index d6fa9227cc..3dbdc9f638 100644 --- a/calyx-py/calyx/queue_data_gen.py +++ b/calyx-py/calyx/queue_data_gen.py @@ -1,5 +1,6 @@ import random import json +import sys from typing import Dict, Union from calyx import queue_util @@ -11,11 +12,12 @@ def format_gen(width: int) -> FormatType: return {"is_signed": False, "numeric_type": "bitnum", "width": width} -def dump_json(): +def dump_json(no_peeks: bool): """Prints a JSON representation of the data to stdout. The data itself is populated randomly, following certain rules: - It has three "memories": `commands`, `values`, and `ans_mem`. - The `commands` memory has queue_util.MAX_CMDS items, which are 0, 1, or 2. + If the `no_peeks` flag is set, then items are chosen randomly from 0 and 2. - The `values` memory has queue_util.MAX_CMDS items: random values between 0 and 400. - The `ans_mem` memory has queue_util.MAX_CMDS items, all zeroes. @@ -23,7 +25,10 @@ def dump_json(): """ commands = { "commands": { - "data": [random.randint(0, 2) for _ in range(queue_util.MAX_CMDS)], + "data": [ + random.choice([0, 2]) if no_peeks else random.randint(0, 2) + for _ in range(queue_util.MAX_CMDS) + ], "format": format_gen(2), } } @@ -47,5 +52,9 @@ def dump_json(): if __name__ == "__main__": + # Accept a flag that we pass to dump_json. + # This says whether we should have any 1s in the `commands` memory. + + no_peeks = len(sys.argv) > 1 and sys.argv[1] == "--no-peeks" random.seed(5) - dump_json() + dump_json(no_peeks) diff --git a/calyx-py/test/correctness/piezo_pifotree.data b/calyx-py/test/correctness/piezo_pifotree.data index 485b427245..a2f8b6cab5 100644 --- a/calyx-py/test/correctness/piezo_pifotree.data +++ b/calyx-py/test/correctness/piezo_pifotree.data @@ -2,105 +2,105 @@ "commands": { "data": [ 2, - 1, - 2, - 1, 2, + 0, 2, + 0, + 0, + 0, + 0, 2, 2, 0, - 1, - 0, 2, 0, 0, 0, - 1, - 1, 0, - 1, + 2, 2, 0, 2, 0, 0, + 0, 2, 0, - 1, - 1, 0, - 1, + 0, + 0, + 0, + 0, + 0, + 0, + 2, + 2, + 0, 0, 0, 0, 2, 2, - 1, 0, + 2, + 2, 0, 0, + 2, 0, + 2, + 2, 0, + 2, 0, + 2, + 2, + 2, + 2, + 2, 0, + 2, + 2, 0, - 1, - 1, 0, 2, + 0, 2, 2, 0, + 2, + 2, + 2, 0, 2, 0, - 1, - 1, 0, - 1, - 1, 0, 0, - 1, 0, - 1, - 1, 2, 2, - 0, 2, 2, 2, - 1, 0, - 1, - 1, - 1, - 1, 2, - 1, - 0, - 1, - 1, 2, 0, + 2, 0, - 1, 0, 2, - 1, - 1, + 2, 0, 2, - 1, - 1, - 1, 2, 0, - 1, + 2, + 2, + 2, 0, - 2 + 0 ], "format": { "is_signed": false, @@ -110,46 +110,6 @@ }, "values": { "data": [ - 92, - 319, - 100, - 60, - 386, - 125, - 236, - 176, - 262, - 181, - 268, - 128, - 397, - 236, - 55, - 301, - 383, - 399, - 188, - 151, - 18, - 221, - 46, - 106, - 174, - 262, - 312, - 185, - 75, - 174, - 141, - 359, - 279, - 47, - 159, - 351, - 162, - 156, - 90, - 40, 320, 76, 369, @@ -209,7 +169,47 @@ 240, 206, 75, - 57 + 57, + 193, + 272, + 91, + 321, + 255, + 173, + 92, + 45, + 251, + 139, + 263, + 400, + 280, + 257, + 184, + 32, + 396, + 182, + 355, + 300, + 339, + 17, + 388, + 156, + 186, + 286, + 360, + 342, + 143, + 248, + 135, + 394, + 353, + 366, + 150, + 174, + 332, + 91, + 297, + 5 ], "format": { "is_signed": false, diff --git a/calyx-py/test/correctness/piezo_pifotree.expect b/calyx-py/test/correctness/piezo_pifotree.expect index 876500088f..3cbecc4ce8 100644 --- a/calyx-py/test/correctness/piezo_pifotree.expect +++ b/calyx-py/test/correctness/piezo_pifotree.expect @@ -1,54 +1,54 @@ { "ans_mem": [ - 92, - 92, - 92, - 386, - 386, - 125, - 236, - 100, - 176, - 176, - 176, - 128, - 128, - 221, - 151, - 174, - 47, - 47, - 159, - 368, + 76, + 320, + 352, 24, - 207, - 41, - 41, + 273, 41, - 252, - 106, - 106, - 374, - 374, - 374, - 374, - 374, - 374, - 16, - 16, - 16, - 222, - 150, + 304, + 176, + 233, + 28, + 322, + 67, + 190, + 215, + 76, + 317, 150, 267, - 267, - 267, - 66, - 66, - 66, - 66, - 373, - 373, + 162, + 232, + 75, + 352, + 140, + 245, + 57, + 240, + 149, + 255, + 91, + 251, + 173, + 400, + 45, + 355, + 139, + 300, + 17, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, 0, 0, 0, @@ -103,147 +103,107 @@ ], "commands": [ 2, - 1, - 2, - 1, 2, + 0, 2, + 0, + 0, + 0, + 0, 2, 2, 0, - 1, - 0, 2, 0, 0, 0, - 1, - 1, 0, - 1, + 2, 2, 0, 2, 0, 0, + 0, 2, 0, - 1, - 1, 0, - 1, + 0, + 0, + 0, 0, 0, 0, 2, 2, - 1, 0, 0, 0, 0, + 2, + 2, + 0, + 2, + 2, 0, 0, + 2, + 0, + 2, + 2, + 0, + 2, + 0, + 2, + 2, + 2, + 2, + 2, 0, + 2, + 2, 0, - 1, - 1, 0, 2, + 0, 2, 2, 0, + 2, + 2, + 2, 0, 2, 0, - 1, - 1, 0, - 1, - 1, 0, 0, - 1, 0, - 1, - 1, 2, 2, - 0, 2, 2, 2, - 1, 0, - 1, - 1, - 1, - 1, 2, - 1, - 0, - 1, - 1, 2, 0, + 2, 0, - 1, 0, 2, - 1, - 1, + 2, 0, 2, - 1, - 1, - 1, 2, 0, - 1, + 2, + 2, + 2, 0, - 2 + 0 ], "values": [ - 92, - 319, - 100, - 60, - 386, - 125, - 236, - 176, - 262, - 181, - 268, - 128, - 397, - 236, - 55, - 301, - 383, - 399, - 188, - 151, - 18, - 221, - 46, - 106, - 174, - 262, - 312, - 185, - 75, - 174, - 141, - 359, - 279, - 47, - 159, - 351, - 162, - 156, - 90, - 40, 320, 76, 369, @@ -303,6 +263,46 @@ 240, 206, 75, - 57 + 57, + 193, + 272, + 91, + 321, + 255, + 173, + 92, + 45, + 251, + 139, + 263, + 400, + 280, + 257, + 184, + 32, + 396, + 182, + 355, + 300, + 339, + 17, + 388, + 156, + 186, + 286, + 360, + 342, + 143, + 248, + 135, + 394, + 353, + 366, + 150, + 174, + 332, + 91, + 297, + 5 ] }