Skip to content

Commit

Permalink
pifo tree: better testing (#1765)
Browse files Browse the repository at this point in the history
  • Loading branch information
anshumanmohan authored Nov 16, 2023
1 parent 2df97f1 commit 5160e84
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 47 deletions.
22 changes: 22 additions & 0 deletions calyx-py/calyx/pifotree_oracle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import queues


if __name__ == "__main__":
commands, values = queues.parse_json()

# Our PIFO is a little complicated: it is a tree of queues.
# The root has two children, which are PIFOs.
# - PIFO_red is the left child.
# + PIFO_red itself has two children, which are FIFOs.
# * FIFO_purple is the left child.
# * FIFO_tangerine is the right child.
# * The boundary for this is 100.
# - FIFO_blue is the right child.
# - The boundary for this is 200.

pifo = queues.Pifo(
queues.Pifo(queues.Fifo([]), queues.Fifo([]), 100), queues.Fifo([]), 200
)

ans = queues.operate_queue(commands, values, pifo)
queues.dump_json(commands, values, ans)
40 changes: 20 additions & 20 deletions calyx-py/test/correctness/pifo_tree.data
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
"commands": {
"data": [
2,
1,
2,
1,
2,
2,
2,
2,
0,
1,
0,
0,
0,
0,
0,
2,
0,
0,
0
Expand All @@ -25,21 +25,21 @@
},
"values": {
"data": [
11,
12,
201,
202,
203,
101,
0,
0,
0,
0,
0,
0,
0,
0,
0
190,
240,
126,
194,
278,
52,
293,
127,
6,
374,
110,
208,
143,
93,
392
],
"format": {
"is_signed": false,
Expand All @@ -66,4 +66,4 @@
"width": 32
}
}
}
}
54 changes: 27 additions & 27 deletions calyx-py/test/correctness/pifo_tree.expect
Original file line number Diff line number Diff line change
@@ -1,48 +1,48 @@
{
"ans_mem": [
11,
201,
101,
202,
12,
203,
0,
0,
190,
190,
52,
278,
278,
190,
293,
126,
0,
0
],
"commands": [
2,
1,
2,
1,
2,
2,
2,
2,
0,
1,
0,
0,
0,
0,
0,
2,
0,
0,
0
],
"values": [
11,
12,
201,
202,
203,
101,
0,
0,
0,
0,
0,
0,
0,
0,
0
190,
240,
126,
194,
278,
52,
293,
127,
6,
374,
110,
208,
143,
93,
392
]
}

0 comments on commit 5160e84

Please sign in to comment.