Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Runtime assertion support #1368

Open
rachitnigam opened this issue Feb 17, 2023 · 1 comment
Open

Runtime assertion support #1368

rachitnigam opened this issue Feb 17, 2023 · 1 comment
Labels
C: Library Calyx's standard library S: Available Can be worked upon

Comments

@rachitnigam
Copy link
Contributor

One thing I often keep wanting to do is document a compilation invariant by generating an assertion checked by simulation tools. I realized one way to do this without changing the language is adding a std_assert primitive:

module std_assert(input logic in);
  always_comb begin
    if (!in)
       assert("Assertion failed")
  end
endmodule

Then, user-level programs can simply generate an assignment to the std_assert module and ensure that some condition holds:

cells {
  a0 = std_assert()
}

wires {
  a0.in = cond;
}
@rachitnigam rachitnigam added S: Discussion needed Issues blocked on discussion C: Library Calyx's standard library labels Feb 17, 2023
@sampsyo
Copy link
Contributor

sampsyo commented Feb 18, 2023

Yeah, seems cool. It would be great if the interpreter/debugger treated this as an automatic breakpoint (i.e., execution stops by default when one of these fails, just as if you had set a breakpoint there).

Also, maybe this goes without saying, but it would also be neat if there were a pass to remove these calls when we are generating synthesizable Verilog.

@rachitnigam rachitnigam added S: Available Can be worked upon and removed S: Discussion needed Issues blocked on discussion labels Apr 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: Library Calyx's standard library S: Available Can be worked upon
Projects
None yet
Development

No branches or pull requests

2 participants