diff options
| author | Jiuyang Liu | 2021-04-30 05:12:24 +0000 |
|---|---|---|
| committer | GitHub | 2021-04-30 05:12:24 +0000 |
| commit | 7dd2d7db355d8dd9e1fc49ed7cd479ce5273b691 (patch) | |
| tree | 30193cdf9f1f0700cf465ca88e89efc61a4fea94 /src/main | |
| parent | c5861176887bfa529277e686df09a42aeceb6cd7 (diff) | |
add helper function to convert chirrtl to firrtl. (#1854)
* add convert(chirrtl: cir.Circuit): fir.Circuit to convert chirrtl to firrtl.
* add scaladoc.
* add test.
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Diffstat (limited to 'src/main')
| -rw-r--r-- | src/main/scala/chisel3/stage/ChiselStage.scala | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/main/scala/chisel3/stage/ChiselStage.scala b/src/main/scala/chisel3/stage/ChiselStage.scala index 1bcf5124..989b3a17 100644 --- a/src/main/scala/chisel3/stage/ChiselStage.scala +++ b/src/main/scala/chisel3/stage/ChiselStage.scala @@ -172,6 +172,26 @@ object ChiselStage { .get } + /** Return a [[firrtl.ir.Circuit]] for a [[chisel3.internal.firrtl.Circuit]](aka chirrtl) + * @param chirrtl [[chisel3.internal.firrtl.Circuit]] which need to be converted to [[firrtl.ir.Circuit]] + */ + def convert(chirrtl: cir.Circuit): fir.Circuit = { + val phase = new ChiselPhase { + override val targets = Seq( + Dependency[chisel3.stage.phases.AddImplicitOutputFile], + Dependency[chisel3.stage.phases.AddImplicitOutputAnnotationFile], + Dependency[chisel3.stage.phases.MaybeAspectPhase], + Dependency[chisel3.stage.phases.Convert] ) + } + + phase + .transform(Seq(ChiselCircuitAnnotation(chirrtl))) + .collectFirst { + case FirrtlCircuitAnnotation(a) => a + } + .get + } + /** Return a CHIRRTL string for a Chisel module * @param gen a call-by-name Chisel module */ |
