[enhancement] Support peek() op in XLS #1383
Labels
csp
Relating to Communicating Sequential Processes or Kahn Process Network style concurrency models
enhancement
New feature or request
What's hard to do? (limit 100 words)
Often requested is a peek() op that given a streaming channel, will return the data at the head of the channel (if any) and a valid bit (true if there were data).
While both peek() and recv_non_blocking() bring us out of KPN land, peek() poses a challenge to simulation vs hardware as in simulation we do not backtrack executed instruction when blocking.
For example:
In hardware, the behavior depends on how peek and recv are scheduled. Let's say that they are scheduled in the same cycle. In this case, once the recv occurs, valid will be true and data will be equal to data0.
In an interpreter, one possible sequence of events is that the channel is empty, and peek executes --> data = 0 and valid = 0. The interpreter then blocks on recv. Once there is data on the channel, recv executes and returns data0.
In order to continue with supporting peek() operation, we should clarify and agree on the behavior of the interpreters, and how the operator is impacted by scheduling.
Current best alternative workaround (limit 100 words)
This is as opposed to the recv_non_blocking() op which will pop the data at the head of the channel if it exists.
Your view of the "best case XLS enhancement" (limit 100 words)
One idea that came out of the discussion was to implement peek and receive as a single op/expression -- so we don't need any roll-back functionality in case a receive blocks.
Proposal was something like like the following
The text was updated successfully, but these errors were encountered: