google / xls

XLS: Accelerated HW Synthesis

Home Page:http://google.github.io/xls/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Codegen error: "is not indexable, and is too wide"

ericastor opened this issue · comments

During codegen, XLS fails on certain inputs with an error of the form:

Error: INVALID_ARGUMENT: Index 1 of array_index __out_buf is not indexable, and is too wide for array literal.135; was bits[4]
=== Source Location Trace: === 
third_party/xls/codegen/node_expressions.cc:802
third_party/xls/codegen/module_builder.cc:869
third_party/xls/codegen/block_generator.cc:646
third_party/xls/codegen/block_generator.cc:394
third_party/xls/codegen/block_generator.cc:911
third_party/xls/codegen/pipeline_generator.cc:82
third_party/xls/tools/codegen.cc:258
third_party/xls/tools/codegen_main.cc:89

To reproduce, run codegen_main --generator=pipeline --pipeline_stages=4 --delay_model=asap7 --reset=rst on the following IR:

package my_package

chan out(bits[7], id=10, kind=streaming, ops=send_only, flow_control=ready_valid, strictness=proven_mutually_exclusive, metadata="""""")

top proc test_proc(tkn: token, state_machine_x: bits[1], state_machine_z: bits[1], init={0, 0}) {
  zero_ext.89: bits[33] = zero_ext(state_machine_x, new_bit_count=33, id=89)
  literal.14: bits[33] = literal(value=8589934591, id=14)
  literal.71: bits[4] = literal(value=0, id=71)
  literal.9: bits[4] = literal(value=8, id=9)
  literal.29: bits[7][8][8] = literal(value=[[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]], id=29)
  add.15: bits[33] = add(zero_ext.89, literal.14, id=15)
  sel.73: bits[4] = sel(state_machine_z, cases=[literal.71], default=literal.9, id=73)
  array_index.22: bits[7] = array_index(literal.29, indices=[add.15, sel.73], id=22)
  literal.103: bits[1] = literal(value=0, id=103)
  send.6: token = send(tkn, array_index.22, channel=out, id=6)
  next_value.36: () = next_value(param=state_machine_x, value=literal.103, id=36)
  next_value.70: () = next_value(param=state_machine_z, value=literal.103, id=70)
  next (send.6)
}

Found in a real world example, then minimized by a combination of manual effort and ir_minimizer_main.