[SimToSV][HWToSV] Print-like SV operations are not guarded from synthesis
- Dominant language
- C++
- Stars
- 2.2k
- Forks
- 524
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 46
Description
The lowering path in `SimToSV` that emits `sv.fwrite` / `sv.write` does not currently make sure that these operations are protected from synthesis.
This is problematic because these operations are simulation-only side effects. They should probably be emitted under the same synthesis guard mechanism used for other non-synthesizable SV constructs.
Run
```
circt-opt --lower-sim-to-sv --lower-hw-to-sv test/Conversion/SimToSV/lower-print-formatted-proc-to-sv.mlir
```
Then the part of output would be:
```mlir
...
hw.module @print_to_literal_file(in %clk : i1) attributes {emit.fragments = [@CIRCT_LIB_LOGGING_FRAGMENT]} {
sv.always posedge %clk {
%0 = sv.constantStr "static.log"
%1 = sv.func.call.procedural @"__circt_lib_logging::FileDescriptor::get"(%0) : (!hw.string) -> i32
sv.fwrite %1, "value"
}
hw.output
}
...
```
The generated sv.fwrite is emitted directly in the procedural region, without a synthesis guard around it.
Contributor guide
No contributing guide indexed for this repository
Research direction
Run the provided circt-opt command on test/Conversion/SimToSV/lower-print-formatted-proc-to-sv.mlir and inspect the SimToSV/HWToSV lowering path for sv.fwrite and sv.write. Compare it with the existing synthesis guard mechanism for other non-synthesizable SV constructs. Done means the generated operations are protected from synthesis and the relevant test output reflects the guard.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100