8000 [proc] Resolve same-name channel interfaces by direction by cdleary · Pull Request #5569 · google/xls · GitHub
[go: up one dir, main page]

Skip to content

[proc] Resolve same-name channel interfaces by direction - #5569

Open
cdleary wants to merge 1 commit into
google:mainfrom
xlsynth:cdleary/2026-11-28-proc-channel-direction
Open

cdleary wants to merge 1 commit into
google:mainfrom
xlsynth:cdleary/2026-11-28-proc-channel-direction

Conversation

@cdleary
@cdleary cdleary commented Nov 28, 2026 •
Copy link
Copy Markdown
Collaborator

A proc-scoped input and output may share a name and bind to two different queues. During work on #5531 we found that both the interpreter and the JIT could consume a proc’s own output.

Reproducer

The two streaming interfaces below are separate queues named port. The token from the first send makes the receive wait until the proc has sent 7.

package example

top proc handshake<port: bits[8] in, port: bits[8] out>() {
  chan_interface port(direction=receive, kind=streaming, strictness=total_order)
  chan_interface port(direction=send, kind=streaming, strictness=total_order)

  start: token = after_all()
  seven: bits[8] = literal(value=7)
  sent: token = send(start, seven, channel=port)
  read: (token, bits[8]) = receive(sent, channel=port)
  ready: token = tuple_index(read, index=0)
  input: bits[8] = tuple_index(read, index=1)
  one: bits[8] = literal(value=1)
  reply: bits[8] = add(input, one)
  done: token = send(ready, reply, channel=port)
}

Save the IR as handshake.ir and run one tick with no input.

eval_proc_main handshake.ir --backend=ir_interpreter --ticks=1

Before the fix, the receive consumed the 7 from the output queue, so the final send left bits[8]:0x8 on port. With the fix, the receive blocks on the empty input queue and bits[8]:0x7 remains on the output. Running with --backend=serial_jit gives the same results.

Runtime changes

Resolve channel operations against the send or receive binding of the executing proc instance. Use the matching interface for the payload type and for the queue reported to the scheduler. The JIT retains its compiled index per name and binds the two queues to its existing send and receive callbacks. AOT objects that baked in the wrong receive payload width need recompilation. When both interfaces are bound to one loopback, both operations use that queue.

eval_proc_main now uses the receive binding for supplied inputs and the send binding for expected outputs, including when wiring RAM model requests and responses. A lookup without a direction reports ambiguity when the name identifies distinct queues. Package-scoped channels keep their single-queue behavior.

Tests

The optimized //xls/... sweep passed all 2,251 selected targets. Native regressions cover send-before-receive, different payload widths, and a child instantiated with both loopback and distinct queues. CLI regressions exercise the interpreter and JIT. The sweep excluded contrib, dev_tools, visualization, and five individual targets.

Resolve sends and receives through their elaborated channel bindings. Use those bindings in the interpreter, JIT callbacks, scheduler notifications, and CLI input/output so distinct queues stay separate and shared loopbacks keep working.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

0