├── .github ├── CODEOWNERS ├── ISSUE_TEMPLATE │ ├── bug-report.md │ └── feature-request.md ├── PULL_REQUEST_TEMPLATE.md ├── configs │ └── mergify_config.yml └── workflows │ ├── setup-oss-cad-suite │ └── action.yml │ └── test.yml ├── .gitignore ├── .install_verilator.sh ├── .install_yosys.sh ├── .install_z3.sh ├── .mergify.yml ├── .run_formal_checks.sh ├── .scalafmt.conf ├── LICENSE.apache ├── Makefile ├── README.md ├── _config.yml ├── benchmark ├── scripts │ ├── benchmark_cold_compile.py │ ├── find_heap_bound.py │ └── monitor_job.py └── src │ └── main │ └── scala │ └── firrtl │ └── benchmark │ ├── hot │ ├── PassBenchmark.scala │ ├── SerializationBenchmark.scala │ ├── TransformBenchmark.scala │ └── util │ │ └── package.scala │ └── util │ └── package.scala ├── build.sbt ├── build.sc ├── doc └── images │ ├── firrtl_logo.png │ └── firrtl_logo.svg ├── fuzzer └── src │ ├── main │ └── scala │ │ └── firrtl │ │ ├── ExprGen.scala │ │ ├── ExprGenParams.scala │ │ ├── ExprState.scala │ │ ├── FirrtlCompileTests.scala │ │ ├── FirrtlEquivalenceTest.scala │ │ ├── GenMonad.scala │ │ └── StateGen.scala │ └── test │ └── scala │ ├── Example.scala │ └── GenMonad.scala ├── jqf └── src │ └── main │ └── scala │ ├── JQFFuzz.scala │ └── JQFRepro.scala ├── notes ├── alpha.txt ├── annotations │ ├── hello.c │ └── hello.ll ├── architecture.05.05.15.txt ├── chisel-feedback-7.6.15.txt ├── chisel.04.06.15.txt ├── chisel.04.13.15.txt ├── chisel.05.04.15.txt ├── feedbackQA.02.24.15.doc ├── feedbackQA.02.24.15.txt ├── female-node.txt ├── flo.txt ├── frontend-notes.04.16.15.txt ├── initialize-register-explanation.txt ├── memory.txt ├── memory_v2.txt ├── notes.02.13.15.txt ├── notes.02.17.15.txt ├── notes.02.18.15.txt ├── notes.02.23.15.txt ├── notes.03.10.15.txt ├── notes.03.16.15.txt ├── notes.03.18.15.txt ├── primop-inference.txt └── stanza-cheatsheet.txt ├── project ├── build.properties └── plugins.sbt ├── regress ├── AddNot.fir ├── FPU.fir ├── HwachaSequencer.fir ├── ICache.fir ├── Ops.fir ├── Rob.fir └── RocketCore.fir ├── root-doc.txt ├── scripts ├── formal_equiv.sh └── parse_firrtl_transform_log.py ├── src ├── main │ ├── antlr4 │ │ └── FIRRTL.g4 │ ├── proto │ │ └── firrtl.proto │ ├── resources │ │ ├── META-INF │ │ │ └── services │ │ │ │ ├── firrtl.options.RegisteredLibrary │ │ │ │ └── firrtl.options.RegisteredTransform │ │ └── logback.xml │ └── scala │ │ ├── firrtl │ │ ├── AddDescriptionNodes.scala │ │ ├── Compiler.scala │ │ ├── DependencyAPIMigration.scala │ │ ├── EmissionOption.scala │ │ ├── Emitter.scala │ │ ├── FileUtils.scala │ │ ├── FirrtlException.scala │ │ ├── Implicits.scala │ │ ├── LexerHelper.scala │ │ ├── LoweringCompilers.scala │ │ ├── Mappers.scala │ │ ├── Namespace.scala │ │ ├── Parser.scala │ │ ├── PrimOps.scala │ │ ├── RenameMap.scala │ │ ├── Utils.scala │ │ ├── Visitor.scala │ │ ├── WIR.scala │ │ ├── analyses │ │ │ ├── CircuitGraph.scala │ │ │ ├── ConnectionGraph.scala │ │ │ ├── GetNamespace.scala │ │ │ ├── IRLookup.scala │ │ │ ├── InstanceGraph.scala │ │ │ ├── InstanceKeyGraph.scala │ │ │ ├── NodeCount.scala │ │ │ └── SymbolTable.scala │ │ ├── annotations │ │ │ ├── Annotation.scala │ │ │ ├── AnnotationUtils.scala │ │ │ ├── JsonProtocol.scala │ │ │ ├── LoadMemoryAnnotation.scala │ │ │ ├── MemoryInitAnnotation.scala │ │ │ ├── PresetAnnotations.scala │ │ │ ├── Target.scala │ │ │ ├── TargetToken.scala │ │ │ ├── TargetUtils.scala │ │ │ ├── analysis │ │ │ │ └── DuplicationHelper.scala │ │ │ └── transforms │ │ │ │ ├── CleanupNamedTargets.scala │ │ │ │ └── EliminateTargetPaths.scala │ │ ├── backends │ │ │ ├── experimental │ │ │ │ ├── rtlil │ │ │ │ │ └── RtlilEmitter.scala │ │ │ │ └── smt │ │ │ │ │ ├── Btor2Serializer.scala │ │ │ │ │ ├── FirrtlExpressionSemantics.scala │ │ │ │ │ ├── FirrtlToTransitionSystem.scala │ │ │ │ │ ├── SMTCommand.scala │ │ │ │ │ ├── SMTEmitter.scala │ │ │ │ │ ├── SMTExpr.scala │ │ │ │ │ ├── SMTExprMap.scala │ │ │ │ │ ├── SMTExprSerializer.scala │ │ │ │ │ ├── SMTLibSerializer.scala │ │ │ │ │ ├── SMTTransitionSystemEncoder.scala │ │ │ │ │ ├── StutteringClockTransform.scala │ │ │ │ │ ├── TransitionSystem.scala │ │ │ │ │ ├── UninterpretedModuleAnnotation.scala │ │ │ │ │ └── random │ │ │ │ │ ├── DefRandom.scala │ │ │ │ │ ├── InvalidToRandomPass.scala │ │ │ │ │ └── UndefinedMemoryBehaviorPass.scala │ │ │ ├── firrtl │ │ │ │ └── FirrtlEmitter.scala │ │ │ ├── proto │ │ │ │ └── ProtoBufEmitter.scala │ │ │ └── verilog │ │ │ │ ├── LegalizeVerilog.scala │ │ │ │ ├── MinimumVerilogEmitter.scala │ │ │ │ ├── SystemVerilogEmitter.scala │ │ │ │ └── VerilogEmitter.scala │ │ ├── checks │ │ │ └── CheckResets.scala │ │ ├── constraint │ │ │ ├── Constraint.scala │ │ │ ├── ConstraintSolver.scala │ │ │ ├── Inequality.scala │ │ │ ├── IsAdd.scala │ │ │ ├── IsFloor.scala │ │ │ ├── IsKnown.scala │ │ │ ├── IsMax.scala │ │ │ ├── IsMin.scala │ │ │ ├── IsMul.scala │ │ │ ├── IsNeg.scala │ │ │ ├── IsPow.scala │ │ │ └── IsVar.scala │ │ ├── features │ │ │ └── LetterCaseTransform.scala │ │ ├── graph │ │ │ ├── DiGraph.scala │ │ │ ├── EdgeData.scala │ │ │ ├── EulerTour.scala │ │ │ └── RenderDiGraph.scala │ │ ├── ir │ │ │ ├── IR.scala │ │ │ ├── Serializer.scala │ │ │ └── StructuralHash.scala │ │ ├── options │ │ │ ├── DependencyManager.scala │ │ │ ├── Exceptions.scala │ │ │ ├── ExitCodes.scala │ │ │ ├── OptionParser.scala │ │ │ ├── OptionsView.scala │ │ │ ├── Phase.scala │ │ │ ├── Registration.scala │ │ │ ├── Shell.scala │ │ │ ├── Stage.scala │ │ │ ├── StageAnnotations.scala │ │ │ ├── StageOptions.scala │ │ │ ├── StageUtils.scala │ │ │ ├── package.scala │ │ │ └── phases │ │ │ │ ├── AddDefaults.scala │ │ │ │ ├── Checks.scala │ │ │ │ ├── ConvertLegacyAnnotations.scala │ │ │ │ ├── DeletedWrapper.scala │ │ │ │ ├── GetIncludes.scala │ │ │ │ └── WriteOutputAnnotations.scala │ │ ├── package.scala │ │ ├── parser │ │ │ └── Listener.scala │ │ ├── passes │ │ │ ├── CInferMDir.scala │ │ │ ├── CheckChirrtl.scala │ │ │ ├── CheckFlows.scala │ │ │ ├── CheckHighForm.scala │ │ │ ├── CheckInitialization.scala │ │ │ ├── CheckTypes.scala │ │ │ ├── CheckWidths.scala │ │ │ ├── CommonSubexpressionElimination.scala │ │ │ ├── ConvertFixedToSInt.scala │ │ │ ├── ExpandConnects.scala │ │ │ ├── ExpandWhens.scala │ │ │ ├── InferBinaryPoints.scala │ │ │ ├── InferTypes.scala │ │ │ ├── InferWidths.scala │ │ │ ├── Inline.scala │ │ │ ├── LegalizeConnects.scala │ │ │ ├── LowerTypes.scala │ │ │ ├── PadWidths.scala │ │ │ ├── Pass.scala │ │ │ ├── PullMuxes.scala │ │ │ ├── RemoveAccesses.scala │ │ │ ├── RemoveCHIRRTL.scala │ │ │ ├── RemoveEmpty.scala │ │ │ ├── RemoveIntervals.scala │ │ │ ├── RemoveValidIf.scala │ │ │ ├── ReplaceAccesses.scala │ │ │ ├── ResolveFlows.scala │ │ │ ├── ResolveKinds.scala │ │ │ ├── SplitExpressions.scala │ │ │ ├── ToWorkingIR.scala │ │ │ ├── TrimIntervals.scala │ │ │ ├── Uniquify.scala │ │ │ ├── VerilogModulusCleanup.scala │ │ │ ├── VerilogPrep.scala │ │ │ ├── ZeroLengthVecs.scala │ │ │ ├── ZeroWidth.scala │ │ │ ├── clocklist │ │ │ │ ├── ClockList.scala │ │ │ │ ├── ClockListTransform.scala │ │ │ │ ├── ClockListUtils.scala │ │ │ │ └── RemoveAllButClocks.scala │ │ │ ├── memlib │ │ │ │ ├── CreateMemoryAnnotations.scala │ │ │ │ ├── DumpMemoryAnnotations.scala │ │ │ │ ├── InferReadWrite.scala │ │ │ │ ├── MemConf.scala │ │ │ │ ├── MemIR.scala │ │ │ │ ├── MemLibOptions.scala │ │ │ │ ├── MemTransformUtils.scala │ │ │ │ ├── MemUtils.scala │ │ │ │ ├── RenameAnnotatedMemoryPorts.scala │ │ │ │ ├── ReplaceMemMacros.scala │ │ │ │ ├── ReplaceMemTransform.scala │ │ │ │ ├── ResolveMaskGranularity.scala │ │ │ │ ├── ResolveMemoryReference.scala │ │ │ │ ├── SeparateWriteClocks.scala │ │ │ │ ├── SetDefaultReadUnderWrite.scala │ │ │ │ ├── ToMemIR.scala │ │ │ │ ├── VerilogMemDelays.scala │ │ │ │ └── YamlUtils.scala │ │ │ └── wiring │ │ │ │ ├── Wiring.scala │ │ │ │ ├── WiringTransform.scala │ │ │ │ └── WiringUtils.scala │ │ ├── proto │ │ │ ├── FromProto.scala │ │ │ └── ToProto.scala │ │ ├── stage │ │ │ ├── FirrtlAnnotations.scala │ │ │ ├── FirrtlCli.scala │ │ │ ├── FirrtlCompilerTargets.scala │ │ │ ├── FirrtlOptions.scala │ │ │ ├── FirrtlStage.scala │ │ │ ├── FirrtlStageUtils.scala │ │ │ ├── Forms.scala │ │ │ ├── TransformManager.scala │ │ │ ├── package.scala │ │ │ ├── phases │ │ │ │ ├── AddCircuit.scala │ │ │ │ ├── AddDefaults.scala │ │ │ │ ├── AddImplicitEmitter.scala │ │ │ │ ├── AddImplicitOutputFile.scala │ │ │ │ ├── CatchExceptions.scala │ │ │ │ ├── Checks.scala │ │ │ │ ├── Compiler.scala │ │ │ │ ├── ConvertCompilerAnnotations.scala │ │ │ │ └── DriverCompatibility.scala │ │ │ └── transforms │ │ │ │ ├── CatchCustomTransformExceptions.scala │ │ │ │ ├── CheckScalaVersion.scala │ │ │ │ ├── Compiler.scala │ │ │ │ ├── ExpandPrepares.scala │ │ │ │ ├── TrackTransforms.scala │ │ │ │ ├── UpdateAnnotations.scala │ │ │ │ └── WrappedTransform.scala │ │ ├── transforms │ │ │ ├── BlackBoxSourceHelper.scala │ │ │ ├── CheckCombLoops.scala │ │ │ ├── CombineCats.scala │ │ │ ├── ConstantPropagation.scala │ │ │ ├── CustomRadixTransform.scala │ │ │ ├── DeadCodeElimination.scala │ │ │ ├── Dedup.scala │ │ │ ├── DedupAnnotations.scala │ │ │ ├── EnsureNamedStatements.scala │ │ │ ├── FixAddingNegativeLiteralsTransform.scala │ │ │ ├── Flatten.scala │ │ │ ├── FlattenRegUpdate.scala │ │ │ ├── GroupComponents.scala │ │ │ ├── IdentityTransform.scala │ │ │ ├── InferResets.scala │ │ │ ├── InlineAcrossCastsTransform.scala │ │ │ ├── InlineBitExtractions.scala │ │ │ ├── InlineBooleanExpressions.scala │ │ │ ├── LegalizeClocksAndAsyncResets.scala │ │ │ ├── LegalizeReductions.scala │ │ │ ├── ManipulateNames.scala │ │ │ ├── MustDedup.scala │ │ │ ├── OptimizationAnnotations.scala │ │ │ ├── PropagatePresetAnnotations.scala │ │ │ ├── RemoveKeywordCollisions.scala │ │ │ ├── RemoveReset.scala │ │ │ ├── RemoveWires.scala │ │ │ ├── RenameModules.scala │ │ │ ├── ReplaceTruncatingArithmetic.scala │ │ │ ├── SimplifyMems.scala │ │ │ ├── SortModules.scala │ │ │ ├── TopWiring.scala │ │ │ ├── formal │ │ │ │ ├── AssertSubmoduleAssumptions.scala │ │ │ │ ├── ConvertAsserts.scala │ │ │ │ └── RemoveVerificationStatements.scala │ │ │ └── package.scala │ │ ├── traversals │ │ │ └── Foreachers.scala │ │ └── util │ │ │ ├── BackendCompilationUtilities.scala │ │ │ ├── ClassUtils.scala │ │ │ └── TestOptions.scala │ │ ├── logger │ │ ├── Logger.scala │ │ ├── LoggerAnnotations.scala │ │ ├── LoggerOptions.scala │ │ ├── package.scala │ │ └── phases │ │ │ ├── AddDefaults.scala │ │ │ └── Checks.scala │ │ └── tutorial │ │ ├── lesson1-circuit-traversal │ │ └── AnalyzeCircuit.scala │ │ └── lesson2-ir-fields │ │ └── AnalyzeCircuit.scala └── test │ ├── resources │ ├── META-INF │ │ └── services │ │ │ ├── firrtl.options.RegisteredLibrary │ │ │ └── firrtl.options.RegisteredTransform │ ├── annotations │ │ └── SampleAnnotations.anno.json │ ├── blackboxes │ │ ├── AdderExtModule.v │ │ ├── LargeParam.v │ │ ├── LargeParamTester.fir │ │ ├── MultiExtModuleTester.fir │ │ ├── ParameterizedExtModule.v │ │ ├── ParameterizedExtModuleTester.fir │ │ ├── ParameterizedViaHeaderAdderExtModule.v │ │ ├── RenamedExtModuleTester.fir │ │ ├── SimpleExtModule.v │ │ ├── SimpleExtModuleTester.fir │ │ └── VerilogHeaderFile.vh │ ├── features │ │ ├── AsyncResetTester.fir │ │ ├── ChirrtlMems.fir │ │ ├── CustomTransform.fir │ │ ├── EmptyChirrtlMem.fir │ │ ├── HasDeadCode.fir │ │ ├── HasLoops.fir │ │ ├── NestedSubAccessTester.fir │ │ ├── NodeType.fir │ │ ├── PresetTester.fir │ │ ├── Printf.fir │ │ ├── ZeroPortMem.fir │ │ └── ZeroWidthMem.fir │ ├── firrtl │ │ └── testTop.cpp │ ├── integration │ ├── passes │ │ ├── ExpandWhens │ │ │ └── ExpandWhens.fir │ │ └── Legalize │ │ │ └── Legalize.fir │ ├── regress │ └── rtlil_equiv_check │ │ ├── CanTop.fir │ │ └── RotationCordic.fir │ └── scala │ ├── firrtl │ ├── JsonProtocolSpec.scala │ ├── RenameMapPrivateSpec.scala │ ├── analysis │ │ └── SymbolTableSpec.scala │ ├── backends │ │ └── experimental │ │ │ ├── rtlil │ │ │ └── end2end │ │ │ │ ├── RtlilCompilationTest.scala │ │ │ │ └── RtlilEquivalenceTest.scala │ │ │ └── smt │ │ │ ├── Btor2Spec.scala │ │ │ ├── FirrtlExpressionSemanticsSpec.scala │ │ │ ├── FirrtlModuleToTransitionSystemSpec.scala │ │ │ ├── FirrtlToTransitionSystemPassSpec.scala │ │ │ ├── SMTBackendHelpers.scala │ │ │ ├── SMTLibSpec.scala │ │ │ ├── end2end │ │ │ ├── AssertAssumeStopSpec.scala │ │ │ ├── AsyncResetSpec.scala │ │ │ ├── EndToEndSMTSpec.scala │ │ │ ├── MemorySpec.scala │ │ │ ├── RequiresZ3.scala │ │ │ ├── SMTCompilationTest.scala │ │ │ ├── UndefinedFirrtlSpec.scala │ │ │ └── UninterpretedModulesSpec.scala │ │ │ └── random │ │ │ ├── InvalidToRandomSpec.scala │ │ │ └── UndefinedMemoryBehaviorSpec.scala │ ├── ir │ │ └── StructuralHashSpec.scala │ ├── passes │ │ └── LowerTypesSpec.scala │ ├── stage │ │ ├── CurrentFirrtlStateAnnotationSpec.scala │ │ └── phases │ │ │ └── tests │ │ │ ├── ConvertCompilerAnnotationsSpec.scala │ │ │ └── DriverCompatibilitySpec.scala │ ├── testutils │ │ ├── FirrtlSpec.scala │ │ ├── LeanTransformSpec.scala │ │ └── PassTests.scala │ └── transforms │ │ └── EnsureNamedStatementsSpec.scala │ ├── firrtlTests │ ├── AnnotationTests.scala │ ├── AsyncResetSpec.scala │ ├── AttachSpec.scala │ ├── CInferMDirSpec.scala │ ├── CheckCombLoopsSpec.scala │ ├── CheckInitializationSpec.scala │ ├── CheckSpec.scala │ ├── ChirrtlMemSpec.scala │ ├── ChirrtlSpec.scala │ ├── ClockListTests.scala │ ├── CompilerTests.scala │ ├── CompilerUtilsSpec.scala │ ├── ConstantPropagationTests.scala │ ├── CustomTransformSpec.scala │ ├── DCETests.scala │ ├── ExpandWhensSpec.scala │ ├── ExtModuleSpec.scala │ ├── ExtModuleTests.scala │ ├── FeatureSpec.scala │ ├── FileUtilsSpec.scala │ ├── FlattenTests.scala │ ├── InferReadWriteSpec.scala │ ├── InferResetsSpec.scala │ ├── InfoSpec.scala │ ├── InlineAcrossCastsSpec.scala │ ├── InlineBooleanExpressionsSpec.scala │ ├── InlineInstancesTests.scala │ ├── IntegrationSpec.scala │ ├── LegalizeSpec.scala │ ├── LoFirrtlOptimizedEmitterTests.scala │ ├── LowerTypesSpec.scala │ ├── MemEnFeedbackSpec.scala │ ├── MemLatencySpec.scala │ ├── MemSpec.scala │ ├── MemoryInitSpec.scala │ ├── MultiThreadingSpec.scala │ ├── MutableRenameMapSpec.scala │ ├── NamespaceSpec.scala │ ├── NegSpec.scala │ ├── PadWidthsTests.scala │ ├── ParserSpec.scala │ ├── PresetRegAnnotationSpec.scala │ ├── PresetSpec.scala │ ├── ProtoBufSpec.scala │ ├── RegisterUpdateSpec.scala │ ├── RemoveWiresSpec.scala │ ├── ReplSeqMemTests.scala │ ├── ReplaceAccessesSpec.scala │ ├── ReplaceTruncatingArithmeticSpec.scala │ ├── SeparateWriteClocksSpec.scala │ ├── SerializerSpec.scala │ ├── SimplifyMemsSpec.scala │ ├── StringSpec.scala │ ├── UniquifySpec.scala │ ├── UnitTests.scala │ ├── UtilsSpec.scala │ ├── VerilogEmitterTests.scala │ ├── VerilogEquivalenceSpec.scala │ ├── VerilogMemDelaySpec.scala │ ├── WidthSpec.scala │ ├── WiringTests.scala │ ├── ZeroLengthVecsSpec.scala │ ├── ZeroWidthTests.scala │ ├── analyses │ │ ├── CircuitGraphSpec.scala │ │ ├── ConnectionGraphSpec.scala │ │ ├── IRLookupSpec.scala │ │ ├── InstanceGraphTests.scala │ │ └── InstanceKeyGraphSpec.scala │ ├── annotationTests │ │ ├── AnnotationSpec.scala │ │ ├── CleanupNamedTargetsSpec.scala │ │ ├── EliminateTargetPathsSpec.scala │ │ ├── JsonProtocolSpec.scala │ │ ├── LoadMemoryAnnotationSpec.scala │ │ ├── MorphismSpec.scala │ │ ├── TargetDirAnnotationSpec.scala │ │ ├── TargetSpec.scala │ │ ├── TargetUtilsSpec.scala │ │ └── UnrecognizedAnnotationSpec.scala │ ├── constraint │ │ └── InequalitySpec.scala │ ├── execution │ │ ├── ExecutionTestHelper.scala │ │ ├── ParserHelpers.scala │ │ ├── SimpleExecutionTest.scala │ │ └── VerilogExecution.scala │ ├── features │ │ └── LetterCaseTransformSpec.scala │ ├── fixed │ │ ├── FixedPointMathSpec.scala │ │ ├── FixedSerializationSpec.scala │ │ ├── FixedTypeInferenceSpec.scala │ │ └── RemoveFixedTypeSpec.scala │ ├── formal │ │ ├── AssertSubmoduleAssumptionsSpec.scala │ │ ├── ConvertAssertsSpec.scala │ │ ├── RemoveVerificationStatementsSpec.scala │ │ └── VerificationSpec.scala │ ├── graph │ │ ├── DiGraphTests.scala │ │ └── EulerTourTests.scala │ ├── interval │ │ ├── IntervalMathSpec.scala │ │ └── IntervalSpec.scala │ ├── options │ │ ├── OptionParserSpec.scala │ │ ├── OptionsViewSpec.scala │ │ ├── PhaseManagerSpec.scala │ │ ├── RegistrationSpec.scala │ │ ├── ShellSpec.scala │ │ └── phases │ │ │ ├── AddDefaultsSpec.scala │ │ │ ├── ChecksSpec.scala │ │ │ ├── GetIncludesSpec.scala │ │ │ └── WriteOutputAnnotationsSpec.scala │ ├── passes │ │ ├── InferTypesFlowsAndKindsSpec.scala │ │ └── RemoveAccessesSpec.scala │ ├── stage │ │ ├── FirrtlCliSpec.scala │ │ ├── FirrtlMainSpec.scala │ │ ├── FirrtlOptionsViewSpec.scala │ │ └── phases │ │ │ ├── AddCircuitSpec.scala │ │ │ ├── AddDefaultsSpec.scala │ │ │ ├── AddImplicitEmitterSpec.scala │ │ │ ├── AddImplicitOutputFileSpec.scala │ │ │ ├── ChecksSpec.scala │ │ │ └── CompilerSpec.scala │ └── transforms │ │ ├── BlackBoxSourceHelperSpec.scala │ │ ├── CombineCatsSpec.scala │ │ ├── CustomRadixTransformSpec.scala │ │ ├── DedupTests.scala │ │ ├── GroupComponentsSpec.scala │ │ ├── InferWidthsWithAnnosSpec.scala │ │ ├── LegalizeClocksAndAsyncResets.scala │ │ ├── LegalizeReductions.scala │ │ ├── ManipulateNamesSpec.scala │ │ ├── MustDedupSpec.scala │ │ ├── RemoveResetSpec.scala │ │ ├── SortModulesSpec.scala │ │ └── TopWiringTest.scala │ └── loggertests │ └── LoggerSpec.scala ├── test └── integration │ ├── GCDTester.fir │ ├── GCDTester.pb │ ├── MemTester.fir │ ├── PipeTester.fir │ └── RightShiftTester.fir └── utils └── bin ├── firrtl └── firrtl-profiling /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @freechipsproject/firrtl-reviewers 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug-report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug Report 3 | about: Report a problem you experienced with FIRRTL 4 | labels: improvement=BugFix 5 | --- 6 | 7 | ### Checklist 8 | 9 | - [ ] Did you specify the current behavior? 10 | - [ ] Did you specify the expected behavior? 11 | - [ ] Did you provide a code example showing the problem? 12 | - [ ] Did you describe your environment? 13 | - [ ] Did you specify relevant external information? 14 | 15 | ### What is the current behavior? 16 | 17 | ### What is the expected behavior? 18 | 19 | ### Steps to Reproduce 20 | 21 | 22 | 23 | 24 | 25 | ### Your environment 26 | 27 | 28 | 29 | - Chisel Verions: 30 | - OS: 31 | - Verilator version: 32 | 33 | ### External Information 34 | 35 | 36 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature-request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature Request 3 | about: Request a new feature to be added to FIRRTL 4 | --- 5 | 6 | ### Checklist 7 | 8 | - [ ] Did you write out a description of the feature you want to see? 9 | - [ ] Did you look around for any related features? 10 | - [ ] Did you specify relevant external information? 11 | 12 | ### Feature Description 13 | 14 | 15 | 16 | ### Type of Feature 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | ### Related Features 27 | 28 | 29 | 30 | ### External Information 31 | 32 | 33 | -------------------------------------------------------------------------------- /.github/configs/mergify_config.yml: -------------------------------------------------------------------------------- 1 | # Configuration for generating .mergify.yml 2 | conditions: 3 | - status-success=all tests passed 4 | branches: 5 | - 1.3.x 6 | - 1.4.x 7 | - 1.5.x 8 | -------------------------------------------------------------------------------- /.github/workflows/setup-oss-cad-suite/action.yml: -------------------------------------------------------------------------------- 1 | name: Setup OSS CAD Suite 2 | 3 | runs: 4 | using: composite 5 | steps: 6 | - name: Install Tabby OSS Cad Suite 7 | shell: bash 8 | env: 9 | VERSION: 2021-11-09 10 | run: | 11 | ARTIFACT=oss-cad-suite-linux-x64-$(echo $VERSION | tr -d '-') 12 | wget -q -O - https://github.com/YosysHQ/oss-cad-suite-build/releases/download/${VERSION}/${ARTIFACT}.tgz | tar -zx 13 | echo "$(pwd)/oss-cad-suite/bin" >> $GITHUB_PATH 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_STORE 2 | */*.DS_STORE 3 | */*/*.DS_STORE 4 | */*/*/*.DS_STORE 5 | */*/*/*/*.DS_STORE 6 | *.tmp 7 | */*.temp 8 | */*/*.temp 9 | */*/*/*.temp 10 | *.swp 11 | */*.swp 12 | */*/*.swp 13 | */*/*/*.swp 14 | */*.flo 15 | */*.v 16 | */*.out 17 | */*/*.flo 18 | */*/*.v 19 | */*/*.out 20 | */*/Output 21 | */*/*/*.flo 22 | */*/*/*.v 23 | */*/*/*.out 24 | */*/*/Output 25 | src/lib/stanzam 26 | src/lib/stanza 27 | src/*/__MACOSX 28 | src/main/stanza/firrtl-main 29 | utils/bin/firrtl 30 | utils/bin/stanza 31 | utils/bin/firrtl-scala 32 | utils/bin/firrtl-stanza 33 | utils/bin/firrtl.jar 34 | utils/bin/firrtl-test.jar 35 | utils/bin/FileCheck 36 | spec/spec.aux 37 | spec/spec.log 38 | spec/spec.toc 39 | spec/spec.out 40 | spec/spec.synctex.gz 41 | notes/*.docx 42 | test_run_dir 43 | __pycache__ 44 | 45 | .project 46 | 47 | # sbt specific 48 | .cache 49 | .history 50 | .lib/ 51 | dist/* 52 | target/ 53 | lib_managed/ 54 | src_managed/ 55 | project/boot/ 56 | project/plugins/project/ 57 | .idea/ 58 | .idea_modules/ 59 | gen/ 60 | project/project/ 61 | /bin/ 62 | out/ 63 | .bloop 64 | .metals 65 | .bsp 66 | project/metals.sbt 67 | 68 | *~ 69 | *#*# 70 | .vscode 71 | -------------------------------------------------------------------------------- /.install_verilator.sh: -------------------------------------------------------------------------------- 1 | set -e 2 | # Install Verilator (http://www.veripool.org/projects/verilator/wiki/Installing) 3 | if [ ! -f $INSTALL_DIR/bin/verilator ]; then 4 | mkdir -p $INSTALL_DIR 5 | git clone https://github.com/verilator/verilator.git 6 | unset VERILATOR_ROOT 7 | cd verilator 8 | git pull 9 | git checkout v3.922 10 | autoconf 11 | ./configure --prefix=$INSTALL_DIR 12 | make 13 | make install 14 | export VERILATOR_ROOT=$INSTALL_DIR 15 | # Fix verilator for local install (http://www.lowrisc.org/docs/untether-v0.2/verilator/) 16 | ln -s $VERILATOR_ROOT/share/verilator/include $VERILATOR_ROOT/include 17 | ln -s $VERILATOR_ROOT/share/verilator/bin/verilator_includer $VERILATOR_ROOT/bin/verilator_includer 18 | fi 19 | -------------------------------------------------------------------------------- /.install_yosys.sh: -------------------------------------------------------------------------------- 1 | set -e 2 | # Install Yosys (https://github.com/cliffordwolf/yosys) 3 | if [ ! -f $INSTALL_DIR/bin/yosys ]; then 4 | mkdir -p $INSTALL_DIR 5 | git clone https://github.com/cliffordwolf/yosys.git 6 | cd yosys 7 | git pull 8 | git checkout yosys-0.8 9 | make 10 | make PREFIX=$INSTALL_DIR install 11 | fi 12 | -------------------------------------------------------------------------------- /.install_z3.sh: -------------------------------------------------------------------------------- 1 | set -e 2 | # Install Z3 (https://github.com/Z3Prover/z3) 3 | if [ ! -f $INSTALL_DIR/bin/z3 ]; then 4 | mkdir -p $INSTALL_DIR 5 | # download prebuilt binary 6 | wget https://github.com/Z3Prover/z3/releases/download/z3-4.8.8/z3-4.8.8-x64-ubuntu-16.04.zip 7 | unzip z3-4.8.8-x64-ubuntu-16.04.zip 8 | mv ./z3-4.8.8-x64-ubuntu-16.04/bin/z3 $INSTALL_DIR/bin/z3 9 | fi 10 | -------------------------------------------------------------------------------- /.run_formal_checks.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # SPDX-License-Identifier: Apache-2.0 4 | 5 | set -e 6 | 7 | if [ $# -ne 1 ]; then 8 | echo "There must be exactly one argument!" 9 | exit -1 10 | fi 11 | 12 | DUT=$1 13 | 14 | # See https://docs.github.com/en/actions/reference/environment-variables 15 | # for info about these variables 16 | 17 | # Run formal check only for PRs, GITHUB_BASE_REF is only set for PRs 18 | if [ ! -z "$GITHUB_BASE_REF" ]; then 19 | # Github Actions does a shallow clone, checkout PR target so that we have it 20 | # Then return to previous branch so HEAD points to the commit we're testing 21 | git remote set-branches origin $GITHUB_BASE_REF && git fetch 22 | git checkout $GITHUB_BASE_REF 23 | git checkout - 24 | cp regress/$DUT.fir $DUT.fir 25 | ./scripts/formal_equiv.sh HEAD $GITHUB_BASE_REF $DUT 26 | else 27 | echo "Not a pull request, no formal check" 28 | exit 0 29 | fi 30 | -------------------------------------------------------------------------------- /.scalafmt.conf: -------------------------------------------------------------------------------- 1 | version = 2.6.4 2 | 3 | maxColumn = 120 4 | align = most 5 | continuationIndent.defnSite = 2 6 | assumeStandardLibraryStripMargin = true 7 | docstrings = ScalaDoc 8 | lineEndings = preserve 9 | includeCurlyBraceInSelectChains = false 10 | danglingParentheses = true 11 | 12 | align.tokens.add = [ 13 | { 14 | code = ":" 15 | } 16 | ] 17 | 18 | newlines.alwaysBeforeCurlyBraceLambdaParams = false 19 | newlines.alwaysBeforeMultilineDef = false 20 | newlines.implicitParamListModifierForce = [before] 21 | 22 | verticalMultiline.atDefnSite = true 23 | 24 | optIn.annotationNewlines = true 25 | 26 | rewrite.rules = [SortImports, PreferCurlyFors, AvoidInfix] 27 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | root_dir ?= $(PWD) 2 | regress_dir ?= $(root_dir)/regress 3 | install_dir ?= $(root_dir)/utils/bin 4 | 5 | SBT ?= sbt 6 | SBT_FLAGS ?= -Dsbt.log.noformat=true 7 | 8 | scala_jar ?= $(install_dir)/firrtl.jar 9 | scala_src := $(shell find src -type f \( -name "*.scala" -o -path "*/resources/*" \)) 10 | 11 | build: build-scala 12 | 13 | clean: 14 | $(MAKE) -C $(root_dir)/spec clean 15 | rm -f $(install_dir)/firrtl.jar 16 | $(SBT) "clean" 17 | 18 | .PHONY : specification 19 | specification: 20 | $(MAKE) -C $(root_dir)/spec all 21 | 22 | regress: $(scala_jar) 23 | cd $(regress_dir) && $(install_dir)/firrtl -i rocket.fir -o rocket.v -X verilog 24 | 25 | # Scala Added Makefile commands 26 | 27 | build-scala: $(scala_jar) 28 | 29 | $(scala_jar): $(scala_src) 30 | $(SBT) "assembly" 31 | 32 | test-scala: 33 | $(SBT) test 34 | 35 | jenkins-build: clean 36 | $(SBT) $(SBT_FLAGS) +clean +test +publish-local 37 | $(SBT) $(SBT_FLAGS) coverageReport 38 | 39 | .PHONY: build clean regress build-scala test-scala 40 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-minimal -------------------------------------------------------------------------------- /benchmark/src/main/scala/firrtl/benchmark/hot/PassBenchmark.scala: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | package firrtl 3 | package benchmark 4 | package hot 5 | 6 | import firrtl.passes._ 7 | import firrtl.stage.TransformManager 8 | 9 | import firrtl.benchmark.util._ 10 | 11 | abstract class PassBenchmark(passFactory: () => Pass) extends App { 12 | val inputFile = args(0) 13 | val warmup = args(1).toInt 14 | val runs = args(2).toInt 15 | 16 | val input = filenameToCircuit(inputFile) 17 | val inputState = CircuitState(input, ChirrtlForm) 18 | 19 | val manager = new TransformManager(passFactory().prerequisites) 20 | val preState = manager.execute(inputState) 21 | 22 | hot.util.benchmark(warmup, runs)(passFactory().run(preState.circuit)) 23 | } 24 | 25 | object ResolveKindsBenchmark extends PassBenchmark(() => ResolveKinds) 26 | 27 | object CheckHighFormBenchmark extends PassBenchmark(() => CheckHighForm) 28 | 29 | object CheckWidthsBenchmark extends PassBenchmark(() => CheckWidths) 30 | 31 | object InferBinaryPointsBenchmark extends PassBenchmark(() => new InferBinaryPoints) 32 | -------------------------------------------------------------------------------- /benchmark/src/main/scala/firrtl/benchmark/hot/SerializationBenchmark.scala: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | package firrtl.benchmark.hot 3 | 4 | import firrtl.benchmark.util._ 5 | import firrtl.ir.Serializer 6 | 7 | object SerializationBenchmark extends App { 8 | val inputFile = args(0) 9 | val warmup = args(1).toInt 10 | val runs = args(2).toInt 11 | val select = if(args.length > 3) args(3) else "o" 12 | 13 | val input = filenameToCircuit(inputFile) 14 | 15 | if(select == "n") { 16 | println("Benchmarking new Serializer.serialize") 17 | firrtl.benchmark.hot.util.benchmark(warmup, runs)(Serializer.serialize(input)) 18 | } else if(select == "o") { 19 | println("Benchmarking legacy serialization") 20 | firrtl.benchmark.hot.util.benchmark(warmup, runs)(input.serialize) 21 | } else if(select.startsWith("test")) { 22 | println("Testing the new serialization against the old one") 23 | val o = input.serialize.split('\n').filterNot(_.trim.isEmpty) 24 | val n = Serializer.serialize(input).split('\n').filterNot(_.trim.isEmpty) 25 | val silent = select.endsWith("silent") 26 | 27 | println(s"Old lines: ${o.length}") 28 | println(s"New lines: ${n.length}") 29 | o.zip(n).zipWithIndex.foreach { case ((ol, nl), ii) => 30 | if(ol != nl) { 31 | println(s"❌@$ii OLD: |$ol|") 32 | println(s"❌@$ii NEW: |$nl|") 33 | throw new RuntimeException() 34 | } else if(!silent) { 35 | println(s"✅ |$ol") 36 | } 37 | } 38 | 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /benchmark/src/main/scala/firrtl/benchmark/hot/TransformBenchmark.scala: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | package firrtl 3 | package benchmark 4 | package hot 5 | 6 | import firrtl._ 7 | import firrtl.passes.LowerTypes 8 | import firrtl.stage.TransformManager 9 | import firrtl.benchmark.util._ 10 | import firrtl.transforms.DedupModules 11 | 12 | abstract class TransformBenchmark(factory: () => Transform) extends App { 13 | val inputFile = args(0) 14 | val warmup = args(1).toInt 15 | val runs = args(2).toInt 16 | 17 | val input = filenameToCircuit(inputFile) 18 | val inputState = CircuitState(input, ChirrtlForm) 19 | 20 | val manager = new TransformManager(factory().prerequisites) 21 | val preState = manager.execute(inputState) 22 | 23 | hot.util.benchmark(warmup, runs)(factory().transform(preState)) 24 | } 25 | 26 | object LowerTypesBenchmark extends TransformBenchmark(() => LowerTypes) 27 | 28 | object DedupBenchmark extends TransformBenchmark(() => new DedupModules()) -------------------------------------------------------------------------------- /benchmark/src/main/scala/firrtl/benchmark/hot/util/package.scala: -------------------------------------------------------------------------------- 1 | 2 | package firrtl.benchmark.hot 3 | 4 | import firrtl.Utils.time 5 | import firrtl.benchmark.util._ 6 | 7 | package object util { 8 | def benchmark(nWarmup: Int, nRun: Int)(f: => Unit): Unit = { 9 | // Warmup 10 | for (i <- 0 until nWarmup) { 11 | val (t, res) = time(f) 12 | println(f"Warmup run $i took $t%.1f ms") 13 | } 14 | 15 | // Benchmark 16 | val times: Array[Double] = Array.fill(nRun)(0.0) 17 | for (i <- 0 until nRun) { 18 | System.gc 19 | val (t, res) = time(f) 20 | times(i) = t 21 | println(f"Benchmark run $i took $t%.1f ms") 22 | } 23 | 24 | println(f"Mean: ${mean(times)}%.1f ms") 25 | println(f"Median: ${median(times)}%.1f ms") 26 | println(f"Stddev: ${stdDev(times)}%.1f ms") 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /benchmark/src/main/scala/firrtl/benchmark/util/package.scala: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package firrtl 4 | package benchmark 5 | 6 | import firrtl.ir.Circuit 7 | import scala.util.control.NonFatal 8 | 9 | package object util { 10 | def filenameToCircuit(filename: String): Circuit = try { 11 | proto.FromProto.fromFile(filename) 12 | } catch { 13 | case NonFatal(_) => Parser.parseFile(filename, Parser.IgnoreInfo) 14 | } 15 | 16 | def mean(xs: Iterable[Double]): Double = xs.sum / xs.size 17 | 18 | def median(xs: Iterable[Double]): Double = { 19 | val size = xs.size 20 | val sorted = xs.toSeq.sorted 21 | if (size % 2 == 1) sorted(size / 2) 22 | else { 23 | val a = sorted(size / 2) 24 | val b = sorted((size / 2) - 1) 25 | (a + b) / 2 26 | } 27 | } 28 | 29 | def variance(xs: Iterable[Double]): Double = { 30 | val avg = mean(xs) 31 | xs.map(a => math.pow(a - avg, 2)).sum / xs.size 32 | } 33 | 34 | def stdDev(xs: Iterable[Double]): Double = math.sqrt(variance(xs)) 35 | } 36 | -------------------------------------------------------------------------------- /doc/images/firrtl_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chipsalliance/firrtl/64731bbb16142a2b09ccbe74ab41b76b7a265869/doc/images/firrtl_logo.png -------------------------------------------------------------------------------- /fuzzer/src/main/scala/firrtl/ExprState.scala: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package firrtl.fuzzer 4 | 5 | import firrtl.ir.{Expression, Reference, Type} 6 | 7 | import scala.language.higherKinds 8 | 9 | /** A typeclass for types that represent the state of a random expression generator 10 | */ 11 | trait ExprState[State] { 12 | 13 | /** Creates a [[StateGen]] that adds a reference to the input state and returns that reference 14 | */ 15 | def withRef[Gen[_]: GenMonad](ref: Reference): StateGen[State, Gen, Reference] 16 | 17 | /** Creates a [[StateGen]] that returns an [[firrtl.ir.Expression Expression]] with the specified type 18 | */ 19 | def exprGen[Gen[_]: GenMonad](tpe: Type): StateGen[State, Gen, Expression] 20 | 21 | /** Gets the set of unbound references 22 | */ 23 | def unboundRefs(s: State): Set[Reference] 24 | 25 | /** Gets the maximum allowed width of any Expression 26 | */ 27 | def maxWidth(s: State): Int 28 | } 29 | 30 | object ExprState { 31 | def apply[S: ExprState] = implicitly[ExprState[S]] 32 | } 33 | -------------------------------------------------------------------------------- /fuzzer/src/test/scala/GenMonad.scala: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Apache-2.0 2 | 3 | package firrtl.fuzzer 4 | 5 | import org.scalacheck.{Gen, Properties} 6 | 7 | object ScalaCheckGenMonad { 8 | implicit def scalaCheckGenMonadInstance: GenMonad[Gen] = new GenMonad[Gen] { 9 | def flatMap[A, B](a: Gen[A])(f: A => Gen[B]): Gen[B] = a.flatMap(f) 10 | 11 | def map[A, B](a: Gen[A])(f: A => B): Gen[B] = a.map(f) 12 | 13 | def choose(min: Int, max: Int): Gen[Int] = Gen.choose(min, max) 14 | 15 | def oneOf[A](items: A*): Gen[A] = Gen.oneOf(items) 16 | 17 | def const[A](c: A): Gen[A] = Gen.const(c) 18 | 19 | def widen[A, B >: A](ga: Gen[A]): Gen[B] = ga 20 | 21 | def generate[A](ga: Gen[A]): A = ga.sample.get 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /notes/alpha.txt: -------------------------------------------------------------------------------- 1 | ========= RENAME STRATEGY ========= 2 | Special chars ~!@#$%^*-_+=?/ get renamed to _XX, where XX is a hex representation of the symbol 3 | 4 | a_x 5 | => 6 | a_XXx 7 | 8 | a_XXx 9 | => 10 | a_XXXXx 11 | 12 | This guarantees all symbols use a subset of the character set 13 | 14 | Now, I need to rename duplicate symbols, so: 15 | 16 | wire x 17 | when p 18 | wire x 19 | 20 | => 21 | 22 | wire x%0 23 | when p 24 | wire x%1 25 | 26 | We know that all new symbols are unique because they use a special character 27 | At this point, all names are unique. 28 | 29 | -- Bundle Expansion -- 30 | To deal with bundle expansion, use another different special character: 31 | 32 | wire x : {a,b} 33 | 34 | => 35 | 36 | wire x#a 37 | wire x#b 38 | 39 | -- Vector Expansion -- 40 | 41 | To deal with bundle expansion, use another different special character: 42 | 43 | wire x : UInt<1>[3] 44 | 45 | => 46 | 47 | wire x$0 : UInt<1> 48 | wire x$1 : UInt<1> 49 | wire x$2 : UInt<1> 50 | 51 | -- Creating Temporaries -- 52 | To deal with creating temporaries, use another different special character: 53 | 54 | node x = a + b * c 55 | => 56 | node x!0 = b * c 57 | node x!1 = a + x!0 58 | node x = x!1 59 | 60 | Finally, to deal with backends that only use subsets of the special characters, do another rename step to remove special characters (must remove $ again!) 61 | 62 | ASCII Hex 63 | _ 5F __ 64 | ~ 7E _A 65 | ! 21 _B 66 | @ 40 _C 67 | # 23 _D 68 | $ 24 _E 69 | % 25 _F 70 | ^ 5E _G 71 | * 2A _H 72 | - 2D _I 73 | + 2B _J 74 | = 3D _K 75 | ? 3F _L 76 | / 2F _M 77 | 78 | -------------------------------------------------------------------------------- /notes/annotations/hello.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main (int a) { 4 | for( int i = 0; i < a; i++) { 5 | return printf("Hello World\n"); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /notes/annotations/hello.ll: -------------------------------------------------------------------------------- 1 | ; ModuleID = 'hello.c' 2 | target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" 3 | target triple = "x86_64-apple-macosx10.9.0" 4 | 5 | @.str = private unnamed_addr constant [13 x i8] c"Hello World\0A\00", align 1 6 | 7 | ; Function Attrs: nounwind ssp uwtable 8 | define i32 @main(i32 %a) #0 { 9 | %1 = icmp sgt i32 %a, 0 10 | br i1 %1, label %2, label %4 11 | 12 | ;