Skip to content

[SimToSV][HWToSV] Print-like SV operations are not guarded from synthesis #10489

@nanjo712

Description

@nanjo712

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:

...
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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions