This repository has been archived by the owner on Aug 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 177
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add --target:fpga flag to prioritize FPGA-friendly compilation
* Update name of FPGA flag based on Jack's comment * Add Scaladoc to describe what each constituent transform does
- Loading branch information
1 parent
6c91a28
commit 47544e4
Showing
2 changed files
with
44 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package firrtl.stage | ||
|
||
import firrtl.transforms._ | ||
import firrtl.passes.memlib._ | ||
import firrtl.options.{ShellOption, HasShellOptions} | ||
|
||
/** | ||
* This flag enables a set of options that guide the FIRRTL compilation flow to ultimately | ||
* generate Verilog that is more amenable to using for synthesized FPGA designs. Currently, this | ||
* flag affects only memories, as the need to emit memories that support downstream inference of | ||
* hardened RAM macros. These options are not intended to be specialized to any particular vendor; | ||
* instead, they aim to emit simple Verilog that more closely reflects traditional human-written | ||
* definitions of synchronous-read memories. | ||
* | ||
* 1) Allow some synchronous-read memories and readwrite ports to pass through VerilogMemDelays | ||
* without introducing explicit pipeline registers or splitting ports. | ||
* 2) Use the SimplifyMems transform to Lower aggregate-typed memories with always-high masks to | ||
* packed memories without splitting. | ||
* 3) Specify that memories with undefined read-under-write behavior should map to emitted | ||
* microarchitectures characteristic of "read-first" ports by default. This eliminates the | ||
* difficulty of inferring a RAM macro that matches the strict semantics of "write-first" ports. | ||
* 4) Enable the InferReadWrite transform to reduce port count, where applicable. | ||
*/ | ||
object OptimizeForFPGA extends HasShellOptions { | ||
private val fpgaAnnos = Seq( | ||
InferReadWriteAnnotation, | ||
RunFirrtlTransformAnnotation(new InferReadWrite), | ||
DefaultReadFirstAnnotation, | ||
RunFirrtlTransformAnnotation(new SetDefaultReadUnderWrite), | ||
RunFirrtlTransformAnnotation(new SimplifyMems), | ||
PassthroughSimpleSyncReadMemsAnnotation | ||
) | ||
val options = Seq( | ||
new ShellOption[Unit]( | ||
longOption = "target:fpga", | ||
toAnnotationSeq = a => fpgaAnnos, | ||
helpText = "Choose compilation strategies that generally favor FPGA targets", | ||
) | ||
) | ||
} |