Using fail! in proc

22 views
Skip to first unread message

Mehul Tikekar

unread,
Apr 7, 2023, 1:58:37 PM4/7/23
to xls-dev
I get the following error when I use a fail! in a proc's next function -

F0407 10:53:32.670126    6863 opt_main.cc:120] Check failed: ::absl::OkStatus() == (xls::tools::RealMain(positional_arguments[0])) (OK vs. INTERNAL: Side-effecting token-typed nodes must be connected to the sink token value via a path of tokens: assert.47.; [after 'Inlines invocations' pass, dynamic pass #118]
=== Source Location Trace: ===
third_party/xls/passes/pass_base.h:376
)

To reproduce the error -

fn out_fn(x: u32, state: u32) -> u32 {
  match x {
    u32:0 => fail!("bad_x", state),
    _ => x + state
  }
}
proc Fmac {
  input_a_consumer: chan<u32> in;
  output_producer: chan<u32> out;

  init { u32:0 }

  config(input_a_consumer: chan<u32> in, output_producer: chan<u32> out) {
    (input_a_consumer, output_producer)
  }

  next(tok: token, state: u32) {
    let (tok, input_a) = recv(tok, input_a_consumer);
    let result = out_fn(input_a, state);
    let tok = send(tok, output_producer, result);
    result
  }
}

If I comment out the case with fail!, it compiles. Is there a correct way to use fail! in proc?

Leary, Chris

unread,
Apr 7, 2023, 3:54:07 PM4/7/23
to Mehul Tikekar, xls-dev
Thanks for pointing this out -- I filed https://github.com/google/xls/issues/926

I believe `fail!` in procs haven't been implemented yet -- only pipelines support SV assertions right now, I see outstanding TODOs in the code, but a) we can quickly make a better error message and b) I can see how hard it is to wire up and get back to you.

I'll probably post updates to the github issue if you don't mind subscribing to that.

--
You received this message because you are subscribed to the Google Groups "xls-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to xls-dev+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/xls-dev/5c7a7f5d-fafc-4935-b92a-1dfab8bf311fn%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
Message has been deleted
0 new messages