-
Notifications
You must be signed in to change notification settings - Fork 309
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
[FIRRTL][Sim] Add fopen
and fclose
intrinsics, add fd
operand to printf
#7111
Conversation
bf6d9dd
to
cf39a6b
Compare
cf39a6b
to
04767b0
Compare
return setLoweringTo<sv::SystemFunctionOp>( | ||
op, resultTy, builder.getStringAttr("fopen"), ValueRange{filename, mode}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$fopen
is task
so you cannot put this into non-procedural region. Please put this to initial block and assign return value to a register.
auto result = builder.create<sv::SystemFunctionOp>( | ||
NoneType::get(builder.getContext()), builder.getStringAttr("fclose"), | ||
ValueRange{fd}); | ||
return success(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also needs to be in a procedural region. I noticed currently there is no support for final
statement. That seems reasonable addition to SV dialect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally the implementation looks great but let's wait for how chipsalliance/firrtl-spec#213 goes first 👍
StringRef formatString; | ||
if (parseExp(clock, "expected clock expression in printf") || | ||
parseExp(condition, "expected condition in printf") || | ||
parseExp(fd, "expected fd expression in printf") || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It 's necessary to accept old syntal. Please add a condition for FIRRTL-spec version.
node fd = intrinsic(circt_fopen<filename = "file.txt", mode = "a"> : SInt<32>) | ||
printf(clock, cond, fd, "test %d\n", var) | ||
intrinsic(circt_fclose, fd) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is pretty problematic as this is introducing a procedural ordering requirement that is not reflected in the IR. I can legally move the close before the printf, yet there is an expectation that I do not and that this will lower to a specific order in Verilog.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I was assuming fclose
intrinsic is lowered in fclose
in final
statement. Alternatively we could add clock
and enable
operands either.
Closed as in favor of #7983. |
This PR enables the SystemVerilog generated by Chisel&CIRCT can be
fwrite
to different files by the simulator.FIRRTL Spec changes: chipsalliance/firrtl-spec#213 (some discussion already there)
Closes #7092, CC @seldridge @sequencer @uenoku