calyxir/calyx

Queues: change in `.expect` interface

Closed this issue · 0 comments

This is a bookmark for a change that we'd like to make across all our queues. I'm parking it here because two big changes to the queues, #2067 and #1810, are in flight and I don't want to create an unnecessarily large diff.

Right now queue_call.py starts up two counters, i and j, and then:

  • Feeds commands[i] and values[i] to the queue it is driving. Increments i.
  • If the queue returns an answer (i.e., if the command passed was pop or peek and the queue executed it successfully), it writes the answer to the ans_mem memory like so: ans_mem[j++] = answer.

This has a couple problems:

  • When the queue returns errors (from overflow and underflow, chiefly), we have no "trace" of that fact in the answer memory and therefore no trace of that in our expect-testing.
  • The fact that i and j are out of sync means that it's hard to debug the behavior of a queue by looking over the expect files.

The new proposal is that queue_call.py should start up one counter i, and:

  • Feed commands[i] and values[i] to the queue it is driving.
  • If the queue returns an answer (i.e., if the command passed was pop or peek and the queue executed it successfully), write the answer to the answers memory just as before: ans_mem[i] = answer. If the queue returns an error, indicate this in the answer memory by writing some special value in ans_mem[i]. Similarly, put some special value into ans_mem[i] in case the command was a push and no output was expected.
  • Increment i.