-
Notifications
You must be signed in to change notification settings - Fork 305
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] Use PRINTF_FD macro instead of 0x80000002 as printf fd #7983
base: main
Are you sure you want to change the base?
Conversation
@darthscsi: What do you think about this? We can just make this part of the FIRRTL ABI (which This would be less configurable than other proposals (e.g., chipsalliance/firrtl-spec#213). However, it avoids some of the problems of things like introducing file descriptors into FIRRTL. The downside of this is that it would take some clever SystemVerilog to be configurable. E.g., I expect that we could include an evolving SystemVerilog file which uses the WDYT? |
CC: @girishpai: As we circle back to ideas you have had about a "logging library" for Chisel, I am wondering if only |
I'd like to explain motivations behind this PR. We generate logs by chisel prinf and collect it for later analysis/verification. However, chisel printf is not configurable and it never works reliably since too many components (simulator/other C libraries) will also print to stdout/stderr. We struggle with it for a long time. chipsalliance/firrtl-spec#213 is proposed to solve the issue, however it seems people are not in favor of it since it looks too specific and too intrusive. So I come up with a clever trick, implemented by my co-workers in this PR. It solves our issue by doing minimal For the general "logging library" design, I'd like to share my thoughts as follows. We have several ways to extend firrtl.printf lowering:
|
b.create<sv::MacroDeclOp>("PRINTF_FD_"); | ||
b.create<emit::FragmentOp>("PRINTF_FD_FRAGMENT", [&] { | ||
b.create<sv::VerbatimOp>( | ||
"\n// Users can define 'PRINTF_FD' to add a specified fd to " |
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.
Do we add comments for other chisel macros? I didn't think we do. There should be a user friendly form of the chisel abi which outlines the macros created to control these things.
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.
Do we add comments for other chisel macros?
These macro are not exposed in Chisel, I think Chisel doesn't have a clear ABI for now.
But instead we should add these to firrtl spec, and chisel users can be point to there.
I don't have an opposition to a minimal change like this. My concern is it might not be general enough to really accomplish what everyone wants. But it is probably better to use the macro than a constant. As long as everyone involved is happy to replace it in the nearish future with something a bit better, I'm fine. It doesn't need to touch the firrtl abi as it is just providing an implementation dependent hook (yes, yes) for dynamically changing the abi behavior. |
I'm also fine with this as a short term solution. It could also easily be adopted in #7973 . My half-baked plan for the future is to add an optional symbol reference operand to the |
I think we could add a new attribute to |
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 needs tests. Also, I agree that there probably isn't a good reason to add comments about what this is as it just bloats the IR.
Otherwise, this is good to proceed with.
@seldridge: Sorry, I only had time today to fix the issue in the test. Could you please take a look for me? |
updates the FIRRTLToHW conversion to use the `PRINTF_FD` macro for specifying the file descriptor, allowing the fd to be obtained externally. This change enhances flexibility by enabling the file descriptor to be defined outside the conversion logic. Signed-off-by: Clo91eaf <[email protected]>
updates the FIRRTLToHW conversion to use the
PRINTF_FD
macro for specifying the file descriptor, allowing the fd to be obtained externally. This change enhances flexibility by enabling the file descriptor to be defined outside the conversion logic.now we can define a log package like this:
and add compile option to import log_fd