-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Queues: collect magic numbers, pass 100 commands (#1771)
- Loading branch information
1 parent
44c0a67
commit 3d27b0f
Showing
14 changed files
with
2,966 additions
and
183 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.