Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions docs/Dialects/FIRRTL/FIRRTLAnnotations.md
Original file line number Diff line number Diff line change
Expand Up @@ -285,23 +285,7 @@ Example:
}
```

### [BlackBoxResourceFileNameAnno](https://javadoc.io/doc/edu.berkeley.cs/firrtl_2.13/latest/firrtl/transforms/BlackBoxResourceFileNameAnno.html)

| Property | Type | Description |
| ---------- | ------ | ------------- |
| class | string | `firrtl.transforms.BlackBoxResourceFileNameAnno` |
| resourceFileName | string | Output filename |

Specifies the output file name for the list of black box source files that
is generated as a collateral of the pass.

Example:
```json
{
"class": "firrtl.transforms.BlackBoxResourceFileNameAnno",
"resourceFileName": "FileList.f"
}
```

### [BlackBoxTargetDirAnno](https://javadoc.io/doc/edu.berkeley.cs/firrtl_2.13/latest/firrtl/transforms/BlackBoxTargetDirAnno.html)

Expand Down
2 changes: 0 additions & 2 deletions include/circt/Dialect/FIRRTL/AnnotationDetails.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ constexpr const char *blackBoxPathAnnoClass =
"firrtl.transforms.BlackBoxPathAnno";
constexpr const char *blackBoxTargetDirAnnoClass =
"firrtl.transforms.BlackBoxTargetDirAnno";
constexpr const char *blackBoxResourceFileNameAnnoClass =
"firrtl.transforms.BlackBoxResourceFileNameAnno";
constexpr const char *blackBoxAnnoClass =
"firrtl.transforms.BlackBox"; // Not in SFC
constexpr const char *mustDedupAnnoClass =
Expand Down
3 changes: 0 additions & 3 deletions include/circt/Dialect/FIRRTL/Passes.td
Original file line number Diff line number Diff line change
Expand Up @@ -405,9 +405,6 @@ def BlackBoxReader : Pass<"firrtl-blackbox-reader", "CircuitOp"> {
- `{class = "firrtl.transforms.BlackBoxTargetDirAnno", targetDir = "..."}`
Overrides the target directory into which black box source files are
emitted.
- `{class = "firrtl.transforms.BlackBoxResourceFileNameAnno", resourceFileName = "xyz.f"}`
Specifies the output file name for the list of black box source files that
is generated as a collateral of the pass.

The supported `firrtl.extmodule` annotations are:

Expand Down
28 changes: 2 additions & 26 deletions lib/Dialect/FIRRTL/Transforms/BlackBoxReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,6 @@ struct BlackBoxReaderPass
/// The target directory for testbench files.
StringRef testBenchDir;

/// The file list file name (sic) for black boxes. If set, generates a file
/// that lists all non-header source files for black boxes. Can be changed
/// through `firrtl.transforms.BlackBoxResourceFileNameAnno` annotations.
StringRef resourceFileName;

/// Analyses used by this pass.
InstanceGraph *instanceGraph;
InstanceInfo *instanceInfo;
Expand Down Expand Up @@ -143,24 +138,11 @@ void BlackBoxReaderPass::runOnOperation() {
// Determine the target directory and resource file name from the
// annotations present on the circuit operation.
targetDir = ".";
resourceFileName = "firrtl_black_box_resource_files.f";

// Process black box annotations on the circuit. Some of these annotations
// will affect how the rest of the annotations are resolved.
SmallVector<Attribute, 4> filteredAnnos;
for (auto annot : AnnotationSet(circuitOp)) {
// Handle resource file name annotation.
if (annot.isClass(blackBoxResourceFileNameAnnoClass)) {
if (auto resourceFN = annot.getMember<StringAttr>("resourceFileName")) {
resourceFileName = resourceFN.getValue();
continue;
}

circuitOp->emitError(blackBoxResourceFileNameAnnoClass)
<< " annotation missing \"resourceFileName\" attribute";
signalPassFailure();
continue;
}
filteredAnnos.push_back(annot.getDict());

// Get the testbench and cover directories.
Expand Down Expand Up @@ -193,9 +175,8 @@ void BlackBoxReaderPass::runOnOperation() {
anythingChanged |=
AnnotationSet(filteredAnnos, context).applyToOperation(circuitOp);

LLVM_DEBUG(llvm::dbgs() << "Black box target directory: " << targetDir << "\n"
<< "Black box resource file name: "
<< resourceFileName << "\n");
LLVM_DEBUG(llvm::dbgs() << "Black box target directory: " << targetDir
<< "\n");

// Newly generated IR will be placed at the end of the circuit.
auto builder = circuitOp.getBodyBuilder();
Expand Down Expand Up @@ -288,11 +269,6 @@ void BlackBoxReaderPass::runOnOperation() {
SmallVector<Attribute> symbols;
for (emit::FileOp file : fileListFiles)
symbols.push_back(FlatSymbolRefAttr::get(file.getSymNameAttr()));

builder.create<emit::FileListOp>(
loc, builder.getStringAttr(resourceFileName),
builder.getArrayAttr(symbols),
builder.getStringAttr(ns.newName("blackbox_filelist")));
}

// If nothing has changed we can preserve the analysis.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -469,9 +469,3 @@ circuit Top :
; EXTRACT: FILE ".{{[/\]}}BlackBox_DUT.v"
; EXTRACT: FILE "Wire{{[/\]}}firrtl{{[/\]}}gct{{[/\]}}BlackBox_GCT.v"
; EXTRACT: FILE ".{{[/\]}}BlackBox_DUTAndGCT.v"

; EXTRACT: FILE "firrtl_black_box_resource_files.f"
; EXTRACT-NOT: FILE
; EXTRACT: BlackBox_DUT.v
; EXTRACT-NEXT: BlackBox_DUTAndGCT.v
; EXTRACT-NEXT: Wire{{[/\]}}firrtl{{[/\]}}gct{{[/\]}}BlackBox_GCT.v
12 changes: 0 additions & 12 deletions test/Dialect/FIRRTL/blackbox-reader.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,6 @@ firrtl.circuit "Foo" attributes {annotations = [
// CHECK: emit.file "qux{{/|\\\\}}NotQux.jpeg" sym @blackbox_Qux.sv {
// CHECK-NEXT: emit.verbatim "/* Qux */\0A"
// CHECK-NEXT: }

// CHECK: emit.file_list "firrtl_black_box_resource_files.f", [
// CHECK-SAME: @blackbox_hello.v
// CHECK-SAME: @blackbox_hello3.v
// CHECK-SAME: @blackbox_Bar.v
// CHECK-SAME: @blackbox_Baz.sv
// CHECK-SAME: @blackbox_hello2.v
// CHECK-SAME: @blackbox_Qux.sv
// CHECK-SAME: ] sym @blackbox_filelist
}

//--- NoDUT.mlir
Expand Down Expand Up @@ -91,7 +82,4 @@ firrtl.circuit "NoDUT" attributes {annotations = [
// CHECK: emit.file ".{{/|\\\\}}NoDUTBlackBox.sv" sym @blackbox_NoDUTBlackBox.sv {
// CHECK-NEXT: emit.verbatim "module NoDUTBlackBox();\0Aendmodule\0A"
// CHECK-NEXT: }
// CHECK: emit.file_list "firrtl_black_box_resource_files.f", [
// CHECK-SAME: @blackbox_NoDUTBlackBox.sv
// CHECK-SAME: ] sym @blackbox_filelist
}
8 changes: 1 addition & 7 deletions test/firtool/blackbox.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,13 @@
// RUN: FileCheck %s --check-prefix=VERILOG-HDR < %t/magic/blackbox-inline.svh
// RUN: FileCheck %s --check-prefix=VERILOG-GIB < %t/magic/blackbox-path.v
// RUN: FileCheck %s --check-prefix=LIST-TOP < %t/filelist.f
// RUN: FileCheck %s --check-prefix=LIST-BLACK-BOX < %t/magic.f

// LIST-TOP: test_mod.sv

// LIST-BLACK-BOX: magic{{[/\]}}blackbox-inline.v
// LIST-BLACK-BOX-NEXT: magic{{[/\]}}blackbox-path.v

firrtl.circuit "test_mod" attributes {annotations = [
// Black box processing should honor only the last annotation.
{class = "firrtl.transforms.BlackBoxTargetDirAnno", targetDir = "ignore_me_plz"},
{class = "firrtl.transforms.BlackBoxTargetDirAnno", targetDir = "magic"},
{class = "firrtl.transforms.BlackBoxResourceFileNameAnno", resourceFileName = "definitely_bad.f"},
{class = "firrtl.transforms.BlackBoxResourceFileNameAnno", resourceFileName = "magic.f"}
{class = "firrtl.transforms.BlackBoxTargetDirAnno", targetDir = "magic"}
]} {
// VERILOG-TOP-LABEL: module test_mod
// VERILOG-TOP-NEXT: ExtInline foo
Expand Down