diff --git a/calyx-py/calyx/fifo_oracle.py b/calyx-py/calyx/fifo_oracle.py index 8cc4104f58..68f9905807 100644 --- a/calyx-py/calyx/fifo_oracle.py +++ b/calyx-py/calyx/fifo_oracle.py @@ -1,8 +1,8 @@ -import queues - +import calyx.queues as queues +import calyx.queue_util as queue_util if __name__ == "__main__": - commands, values = queues.parse_json() - pifo = queues.Fifo([]) - ans = queues.operate_queue(commands, values, pifo) - queues.dump_json(commands, values, ans) + commands, values = queue_util.parse_json() + fifo = queues.Fifo([]) + ans = queues.operate_queue(commands, values, fifo) + queue_util.dump_json(commands, values, ans) diff --git a/calyx-py/calyx/pifo_oracle.py b/calyx-py/calyx/pifo_oracle.py index 55d7a81bc6..f454a75407 100644 --- a/calyx-py/calyx/pifo_oracle.py +++ b/calyx-py/calyx/pifo_oracle.py @@ -1,11 +1,11 @@ -import queues - +import calyx.queues as queues +import calyx.queue_util as queue_util if __name__ == "__main__": - commands, values = queues.parse_json() + commands, values = queue_util.parse_json() # Our PIFO is simple: it just orchestrates two FIFOs. The boundary is 200. pifo = queues.Pifo(queues.Fifo([]), queues.Fifo([]), 200) ans = queues.operate_queue(commands, values, pifo) - queues.dump_json(commands, values, ans) + queue_util.dump_json(commands, values, ans) diff --git a/calyx-py/calyx/pifotree_oracle.py b/calyx-py/calyx/pifotree_oracle.py index 9f83b83fca..9ca1f2c350 100644 --- a/calyx-py/calyx/pifotree_oracle.py +++ b/calyx-py/calyx/pifotree_oracle.py @@ -1,8 +1,9 @@ -import queues +import calyx.queues as queues +import calyx.queue_util as queue_util if __name__ == "__main__": - commands, values = queues.parse_json() + commands, values = queue_util.parse_json() # Our PIFO is a little complicated: it is a tree of queues. # The root has two children, which are PIFOs. @@ -19,4 +20,5 @@ ) ans = queues.operate_queue(commands, values, pifo) - queues.dump_json(commands, values, ans) + queue_util.dump_json(commands, values, ans) + diff --git a/calyx-py/calyx/queue_call.py b/calyx-py/calyx/queue_call.py index e8e0ad1cc9..e66b50fc73 100644 --- a/calyx-py/calyx/queue_call.py +++ b/calyx-py/calyx/queue_call.py @@ -1,9 +1,7 @@ # pylint: disable=import-error +import calyx.queue_util as queue_util import calyx.builder as cb -MAX_CMDS = 15 -ANS_MEM_LEN = 10 - def insert_main(prog, queue): """Inserts the component `main` into the program. @@ -33,9 +31,9 @@ def insert_main(prog, queue): # - one ref register, `ans`, into which the result of a pop or peek is written. # - one ref register, `err`, which is raised if an error occurs. - commands = main.seq_mem_d1("commands", 2, MAX_CMDS, 32, is_external=True) - values = main.seq_mem_d1("values", 32, MAX_CMDS, 32, is_external=True) - ans_mem = main.seq_mem_d1("ans_mem", 32, 10, 32, is_external=True) + commands = main.seq_mem_d1("commands", 2, queue_util.MAX_CMDS, 32, is_external=True) + values = main.seq_mem_d1("values", 32, queue_util.MAX_CMDS, 32, is_external=True) + ans_mem = main.seq_mem_d1("ans_mem", 32, queue_util.MAX_CMDS, 32, is_external=True) # The two components we'll use: queue = main.cell("myqueue", queue) @@ -79,10 +77,10 @@ def insert_main(prog, queue): loop_goes_on # Does the `err` flag say that the loop should continue? ) - update_i_neq_15, _ = main.neq_store_in_reg( + update_i_neq_max_cmds, _ = main.neq_store_in_reg( i.out, - cb.const(32, 15), - "i_neq_15", + cb.const(32, queue_util.MAX_CMDS), + "i_neq_max_cmds", 32, loop_goes_on # Does the `i` index say that the loop should continue? @@ -116,7 +114,8 @@ def insert_main(prog, queue): ], ), incr_i, # Increment the command index - update_i_neq_15, # Did this increment make us need to break? + update_i_neq_max_cmds, + # Did this increment make us need to break? ], ), ], diff --git a/calyx-py/calyx/queue_data_gen.py b/calyx-py/calyx/queue_data_gen.py index 13f5cf211b..327f2d86db 100644 --- a/calyx-py/calyx/queue_data_gen.py +++ b/calyx-py/calyx/queue_data_gen.py @@ -1,9 +1,7 @@ import random import json from typing import Dict, Union - -MAX_CMDS = 15 -ANS_MEM_LEN = 10 +import calyx.queue_util as queue_util FormatType = Dict[str, Union[bool, str, int]] @@ -17,29 +15,34 @@ def dump_json(): """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 MAX_CMDS items, which are 0, 1, or 2. - - The `values` memory has MAX_CMDS items: random values between 0 and 400. - - The `ans_mem` memory has ANS_MEM_LEN items, all zeroes. + - The `commands` memory has queue_util.MAX_CMDS items, which are 0, 1, or 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. - Each memory has a `format` field, which is a format object for a bitvector. """ commands = { "commands": { - "data": [random.randint(0, 2) for _ in range(MAX_CMDS)], - # The `commands` memory has MAX_CMDS items, which are 0, 1, or 2. + # We'll "rig" these random values a little. + # The first 5% of the commands will be 2 (push). + # The rest will be generated randomly from among 0, 1, and 2. + "data": [2] * (queue_util.MAX_CMDS // 20) + + [random.randint(0, 2) for _ in range(queue_util.MAX_CMDS * 19 // 20)], "format": format_gen(2), } } values = { "values": { - "data": [random.randint(0, 400) for _ in range(MAX_CMDS)], - # The `values` memory has MAX_CMDS items: random values between 0 and 00. + "data": [random.randint(0, 400) for _ in range(queue_util.MAX_CMDS)], + # The `values` memory has queue_util.MAX_CMDS items: random values + # between 0 and 400. "format": format_gen(32), } } ans_mem = { "ans_mem": { - "data": [0 for _ in range(ANS_MEM_LEN)], - # The `ans_mem` memory has ANS_MEM_LEN items, all zeroes. + "data": [0 for _ in range(queue_util.MAX_CMDS)], + # The `ans_mem` memory has queue_util.MAX_CMDS items, all zeroes. "format": format_gen(32), } } diff --git a/calyx-py/calyx/queue_util.py b/calyx-py/calyx/queue_util.py new file mode 100644 index 0000000000..e04380a0b0 --- /dev/null +++ b/calyx-py/calyx/queue_util.py @@ -0,0 +1,29 @@ +import json +import sys + +MAX_CMDS = 100 +QUEUE_SIZE = 10 + + +def parse_json(): + """Effectively the opposite of `data_gen`: + Given a JSON file formatted for Calyx purposes, parse it into its two lists: + - The `commands` memory, which has MAX_CMDS items. + - The `values` memory, which has MAX_CMDS items. + Returns the two lists. + """ + + data = json.load(sys.stdin) + commands = data["commands"]["data"] + values = data["values"]["data"] + return commands, values + + +def dump_json(commands, values, ans_mem): + """Prints a JSON representation of the data to stdout.""" + payload = { + "ans_mem": ans_mem, + "commands": commands, + "values": values, + } + print(json.dumps(payload, indent=2)) diff --git a/calyx-py/calyx/queues.py b/calyx-py/calyx/queues.py index c9c493b9e6..77f2982efc 100644 --- a/calyx-py/calyx/queues.py +++ b/calyx-py/calyx/queues.py @@ -1,23 +1,26 @@ -import sys -import json from dataclasses import dataclass from typing import List - -ANS_MEM_LEN = 10 +import calyx.queue_util as queue_util @dataclass class Fifo: """A FIFO data structure. Supports the operations `push`, `pop`, and `peek`. + Inherent to the queue is its `max_len`, which is given to us at initialization + and we cannot exceed. """ - def __init__(self, data: List[int]): + def __init__(self, data: List[int], max_len: int = None): self.data = data + self.max_len = max_len or queue_util.QUEUE_SIZE def push(self, val: int): """Pushes `val` to the FIFO.""" - self.data.append(val) + if len(self.data) < self.max_len: + self.data.append(val) + else: + raise IndexError("Cannot push to full FIFO.") def pop(self) -> int: """Pops the FIFO.""" @@ -49,6 +52,10 @@ class Pifo: We maintain internally a variable called `pifo_len`: the sum of the lengths of the two queues. + Inherent to the queue is its `max_len`, which is given to us at initialization + and we cannot exceed. + + When asked to pop: - If `pifo_len` is 0, we raise an error. - Else, if `hot` is 0, we try to pop from queue_0. @@ -64,19 +71,26 @@ class Pifo: - We don't flip `hot`. When asked to push: + - If the PIFO is at length `max_len`, we raise an error. - If the value to be pushed is less than `boundary`, we push it into queue_1. - Else, we push it into queue_2. - We increment `pifo_len` by 1. """ - def __init__(self, queue_1, queue_2, boundary): + def __init__(self, queue_1, queue_2, boundary, max_len=None): self.data = (queue_1, queue_2) self.hot = 0 self.pifo_len = len(queue_1) + len(queue_2) self.boundary = boundary + self.max_len = max_len or queue_util.QUEUE_SIZE + assert ( + self.pifo_len <= self.max_len + ) # We can't be initialized with a PIFO that is too long. def push(self, val: int): """Pushes `val` to the PIFO.""" + if self.pifo_len == self.max_len: + raise IndexError("Cannot push to full PIFO.") if val < self.boundary: self.data[0].push(val) else: @@ -120,30 +134,6 @@ def __len__(self) -> int: return self.pifo_len -def parse_json(): - """Effectively the opposite of `data_gen`: - Given a JSON file formatted for Calyx purposes, parse it into its two lists: - - The `commands` memory, which has MAX_CMDS items. - - The `values` memory, which has MAX_CMDS items. - Returns the two lists. - """ - - data = json.load(sys.stdin) - commands = data["commands"]["data"] - values = data["values"]["data"] - return commands, values - - -def dump_json(commands, values, ans_mem): - """Prints a JSON representation of the data to stdout.""" - payload = { - "ans_mem": ans_mem, - "commands": commands, - "values": values, - } - print(json.dumps(payload, indent=2)) - - def operate_queue(commands, values, queue): """Given the two lists, one of commands and one of values. Feed these into our queue, and return the answer memory. @@ -164,8 +154,11 @@ def operate_queue(commands, values, queue): break elif cmd == 2: - queue.push(val) + try: + queue.push(val) + except IndexError: + break - # Pad the answer memory with zeroes until it is of length ANS_MEM_LEN. - ans += [0] * (ANS_MEM_LEN - len(ans)) + # Pad the answer memory with zeroes until it is of length MAX_CMDS. + ans += [0] * (queue_util.MAX_CMDS - len(ans)) return ans diff --git a/calyx-py/test/correctness/fifo.data b/calyx-py/test/correctness/fifo.data index 5f72a3db88..7d0d68fb24 100644 --- a/calyx-py/test/correctness/fifo.data +++ b/calyx-py/test/correctness/fifo.data @@ -1,6 +1,11 @@ { "commands": { "data": [ + 2, + 2, + 2, + 2, + 2, 2, 1, 2, @@ -15,7 +20,87 @@ 2, 0, 0, - 0 + 0, + 1, + 1, + 0, + 1, + 2, + 0, + 2, + 0, + 0, + 2, + 0, + 1, + 1, + 0, + 1, + 0, + 0, + 0, + 2, + 2, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 0, + 2, + 2, + 2, + 0, + 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, + 0, + 1, + 0, + 2, + 1, + 1, + 0, + 2, + 1, + 1, + 1 ], "format": { "is_signed": false, @@ -25,21 +110,106 @@ }, "values": { "data": [ - 190, - 240, - 126, - 194, - 278, - 52, - 293, - 127, - 6, + 296, + 4, + 231, + 23, + 362, + 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, + 352, + 158, + 247, + 82, + 368, + 24, + 41, + 307, + 273, + 207, + 16, + 121, + 379, + 304, + 176, + 128, + 233, + 333, + 215, + 74, + 28, + 326, + 16, + 252, + 171, + 106, + 66, 374, - 110, - 208, - 143, - 93, - 392 + 288, + 67, + 322, + 211, + 54, + 86, + 222, + 190, + 76, + 30, + 215, + 150, + 72, + 232, + 317, + 86, + 267, + 232, + 249, + 352, + 373, + 162, + 245, + 140 ], "format": { "is_signed": false, @@ -49,6 +219,96 @@ }, "ans_mem": { "data": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, 0, 0, 0, diff --git a/calyx-py/test/correctness/fifo.expect b/calyx-py/test/correctness/fifo.expect index d55133390a..63c85e68a1 100644 --- a/calyx-py/test/correctness/fifo.expect +++ b/calyx-py/test/correctness/fifo.expect @@ -1,17 +1,112 @@ { "ans_mem": [ - 190, - 190, - 190, - 126, - 126, - 278, - 52, - 293, + 296, + 296, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, 0, 0 ], "commands": [ + 2, + 2, + 2, + 2, + 2, 2, 1, 2, @@ -26,23 +121,188 @@ 2, 0, 0, - 0 + 0, + 1, + 1, + 0, + 1, + 2, + 0, + 2, + 0, + 0, + 2, + 0, + 1, + 1, + 0, + 1, + 0, + 0, + 0, + 2, + 2, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 0, + 2, + 2, + 2, + 0, + 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, + 0, + 1, + 0, + 2, + 1, + 1, + 0, + 2, + 1, + 1, + 1 ], "values": [ - 190, - 240, - 126, - 194, - 278, - 52, - 293, - 127, - 6, + 296, + 4, + 231, + 23, + 362, + 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, + 352, + 158, + 247, + 82, + 368, + 24, + 41, + 307, + 273, + 207, + 16, + 121, + 379, + 304, + 176, + 128, + 233, + 333, + 215, + 74, + 28, + 326, + 16, + 252, + 171, + 106, + 66, 374, - 110, - 208, - 143, - 93, - 392 + 288, + 67, + 322, + 211, + 54, + 86, + 222, + 190, + 76, + 30, + 215, + 150, + 72, + 232, + 317, + 86, + 267, + 232, + 249, + 352, + 373, + 162, + 245, + 140 ] } diff --git a/calyx-py/test/correctness/piezo_pifotree.yx b/calyx-py/test/correctness/piezo_pifotree.yx new file mode 100644 index 0000000000..c0357fc521 --- /dev/null +++ b/calyx-py/test/correctness/piezo_pifotree.yx @@ -0,0 +1,1197 @@ +import "primitives/core.futil"; +import "primitives/binary_operators.futil"; +import "primitives/memories.futil"; +component stats(flow: 1) -> (count_0: 32, count_1: 32) { + cells { + count_0_sto = std_reg(32); + count_1_sto = std_reg(32); + count_0_sto_incr = std_add(32); + count_1_sto_incr = std_add(32); + eq_1 = std_eq(1); + eq_2 = std_eq(1); + } + wires { + group count_0_sto_incr_group { + count_0_sto_incr.left = count_0_sto.out; + count_0_sto_incr.right = 32'd1; + count_0_sto.write_en = 1'd1; + count_0_sto.in = count_0_sto_incr.out; + count_0_sto_incr_group[done] = count_0_sto.done; + } + group count_1_sto_incr_group { + count_1_sto_incr.left = count_1_sto.out; + count_1_sto_incr.right = 32'd1; + count_1_sto.write_en = 1'd1; + count_1_sto.in = count_1_sto_incr.out; + count_1_sto_incr_group[done] = count_1_sto.done; + } + comb group eq_1_group { + eq_1.left = flow; + eq_1.right = 1'd0; + } + comb group eq_2_group { + eq_2.left = flow; + eq_2.right = 1'd1; + } + count_0 = count_0_sto.out; + count_1 = count_1_sto.out; + } + control { + seq { + par { + if eq_1.out with eq_1_group { + seq { + count_0_sto_incr_group; + } + } + if eq_2.out with eq_2_group { + seq { + count_1_sto_incr_group; + } + } + } + } + } +} +component fifo_purple(cmd: 2, value: 32) -> () { + cells { + mem = seq_mem_d1(32, 10, 32); + next_write = std_reg(32); + next_read = std_reg(32); + ref ans = std_reg(32); + ref err = std_reg(1); + len = std_reg(32); + eq_1 = std_eq(2); + eq_2 = std_eq(2); + eq_3 = std_eq(2); + eq_4 = std_eq(32); + eq_5 = std_eq(32); + eq_6 = std_eq(32); + eq_7 = std_eq(32); + next_write_incr = std_add(32); + next_read_incr = std_add(32); + len_incr = std_add(32); + len_decr = std_sub(32); + } + wires { + comb group eq_1_group { + eq_1.left = cmd; + eq_1.right = 2'd0; + } + comb group eq_2_group { + eq_2.left = cmd; + eq_2.right = 2'd1; + } + comb group eq_3_group { + eq_3.left = cmd; + eq_3.right = 2'd2; + } + comb group eq_4_group { + eq_4.left = next_write.out; + eq_4.right = 32'd10; + } + comb group eq_5_group { + eq_5.left = next_read.out; + eq_5.right = 32'd10; + } + comb group eq_6_group { + eq_6.left = len.out; + eq_6.right = 32'd0; + } + comb group eq_7_group { + eq_7.left = len.out; + eq_7.right = 32'd10; + } + group next_write_incr_group { + next_write_incr.left = next_write.out; + next_write_incr.right = 32'd1; + next_write.write_en = 1'd1; + next_write.in = next_write_incr.out; + next_write_incr_group[done] = next_write.done; + } + group next_read_incr_group { + next_read_incr.left = next_read.out; + next_read_incr.right = 32'd1; + next_read.write_en = 1'd1; + next_read.in = next_read_incr.out; + next_read_incr_group[done] = next_read.done; + } + group len_incr_group { + len_incr.left = len.out; + len_incr.right = 32'd1; + len.write_en = 1'd1; + len.in = len_incr.out; + len_incr_group[done] = len.done; + } + group len_decr_group { + len_decr.left = len.out; + len_decr.right = 32'd1; + len.write_en = 1'd1; + len.in = len_decr.out; + len_decr_group[done] = len.done; + } + group flash_write { + next_write.in = 32'd0; + next_write.write_en = 1'd1; + flash_write[done] = next_write.done; + } + group flash_read { + next_read.in = 32'd0; + next_read.write_en = 1'd1; + flash_read[done] = next_read.done; + } + group raise_err { + err.in = 1'd1; + err.write_en = 1'd1; + raise_err[done] = err.done; + } + group flash_ans { + ans.in = 32'd0; + ans.write_en = 1'd1; + flash_ans[done] = ans.done; + } + group write_payload_to_mem { + mem.addr0 = next_write.out; + mem.write_en = 1'd1; + mem.write_data = value; + write_payload_to_mem[done] = mem.write_done; + } + group read_payload_from_mem_phase1 { + mem.addr0 = next_read.out; + mem.read_en = 1'd1; + read_payload_from_mem_phase1[done] = mem.read_done; + } + group read_payload_from_mem_phase2 { + ans.write_en = 1'd1; + ans.in = mem.read_data; + read_payload_from_mem_phase2[done] = ans.done; + } + } + control { + seq { + par { + if eq_1.out with eq_1_group { + if eq_6.out with eq_6_group { + seq { + raise_err; + flash_ans; + } + } else { + seq { + read_payload_from_mem_phase1; + read_payload_from_mem_phase2; + next_read_incr_group; + if eq_5.out with eq_5_group { + flash_read; + } + len_decr_group; + } + } + } + if eq_2.out with eq_2_group { + if eq_6.out with eq_6_group { + seq { + raise_err; + flash_ans; + } + } else { + seq { + read_payload_from_mem_phase1; + read_payload_from_mem_phase2; + } + } + } + if eq_3.out with eq_3_group { + if eq_7.out with eq_7_group { + seq { + raise_err; + flash_ans; + } + } else { + seq { + write_payload_to_mem; + next_write_incr_group; + if eq_4.out with eq_4_group { + flash_write; + } + len_incr_group; + } + } + } + } + } + } +} +component fifo_tangerine(cmd: 2, value: 32) -> () { + cells { + mem = seq_mem_d1(32, 10, 32); + next_write = std_reg(32); + next_read = std_reg(32); + ref ans = std_reg(32); + ref err = std_reg(1); + len = std_reg(32); + eq_1 = std_eq(2); + eq_2 = std_eq(2); + eq_3 = std_eq(2); + eq_4 = std_eq(32); + eq_5 = std_eq(32); + eq_6 = std_eq(32); + eq_7 = std_eq(32); + next_write_incr = std_add(32); + next_read_incr = std_add(32); + len_incr = std_add(32); + len_decr = std_sub(32); + } + wires { + comb group eq_1_group { + eq_1.left = cmd; + eq_1.right = 2'd0; + } + comb group eq_2_group { + eq_2.left = cmd; + eq_2.right = 2'd1; + } + comb group eq_3_group { + eq_3.left = cmd; + eq_3.right = 2'd2; + } + comb group eq_4_group { + eq_4.left = next_write.out; + eq_4.right = 32'd10; + } + comb group eq_5_group { + eq_5.left = next_read.out; + eq_5.right = 32'd10; + } + comb group eq_6_group { + eq_6.left = len.out; + eq_6.right = 32'd0; + } + comb group eq_7_group { + eq_7.left = len.out; + eq_7.right = 32'd10; + } + group next_write_incr_group { + next_write_incr.left = next_write.out; + next_write_incr.right = 32'd1; + next_write.write_en = 1'd1; + next_write.in = next_write_incr.out; + next_write_incr_group[done] = next_write.done; + } + group next_read_incr_group { + next_read_incr.left = next_read.out; + next_read_incr.right = 32'd1; + next_read.write_en = 1'd1; + next_read.in = next_read_incr.out; + next_read_incr_group[done] = next_read.done; + } + group len_incr_group { + len_incr.left = len.out; + len_incr.right = 32'd1; + len.write_en = 1'd1; + len.in = len_incr.out; + len_incr_group[done] = len.done; + } + group len_decr_group { + len_decr.left = len.out; + len_decr.right = 32'd1; + len.write_en = 1'd1; + len.in = len_decr.out; + len_decr_group[done] = len.done; + } + group flash_write { + next_write.in = 32'd0; + next_write.write_en = 1'd1; + flash_write[done] = next_write.done; + } + group flash_read { + next_read.in = 32'd0; + next_read.write_en = 1'd1; + flash_read[done] = next_read.done; + } + group raise_err { + err.in = 1'd1; + err.write_en = 1'd1; + raise_err[done] = err.done; + } + group flash_ans { + ans.in = 32'd0; + ans.write_en = 1'd1; + flash_ans[done] = ans.done; + } + group write_payload_to_mem { + mem.addr0 = next_write.out; + mem.write_en = 1'd1; + mem.write_data = value; + write_payload_to_mem[done] = mem.write_done; + } + group read_payload_from_mem_phase1 { + mem.addr0 = next_read.out; + mem.read_en = 1'd1; + read_payload_from_mem_phase1[done] = mem.read_done; + } + group read_payload_from_mem_phase2 { + ans.write_en = 1'd1; + ans.in = mem.read_data; + read_payload_from_mem_phase2[done] = ans.done; + } + } + control { + seq { + par { + if eq_1.out with eq_1_group { + if eq_6.out with eq_6_group { + seq { + raise_err; + flash_ans; + } + } else { + seq { + read_payload_from_mem_phase1; + read_payload_from_mem_phase2; + next_read_incr_group; + if eq_5.out with eq_5_group { + flash_read; + } + len_decr_group; + } + } + } + if eq_2.out with eq_2_group { + if eq_6.out with eq_6_group { + seq { + raise_err; + flash_ans; + } + } else { + seq { + read_payload_from_mem_phase1; + read_payload_from_mem_phase2; + } + } + } + if eq_3.out with eq_3_group { + if eq_7.out with eq_7_group { + seq { + raise_err; + flash_ans; + } + } else { + seq { + write_payload_to_mem; + next_write_incr_group; + if eq_4.out with eq_4_group { + flash_write; + } + len_incr_group; + } + } + } + } + } + } +} +component pifo_red(cmd: 2, value: 32) -> () { + cells { + queue_l = fifo_purple(); + queue_r = fifo_tangerine(); + flow = std_reg(1); + lt_1 = std_lt(32); + ref ans = std_reg(32); + ref err = std_reg(1); + len = std_reg(32); + hot = std_reg(1); + eq_2 = std_eq(1); + eq_3 = std_eq(1); + eq_4 = std_eq(1); + eq_5 = std_eq(1); + eq_6 = std_eq(32); + eq_7 = std_eq(32); + eq_8 = std_eq(2); + eq_9 = std_eq(2); + eq_10 = std_eq(2); + eq_11 = std_eq(1); + neq_12 = std_neq(1); + hot_not = std_not(1); + len_incr = std_add(32); + len_decr = std_sub(32); + } + wires { + group infer_flow { + lt_1.left = 32'd100; + lt_1.right = value; + flow.write_en = 1'd1; + flow.in = lt_1.out; + infer_flow[done] = flow.done; + } + comb group eq_2_group { + eq_2.left = hot.out; + eq_2.right = 1'd0; + } + comb group eq_3_group { + eq_3.left = hot.out; + eq_3.right = 1'd1; + } + comb group eq_4_group { + eq_4.left = flow.out; + eq_4.right = 1'd0; + } + comb group eq_5_group { + eq_5.left = flow.out; + eq_5.right = 1'd1; + } + comb group eq_6_group { + eq_6.left = len.out; + eq_6.right = 32'd0; + } + comb group eq_7_group { + eq_7.left = len.out; + eq_7.right = 32'd10; + } + comb group eq_8_group { + eq_8.left = cmd; + eq_8.right = 2'd0; + } + comb group eq_9_group { + eq_9.left = cmd; + eq_9.right = 2'd1; + } + comb group eq_10_group { + eq_10.left = cmd; + eq_10.right = 2'd2; + } + comb group eq_11_group { + eq_11.left = err.out; + eq_11.right = 1'd0; + } + comb group neq_12_group { + neq_12.left = err.out; + neq_12.right = 1'd0; + } + group hot_not_group { + hot_not.in = hot.out; + hot.write_en = 1'd1; + hot.in = hot_not.out; + hot_not_group[done] = hot.done; + } + group raise_err { + err.in = 1'd1; + err.write_en = 1'd1; + raise_err[done] = err.done; + } + group lower_err { + err.in = 1'd0; + err.write_en = 1'd1; + lower_err[done] = err.done; + } + group flash_ans { + ans.in = 32'd0; + ans.write_en = 1'd1; + flash_ans[done] = ans.done; + } + group len_incr_group { + len_incr.left = len.out; + len_incr.right = 32'd1; + len.write_en = 1'd1; + len.in = len_incr.out; + len_incr_group[done] = len.done; + } + group len_decr_group { + len_decr.left = len.out; + len_decr.right = 32'd1; + len.write_en = 1'd1; + len.in = len_decr.out; + len_decr_group[done] = len.done; + } + } + control { + seq { + par { + if eq_8.out with eq_8_group { + if eq_6.out with eq_6_group { + seq { + raise_err; + flash_ans; + } + } else { + seq { + lower_err; + par { + if eq_2.out with eq_2_group { + seq { + invoke queue_l[ans=ans, err=err](cmd=cmd, value=value)(); + par { + if neq_12.out with neq_12_group { + seq { + lower_err; + invoke queue_r[ans=ans, err=err](cmd=cmd, value=value)(); + } + } + if eq_11.out with eq_11_group { + seq { + hot_not_group; + } + } + } + } + } + if eq_3.out with eq_3_group { + seq { + invoke queue_r[ans=ans, err=err](cmd=cmd, value=value)(); + par { + if neq_12.out with neq_12_group { + seq { + lower_err; + invoke queue_l[ans=ans, err=err](cmd=cmd, value=value)(); + } + } + if eq_11.out with eq_11_group { + seq { + hot_not_group; + } + } + } + } + } + } + len_decr_group; + } + } + } + if eq_9.out with eq_9_group { + if eq_6.out with eq_6_group { + seq { + raise_err; + flash_ans; + } + } else { + seq { + lower_err; + par { + if eq_2.out with eq_2_group { + seq { + invoke queue_l[ans=ans, err=err](cmd=cmd, value=value)(); + if neq_12.out with neq_12_group { + seq { + lower_err; + invoke queue_r[ans=ans, err=err](cmd=cmd, value=value)(); + } + } + } + } + if eq_3.out with eq_3_group { + seq { + invoke queue_r[ans=ans, err=err](cmd=cmd, value=value)(); + if neq_12.out with neq_12_group { + seq { + lower_err; + invoke queue_l[ans=ans, err=err](cmd=cmd, value=value)(); + } + } + } + } + } + } + } + } + if eq_10.out with eq_10_group { + if eq_7.out with eq_7_group { + seq { + raise_err; + flash_ans; + } + } else { + seq { + lower_err; + infer_flow; + par { + if eq_4.out with eq_4_group { + invoke queue_l[ans=ans, err=err](cmd=cmd, value=value)(); + } + if eq_5.out with eq_5_group { + invoke queue_r[ans=ans, err=err](cmd=cmd, value=value)(); + } + } + if eq_11.out with eq_11_group { + seq { + len_incr_group; + } + } + } + } + } + } + } + } +} +component fifo_blue(cmd: 2, value: 32) -> () { + cells { + mem = seq_mem_d1(32, 10, 32); + next_write = std_reg(32); + next_read = std_reg(32); + ref ans = std_reg(32); + ref err = std_reg(1); + len = std_reg(32); + eq_1 = std_eq(2); + eq_2 = std_eq(2); + eq_3 = std_eq(2); + eq_4 = std_eq(32); + eq_5 = std_eq(32); + eq_6 = std_eq(32); + eq_7 = std_eq(32); + next_write_incr = std_add(32); + next_read_incr = std_add(32); + len_incr = std_add(32); + len_decr = std_sub(32); + } + wires { + comb group eq_1_group { + eq_1.left = cmd; + eq_1.right = 2'd0; + } + comb group eq_2_group { + eq_2.left = cmd; + eq_2.right = 2'd1; + } + comb group eq_3_group { + eq_3.left = cmd; + eq_3.right = 2'd2; + } + comb group eq_4_group { + eq_4.left = next_write.out; + eq_4.right = 32'd10; + } + comb group eq_5_group { + eq_5.left = next_read.out; + eq_5.right = 32'd10; + } + comb group eq_6_group { + eq_6.left = len.out; + eq_6.right = 32'd0; + } + comb group eq_7_group { + eq_7.left = len.out; + eq_7.right = 32'd10; + } + group next_write_incr_group { + next_write_incr.left = next_write.out; + next_write_incr.right = 32'd1; + next_write.write_en = 1'd1; + next_write.in = next_write_incr.out; + next_write_incr_group[done] = next_write.done; + } + group next_read_incr_group { + next_read_incr.left = next_read.out; + next_read_incr.right = 32'd1; + next_read.write_en = 1'd1; + next_read.in = next_read_incr.out; + next_read_incr_group[done] = next_read.done; + } + group len_incr_group { + len_incr.left = len.out; + len_incr.right = 32'd1; + len.write_en = 1'd1; + len.in = len_incr.out; + len_incr_group[done] = len.done; + } + group len_decr_group { + len_decr.left = len.out; + len_decr.right = 32'd1; + len.write_en = 1'd1; + len.in = len_decr.out; + len_decr_group[done] = len.done; + } + group flash_write { + next_write.in = 32'd0; + next_write.write_en = 1'd1; + flash_write[done] = next_write.done; + } + group flash_read { + next_read.in = 32'd0; + next_read.write_en = 1'd1; + flash_read[done] = next_read.done; + } + group raise_err { + err.in = 1'd1; + err.write_en = 1'd1; + raise_err[done] = err.done; + } + group flash_ans { + ans.in = 32'd0; + ans.write_en = 1'd1; + flash_ans[done] = ans.done; + } + group write_payload_to_mem { + mem.addr0 = next_write.out; + mem.write_en = 1'd1; + mem.write_data = value; + write_payload_to_mem[done] = mem.write_done; + } + group read_payload_from_mem_phase1 { + mem.addr0 = next_read.out; + mem.read_en = 1'd1; + read_payload_from_mem_phase1[done] = mem.read_done; + } + group read_payload_from_mem_phase2 { + ans.write_en = 1'd1; + ans.in = mem.read_data; + read_payload_from_mem_phase2[done] = ans.done; + } + } + control { + seq { + par { + if eq_1.out with eq_1_group { + if eq_6.out with eq_6_group { + seq { + raise_err; + flash_ans; + } + } else { + seq { + read_payload_from_mem_phase1; + read_payload_from_mem_phase2; + next_read_incr_group; + if eq_5.out with eq_5_group { + flash_read; + } + len_decr_group; + } + } + } + if eq_2.out with eq_2_group { + if eq_6.out with eq_6_group { + seq { + raise_err; + flash_ans; + } + } else { + seq { + read_payload_from_mem_phase1; + read_payload_from_mem_phase2; + } + } + } + if eq_3.out with eq_3_group { + if eq_7.out with eq_7_group { + seq { + raise_err; + flash_ans; + } + } else { + seq { + write_payload_to_mem; + next_write_incr_group; + if eq_4.out with eq_4_group { + flash_write; + } + len_incr_group; + } + } + } + } + } + } +} +component pifo_root(cmd: 2, value: 32) -> () { + cells { + queue_l = pifo_red(); + queue_r = fifo_blue(); + ref stats = stats(); + flow = std_reg(1); + lt_1 = std_lt(32); + ref ans = std_reg(32); + ref err = std_reg(1); + len = std_reg(32); + hot = std_reg(1); + eq_2 = std_eq(1); + eq_3 = std_eq(1); + eq_4 = std_eq(1); + eq_5 = std_eq(1); + eq_6 = std_eq(32); + eq_7 = std_eq(32); + eq_8 = std_eq(2); + eq_9 = std_eq(2); + eq_10 = std_eq(2); + eq_11 = std_eq(1); + neq_12 = std_neq(1); + hot_not = std_not(1); + len_incr = std_add(32); + len_decr = std_sub(32); + } + wires { + group infer_flow { + lt_1.left = 32'd200; + lt_1.right = value; + flow.write_en = 1'd1; + flow.in = lt_1.out; + infer_flow[done] = flow.done; + } + comb group eq_2_group { + eq_2.left = hot.out; + eq_2.right = 1'd0; + } + comb group eq_3_group { + eq_3.left = hot.out; + eq_3.right = 1'd1; + } + comb group eq_4_group { + eq_4.left = flow.out; + eq_4.right = 1'd0; + } + comb group eq_5_group { + eq_5.left = flow.out; + eq_5.right = 1'd1; + } + comb group eq_6_group { + eq_6.left = len.out; + eq_6.right = 32'd0; + } + comb group eq_7_group { + eq_7.left = len.out; + eq_7.right = 32'd10; + } + comb group eq_8_group { + eq_8.left = cmd; + eq_8.right = 2'd0; + } + comb group eq_9_group { + eq_9.left = cmd; + eq_9.right = 2'd1; + } + comb group eq_10_group { + eq_10.left = cmd; + eq_10.right = 2'd2; + } + comb group eq_11_group { + eq_11.left = err.out; + eq_11.right = 1'd0; + } + comb group neq_12_group { + neq_12.left = err.out; + neq_12.right = 1'd0; + } + group hot_not_group { + hot_not.in = hot.out; + hot.write_en = 1'd1; + hot.in = hot_not.out; + hot_not_group[done] = hot.done; + } + group raise_err { + err.in = 1'd1; + err.write_en = 1'd1; + raise_err[done] = err.done; + } + group lower_err { + err.in = 1'd0; + err.write_en = 1'd1; + lower_err[done] = err.done; + } + group flash_ans { + ans.in = 32'd0; + ans.write_en = 1'd1; + flash_ans[done] = ans.done; + } + group len_incr_group { + len_incr.left = len.out; + len_incr.right = 32'd1; + len.write_en = 1'd1; + len.in = len_incr.out; + len_incr_group[done] = len.done; + } + group len_decr_group { + len_decr.left = len.out; + len_decr.right = 32'd1; + len.write_en = 1'd1; + len.in = len_decr.out; + len_decr_group[done] = len.done; + } + } + control { + seq { + par { + if eq_8.out with eq_8_group { + if eq_6.out with eq_6_group { + seq { + raise_err; + flash_ans; + } + } else { + seq { + lower_err; + par { + if eq_2.out with eq_2_group { + seq { + invoke queue_l[ans=ans, err=err](cmd=cmd, value=value)(); + par { + if neq_12.out with neq_12_group { + seq { + lower_err; + invoke queue_r[ans=ans, err=err](cmd=cmd, value=value)(); + } + } + if eq_11.out with eq_11_group { + seq { + hot_not_group; + } + } + } + } + } + if eq_3.out with eq_3_group { + seq { + invoke queue_r[ans=ans, err=err](cmd=cmd, value=value)(); + par { + if neq_12.out with neq_12_group { + seq { + lower_err; + invoke queue_l[ans=ans, err=err](cmd=cmd, value=value)(); + } + } + if eq_11.out with eq_11_group { + seq { + hot_not_group; + } + } + } + } + } + } + len_decr_group; + } + } + } + if eq_9.out with eq_9_group { + if eq_6.out with eq_6_group { + seq { + raise_err; + flash_ans; + } + } else { + seq { + lower_err; + par { + if eq_2.out with eq_2_group { + seq { + invoke queue_l[ans=ans, err=err](cmd=cmd, value=value)(); + if neq_12.out with neq_12_group { + seq { + lower_err; + invoke queue_r[ans=ans, err=err](cmd=cmd, value=value)(); + } + } + } + } + if eq_3.out with eq_3_group { + seq { + invoke queue_r[ans=ans, err=err](cmd=cmd, value=value)(); + if neq_12.out with neq_12_group { + seq { + lower_err; + invoke queue_l[ans=ans, err=err](cmd=cmd, value=value)(); + } + } + } + } + } + } + } + } + if eq_10.out with eq_10_group { + if eq_7.out with eq_7_group { + seq { + raise_err; + flash_ans; + } + } else { + seq { + lower_err; + infer_flow; + par { + if eq_4.out with eq_4_group { + invoke queue_l[ans=ans, err=err](cmd=cmd, value=value)(); + } + if eq_5.out with eq_5_group { + invoke queue_r[ans=ans, err=err](cmd=cmd, value=value)(); + } + } + if eq_11.out with eq_11_group { + seq { + len_incr_group; + invoke stats(flow=flow.out)(); + } + } + } + } + } + } + } + } +} +component dataplane() -> () { + cells { + ref stats_runner = stats(); + myqueue = pifo_root(); + ref commands = seq_mem_d1(2, 15, 32); + ref values = seq_mem_d1(32, 15, 32); + ref has_ans = std_reg(1); + ref component_ans = std_reg(32); + ref component_err = std_reg(1); + i = std_reg(32); + command = std_reg(2); + value = std_reg(32); + i_incr = std_add(32); + le_1 = std_le(2); + not_2 = std_not(1); + i_eq_MAX_CMDS = std_eq(32); + } + wires { + group i_incr_group { + i_incr.left = i.out; + i_incr.right = 32'd1; + i.write_en = 1'd1; + i.in = i_incr.out; + i_incr_group[done] = i.done; + } + comb group le_1_group { + le_1.left = command.out; + le_1.right = 2'd1; + } + group read_cmd_phase1 { + commands.addr0 = i.out; + commands.read_en = 1'd1; + read_cmd_phase1[done] = commands.read_done; + } + group write_cmd_phase2 { + command.write_en = 1'd1; + command.in = commands.read_data; + write_cmd_phase2[done] = command.done; + } + group read_value { + values.addr0 = i.out; + values.read_en = 1'd1; + read_value[done] = values.read_done; + } + group write_value_to_reg { + value.write_en = 1'd1; + value.in = values.read_data; + write_value_to_reg[done] = value.done; + } + group raise_has_ans { + has_ans.in = 1'd1; + has_ans.write_en = 1'd1; + raise_has_ans[done] = has_ans.done; + } + group lower_has_ans { + has_ans.in = 1'd0; + has_ans.write_en = 1'd1; + lower_has_ans[done] = has_ans.done; + } + comb group not_2_group { + not_2.in = component_err.out; + } + group i_eq_MAX_CMDS_group { + i_eq_MAX_CMDS.left = i.out; + i_eq_MAX_CMDS.right = 32'd15; + component_err.write_en = 1'd1; + component_err.in = i_eq_MAX_CMDS.out; + i_eq_MAX_CMDS_group[done] = component_err.done; + } + } + control { + seq { + read_cmd_phase1; + write_cmd_phase2; + read_value; + write_value_to_reg; + invoke myqueue[ans=component_ans, err=component_err, stats=stats_runner](cmd=command.out, value=value.out)(); + if not_2.out with not_2_group { + seq { + if le_1.out with le_1_group { + seq { + raise_has_ans; + } + } else { + seq { + lower_has_ans; + } + } + i_incr_group; + i_eq_MAX_CMDS_group; + } + } + } + } +} +component controller() -> () { + cells { + ref stats_controller = stats(); + count_0 = std_reg(32); + count_1 = std_reg(32); + } + wires { + group get_data_locally { + count_0.in = stats_controller.count_0; + count_0.write_en = 1'd1; + count_1.in = stats_controller.count_1; + count_1.write_en = 1'd1; + get_data_locally[done] = count_0.done & count_1.done ? 1'd1; + } + } + control { + seq { + get_data_locally; + } + } +} +component main() -> () { + cells { + stats_main = stats(); + dataplane = dataplane(); + controller = controller(); + has_ans = std_reg(1); + dataplane_ans = std_reg(32); + dataplane_err = std_reg(1); + @external commands = seq_mem_d1(2, 15, 32); + @external values = seq_mem_d1(32, 15, 32); + @external ans_mem = seq_mem_d1(32, 10, 32); + j = std_reg(32); + j_incr = std_add(32); + eq_1 = std_eq(1); + } + wires { + group j_incr_group { + j_incr.left = j.out; + j_incr.right = 32'd1; + j.write_en = 1'd1; + j.in = j_incr.out; + j_incr_group[done] = j.done; + } + group write_ans { + ans_mem.addr0 = j.out; + ans_mem.write_en = 1'd1; + ans_mem.write_data = dataplane_ans.out; + write_ans[done] = ans_mem.write_done; + } + comb group eq_1_group { + eq_1.left = dataplane_err.out; + eq_1.right = 1'd0; + } + } + control { + seq { + while eq_1.out with eq_1_group { + seq { + invoke dataplane[commands=commands, values=values, has_ans=has_ans, component_ans=dataplane_ans, component_err=dataplane_err, stats_runner=stats_main]()(); + if has_ans.out { + seq { + write_ans; + j_incr_group; + } + } + invoke controller[stats_controller=stats_main]()(); + } + } + } + } +} diff --git a/calyx-py/test/correctness/pifo.data b/calyx-py/test/correctness/pifo.data index 5f72a3db88..7d0d68fb24 100644 --- a/calyx-py/test/correctness/pifo.data +++ b/calyx-py/test/correctness/pifo.data @@ -1,6 +1,11 @@ { "commands": { "data": [ + 2, + 2, + 2, + 2, + 2, 2, 1, 2, @@ -15,7 +20,87 @@ 2, 0, 0, - 0 + 0, + 1, + 1, + 0, + 1, + 2, + 0, + 2, + 0, + 0, + 2, + 0, + 1, + 1, + 0, + 1, + 0, + 0, + 0, + 2, + 2, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 0, + 2, + 2, + 2, + 0, + 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, + 0, + 1, + 0, + 2, + 1, + 1, + 0, + 2, + 1, + 1, + 1 ], "format": { "is_signed": false, @@ -25,21 +110,106 @@ }, "values": { "data": [ - 190, - 240, - 126, - 194, - 278, - 52, - 293, - 127, - 6, + 296, + 4, + 231, + 23, + 362, + 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, + 352, + 158, + 247, + 82, + 368, + 24, + 41, + 307, + 273, + 207, + 16, + 121, + 379, + 304, + 176, + 128, + 233, + 333, + 215, + 74, + 28, + 326, + 16, + 252, + 171, + 106, + 66, 374, - 110, - 208, - 143, - 93, - 392 + 288, + 67, + 322, + 211, + 54, + 86, + 222, + 190, + 76, + 30, + 215, + 150, + 72, + 232, + 317, + 86, + 267, + 232, + 249, + 352, + 373, + 162, + 245, + 140 ], "format": { "is_signed": false, @@ -49,6 +219,96 @@ }, "ans_mem": { "data": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, 0, 0, 0, diff --git a/calyx-py/test/correctness/pifo.expect b/calyx-py/test/correctness/pifo.expect index e29484e3fe..342f598736 100644 --- a/calyx-py/test/correctness/pifo.expect +++ b/calyx-py/test/correctness/pifo.expect @@ -1,17 +1,112 @@ { "ans_mem": [ - 190, - 190, - 190, - 278, - 278, - 126, - 293, - 52, + 4, + 4, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, 0, 0 ], "commands": [ + 2, + 2, + 2, + 2, + 2, 2, 1, 2, @@ -26,23 +121,188 @@ 2, 0, 0, - 0 + 0, + 1, + 1, + 0, + 1, + 2, + 0, + 2, + 0, + 0, + 2, + 0, + 1, + 1, + 0, + 1, + 0, + 0, + 0, + 2, + 2, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 0, + 2, + 2, + 2, + 0, + 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, + 0, + 1, + 0, + 2, + 1, + 1, + 0, + 2, + 1, + 1, + 1 ], "values": [ - 190, - 240, - 126, - 194, - 278, - 52, - 293, - 127, - 6, + 296, + 4, + 231, + 23, + 362, + 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, + 352, + 158, + 247, + 82, + 368, + 24, + 41, + 307, + 273, + 207, + 16, + 121, + 379, + 304, + 176, + 128, + 233, + 333, + 215, + 74, + 28, + 326, + 16, + 252, + 171, + 106, + 66, 374, - 110, - 208, - 143, - 93, - 392 + 288, + 67, + 322, + 211, + 54, + 86, + 222, + 190, + 76, + 30, + 215, + 150, + 72, + 232, + 317, + 86, + 267, + 232, + 249, + 352, + 373, + 162, + 245, + 140 ] } diff --git a/calyx-py/test/correctness/pifo_tree.data b/calyx-py/test/correctness/pifo_tree.data index 5f72a3db88..7d0d68fb24 100644 --- a/calyx-py/test/correctness/pifo_tree.data +++ b/calyx-py/test/correctness/pifo_tree.data @@ -1,6 +1,11 @@ { "commands": { "data": [ + 2, + 2, + 2, + 2, + 2, 2, 1, 2, @@ -15,7 +20,87 @@ 2, 0, 0, - 0 + 0, + 1, + 1, + 0, + 1, + 2, + 0, + 2, + 0, + 0, + 2, + 0, + 1, + 1, + 0, + 1, + 0, + 0, + 0, + 2, + 2, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 0, + 2, + 2, + 2, + 0, + 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, + 0, + 1, + 0, + 2, + 1, + 1, + 0, + 2, + 1, + 1, + 1 ], "format": { "is_signed": false, @@ -25,21 +110,106 @@ }, "values": { "data": [ - 190, - 240, - 126, - 194, - 278, - 52, - 293, - 127, - 6, + 296, + 4, + 231, + 23, + 362, + 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, + 352, + 158, + 247, + 82, + 368, + 24, + 41, + 307, + 273, + 207, + 16, + 121, + 379, + 304, + 176, + 128, + 233, + 333, + 215, + 74, + 28, + 326, + 16, + 252, + 171, + 106, + 66, 374, - 110, - 208, - 143, - 93, - 392 + 288, + 67, + 322, + 211, + 54, + 86, + 222, + 190, + 76, + 30, + 215, + 150, + 72, + 232, + 317, + 86, + 267, + 232, + 249, + 352, + 373, + 162, + 245, + 140 ], "format": { "is_signed": false, @@ -49,6 +219,96 @@ }, "ans_mem": { "data": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, 0, 0, 0, diff --git a/calyx-py/test/correctness/pifo_tree.expect b/calyx-py/test/correctness/pifo_tree.expect index c0040e323f..342f598736 100644 --- a/calyx-py/test/correctness/pifo_tree.expect +++ b/calyx-py/test/correctness/pifo_tree.expect @@ -1,17 +1,112 @@ { "ans_mem": [ - 190, - 190, - 52, - 278, - 278, - 190, - 293, - 126, + 4, + 4, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, 0, 0 ], "commands": [ + 2, + 2, + 2, + 2, + 2, 2, 1, 2, @@ -26,23 +121,188 @@ 2, 0, 0, - 0 + 0, + 1, + 1, + 0, + 1, + 2, + 0, + 2, + 0, + 0, + 2, + 0, + 1, + 1, + 0, + 1, + 0, + 0, + 0, + 2, + 2, + 1, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 0, + 2, + 2, + 2, + 0, + 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, + 0, + 1, + 0, + 2, + 1, + 1, + 0, + 2, + 1, + 1, + 1 ], "values": [ - 190, - 240, - 126, - 194, - 278, - 52, - 293, - 127, - 6, + 296, + 4, + 231, + 23, + 362, + 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, + 352, + 158, + 247, + 82, + 368, + 24, + 41, + 307, + 273, + 207, + 16, + 121, + 379, + 304, + 176, + 128, + 233, + 333, + 215, + 74, + 28, + 326, + 16, + 252, + 171, + 106, + 66, 374, - 110, - 208, - 143, - 93, - 392 + 288, + 67, + 322, + 211, + 54, + 86, + 222, + 190, + 76, + 30, + 215, + 150, + 72, + 232, + 317, + 86, + 267, + 232, + 249, + 352, + 373, + 162, + 245, + 140 ] }