[ExportVerilog] Add lowering option to not emit version comment (#4811)

This commit is contained in:
rsetaluri 2023-03-21 10:23:09 -07:00 committed by GitHub
parent 31972c02b4
commit 710b321691
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 33 additions and 5 deletions

View File

@ -116,10 +116,12 @@ The current set of "style" Lowering Options is:
For a namehint with "\_" prefix, if the term size is greater than `wireSpillingNamehintTermLimit`
(default=3), then the expression is spilled.
* `emitWireInPorts` (default=`false`). Emits `wire` in port lists rather than
relying on 'default_nettype'. For instance, instead of `input a` this option
would emit that port as `input wire a`.
* `emitBindComments` (default=`false`). Emits a comment wherever an instance or
interface instance is not printed, because it was emitted as a bind elsewhere.
relying on 'default_nettype'. For instance, instead of `input a` this option
would emit that port as `input wire a`.
* `emitBindComments` (default=`false`). Emits a comment wherever an instance or
interface instance is not printed, because it was emitted as a bind elsewhere.
* `omitVersionComment` (default=`false`). Avoids emitting a version comment
(e.g. `// Generated by CIRCT ...`) at the top of each verilog file.
The current set of "lint warnings fix" Lowering Options is:

View File

@ -151,6 +151,9 @@ struct LoweringOptions {
/// If true, emit a comment wherever an instance wasn't printed, because
/// it's emitted elsewhere as a bind.
bool emitBindComments = false;
/// If true, do not emit a version comment at the top of each verilog file.
bool omitVersionComment = false;
};
} // namespace circt

View File

@ -5144,7 +5144,7 @@ void SharedEmitterState::collectOpsForFile(const FileInfo &file,
EmissionList &thingsToEmit,
bool emitHeader) {
// Include the version string comment when the file is verilog.
if (file.isVerilog)
if (file.isVerilog && !options.omitVersionComment)
thingsToEmit.emplace_back(circt::getCirctVersionComment());
// If we're emitting replicated ops, keep track of where we are in the list.

View File

@ -113,6 +113,8 @@ void LoweringOptions::parse(StringRef text, ErrorHandlerT errorHandler) {
emitWireInPorts = true;
} else if (option == "emitBindComments") {
emitBindComments = true;
} else if (option == "omitVersionComment") {
omitVersionComment = true;
} else {
errorHandler(llvm::Twine("unknown style option \'") + option + "\'");
// We continue parsing options after a failure.
@ -164,6 +166,8 @@ std::string LoweringOptions::toString() const {
options += "emitWireInPorts,";
if (emitBindComments)
options += "emitBindComments,";
if (omitVersionComment)
options += "omitVersionComment,";
// Remove a trailing comma if present.
if (!options.empty()) {

View File

@ -0,0 +1,19 @@
// RUN: circt-opt %s -export-verilog --split-input-file | FileCheck %s
module {
// CHECK-LABEL: Generated
// CHECK-NEXT: module Foo(
hw.module @Foo(%a: i1 loc("")) -> () {
hw.output
}
}
// -----
module attributes {circt.loweringOptions = "omitVersionComment"}{
// CHECK-NOT: Generated
// CHECK-LABEL: module Bar(
hw.module @Bar() -> () {
hw.output
}
}