Skip to content

Commit

Permalink
Add CAPI for new option, add '-modules' suffix as suggested, thanks!
Browse files Browse the repository at this point in the history
  • Loading branch information
dtzSiFive committed Apr 30, 2024
1 parent bcbdbab commit ebbc645
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 7 deletions.
3 changes: 3 additions & 0 deletions include/circt-c/Firtool/Firtool.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ MLIR_CAPI_EXPORTED void circtFirtoolOptionsSetDisableAnnotationsClassless(
MLIR_CAPI_EXPORTED void circtFirtoolOptionsSetLowerAnnotationsNoRefTypePorts(
CirctFirtoolFirtoolOptions options, bool value);

MLIR_CAPI_EXPORTED void circtFirtoolOptionsSetAllowAddingPortsOnPublic(
CirctFirtoolFirtoolOptions options, bool value);

MLIR_CAPI_EXPORTED void circtFirtoolOptionsSetPreserveAggregate(
CirctFirtoolFirtoolOptions options,
CirctFirtoolPreserveAggregateMode value);
Expand Down
2 changes: 1 addition & 1 deletion include/circt/Dialect/FIRRTL/Passes.td
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def LowerFIRRTLAnnotations : Pass<"firrtl-lower-annotations", "firrtl::CircuitOp
"Ignore unknown annotations.">,
Option<"noRefTypePorts", "no-ref-type-ports", "bool", "false",
"Create normal ports, not ref type ports.">,
Option<"allowAddingPortsOnPublic", "allow-adding-ports-on-public", "bool", "false",
Option<"allowAddingPortsOnPublic", "allow-adding-ports-on-public-modules", "bool", "false",
"Allow public modules to gain additional ports as a result of wiring.">,
];
let dependentDialects = ["hw::HWDialect"];
Expand Down
5 changes: 5 additions & 0 deletions lib/CAPI/Firtool/Firtool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ void circtFirtoolOptionsSetLowerAnnotationsNoRefTypePorts(
unwrap(options)->setLowerAnnotationsNoRefTypePorts(value);
}

void circtFirtoolOptionsSetAllowAddingPortsOnPublic(
CirctFirtoolFirtoolOptions options, bool value) {
unwrap(options)->setAllowAddingPortsOnPublic(value);
}

void circtFirtoolOptionsSetPreserveAggregate(
CirctFirtoolFirtoolOptions options,
CirctFirtoolPreserveAggregateMode value) {
Expand Down
2 changes: 1 addition & 1 deletion lib/Firtool/Firtool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ struct FirtoolCmdOptions {
llvm::cl::init(false), llvm::cl::Hidden};

llvm::cl::opt<bool> allowAddingPortsOnPublic{
"allow-adding-ports-on-public",
"allow-adding-ports-on-public-modules",
llvm::cl::desc("Allow adding ports to public modules"),
llvm::cl::init(false), llvm::cl::Hidden};

Expand Down
2 changes: 1 addition & 1 deletion test/Dialect/FIRRTL/SFCTests/mem-taps-reg.fir
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
; RUN: firtool --verilog --allow-adding-ports-on-public %s | FileCheck %s
; RUN: firtool --verilog --allow-adding-ports-on-public-modules %s | FileCheck %s

circuit Top : %[[
{
Expand Down
6 changes: 3 additions & 3 deletions test/Dialect/FIRRTL/SFCTests/mem-taps.fir
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
; RUN: firtool --verilog -allow-adding-ports-on-public %s | FileCheck %s
; RUN: firtool --verilog -allow-adding-ports-on-public -preserve-aggregate=1d-vec %s | FileCheck %s --check-prefix=AGGGREGATE
; RUN: firtool --verilog -allow-adding-ports-on-public -lower-annotations-no-ref-type-ports %s | FileCheck %s --check-prefix=NOREFS
; RUN: firtool --verilog -allow-adding-ports-on-public-modules %s | FileCheck %s
; RUN: firtool --verilog -allow-adding-ports-on-public-modules -preserve-aggregate=1d-vec %s | FileCheck %s --check-prefix=AGGGREGATE
; RUN: firtool --verilog -allow-adding-ports-on-public-modules -lower-annotations-no-ref-type-ports %s | FileCheck %s --check-prefix=NOREFS

circuit Top : %[[
{
Expand Down
2 changes: 1 addition & 1 deletion test/Dialect/FIRRTL/annotations.mlir
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: circt-opt --pass-pipeline='builtin.module(firrtl.circuit(firrtl-lower-annotations{allow-adding-ports-on-public=true}))' --split-input-file %s | FileCheck %s
// RUN: circt-opt --pass-pipeline='builtin.module(firrtl.circuit(firrtl-lower-annotations{allow-adding-ports-on-public-modules=true}))' --split-input-file %s | FileCheck %s

// circt.test copies the annotation to the target
// circt.testNT puts the targetless annotation on the circuit
Expand Down

0 comments on commit ebbc645

Please sign in to comment.