google / xls

XLS: Accelerated HW Synthesis
http://google.github.io/xls/
Apache License 2.0
1.2k stars 174 forks source link

interpreter_main throw fatal exception when trying to instanciate varint example #1118

Open proppy opened 1 year ago

proppy commented 1 year ago

with the following snippets:

import std
import xls.examples.protobuf.varint_streaming_decode

const INPUT_BYTES = u32:7;
const OUTPUT_WORDS = u32:3;
const SCRATCHPAD_BYTES = u32:13;
const INPUT_BYTES_WIDTH = std::clog2(INPUT_BYTES);
const OUTPUT_WORDS_WIDTH = std::clog2(OUTPUT_WORDS);

proc varint_streaming {
  init { () }

  config (terminator: chan<bool> out) {
    let (_, bytes_r) =
      chan<(u8[INPUT_BYTES], uN[INPUT_BYTES_WIDTH])>;
    let (words_s, _) =
      chan<(u32[OUTPUT_WORDS], uN[OUTPUT_WORDS_WIDTH])>;
    spawn varint_streaming_decode::varint_streaming_u32_decode<INPUT_BYTES,
                                                               OUTPUT_WORDS,
                                                               SCRATCHPAD_BYTES>(bytes_r, words_s);
    ()
  }

  next(tok: token, state: ()) {}
}

interpreter_main throw the following exception:

PC: @     0x7f5c70d89347  (unknown)  gsignal
    @     0x5603e25fb5e9       1152  FailureSignalHandler()
    @     0x7f5c70ee21c0  793259904  (unknown)
    @     0x5603e275a517        224  std::__u::__libcpp_verbose_abort()
    @     0x5603df7ce4c2         16  std::__u::__throw_bad_variant_access()
    @     0x5603e1c7365a        544  xls::dslx::ProcConfigIrConverter::HandleLet()
    @     0x5603e1eaf887         32  xls::dslx::Let::Accept()
    @     0x5603e1c715f1         48  xls::dslx::ProcConfigIrConverter::HandleStatement()
    @     0x5603e1c713ce        336  xls::dslx::ProcConfigIrConverter::HandleBlock()
    @     0x5603e1eaec07         32  xls::dslx::Block::Accept()
    @     0x5603e1c729b3        112  xls::dslx::ProcConfigIrConverter::HandleFunction()
    @     0x5603e1eaee14         32  xls::dslx::Function::Accept()
    @     0x5603e1c284db       1344  xls::dslx::(anonymous namespace)::ConvertCallGraph()
    @     0x5603e1c26880        752  xls::dslx::ConvertModuleIntoPackage()
    @     0x5603e1c293e2        112  xls::dslx::ConvertModuleToPackage()
    @     0x5603e1c1cf81       1392  xls::dslx::ParseAndTest()
    @     0x5603df7ca19b        768  main
    @     0x7f5c70d75633        192  __libc_start_main
    @     0x5603df7c902a  (unknown)  _start
ericastor commented 1 year ago

This looks to be a problem with the DSLX interpreter's handling of Let - specifically, when assigning from a channel declaration to a tuple that includes a wildcard identifier!

This is the line that fails: https://github.com/google/xls/blob/f8aaf48845010ebefd3ebef506709ef9a7472301/xls/dslx/ir_convert/proc_config_ir_converter.cc#L171

We'll need to fix the way we handle wildcards in this context.