diff options
| author | albertchen-sifive | 2018-10-01 17:23:34 -0700 |
|---|---|---|
| committer | Jack Koenig | 2018-10-01 17:23:34 -0700 |
| commit | 16f3dbda5c3868419cf78d4d83133cd34adf3303 (patch) | |
| tree | ff5e28f2b455599a7ebff607c57e3f9fccf406de /src/main | |
| parent | 29e5c0881291b2ab225eb1617592213de611a4a5 (diff) | |
add BlackBoxPathAnno (#903)
Diffstat (limited to 'src/main')
| -rw-r--r-- | src/main/scala/firrtl/transforms/BlackBoxSourceHelper.scala | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/main/scala/firrtl/transforms/BlackBoxSourceHelper.scala b/src/main/scala/firrtl/transforms/BlackBoxSourceHelper.scala index 182accf2..bf419840 100644 --- a/src/main/scala/firrtl/transforms/BlackBoxSourceHelper.scala +++ b/src/main/scala/firrtl/transforms/BlackBoxSourceHelper.scala @@ -2,7 +2,7 @@ package firrtl.transforms -import java.io.{File, FileNotFoundException, FileOutputStream, PrintWriter} +import java.io.{File, FileNotFoundException, FileInputStream, FileOutputStream, PrintWriter} import firrtl._ import firrtl.Utils.throwInternalError @@ -29,6 +29,12 @@ case class BlackBoxInlineAnno(target: ModuleName, name: String, text: String) ex override def serialize: String = s"inline\n$name\n$text" } +case class BlackBoxPathAnno(target: ModuleName, path: String) extends BlackBoxHelperAnno + with SingleTargetAnnotation[ModuleName] { + def duplicate(n: ModuleName) = this.copy(target = n) + override def serialize: String = s"path\n$path" +} + /** Handle source for Verilog ExtModules (BlackBoxes) * * This transform handles the moving of Verilog source for black boxes into the @@ -71,6 +77,16 @@ class BlackBoxSourceHelper extends firrtl.Transform { val resourceFiles: ListSet[File] = annos.collect { case BlackBoxResourceAnno(_, resourceId) => BlackBoxSourceHelper.writeResourceToDirectory(resourceId, targetDir) + case BlackBoxPathAnno(_, path) => + val fileName = path.split("/").last + val fromFile = new File(path) + val toFile = new File(targetDir, fileName) + + val inputStream = new FileInputStream(fromFile).getChannel + val outputStream = new FileOutputStream(toFile).getChannel + outputStream.transferFrom(inputStream, 0, Long.MaxValue) + + toFile } val inlineFiles: ListSet[File] = annos.collect { |
