aboutsummaryrefslogtreecommitdiff
path: root/src/main
AgeCommit message (Collapse)Author
2019-09-12update inline transform and testcasesAbert Chen
2019-09-06Refactor: remove redundancy code (#1166)Leway Colin
* Refactor: remove redundancy code * Fixed coding style
2019-09-05Filter out more filename extensions for blackbox source headers (#1134)Albert Magyar
2019-08-27Add StageErrorSchuyler Eldridge
This adds the StageError Error. This Error indicates that a Stage/Phase has hit an unrecoverable error, it cannot continue, and requests that the entire Stage/Phase hierarchy be killed with an ExitFailure ExitCode. StageMain is modified to catch StageError and exit the application with the provided exit code number. Signed-off-by: Schuyler Eldridge <schuyler.eldridge@ibm.com>
2019-08-27Add firrtl.options.ExitCode type hierarchySchuyler Eldridge
Signed-off-by: Schuyler Eldridge <schuyler.eldridge@ibm.com>
2019-08-20Remove incorrect short option for --info-modeSchuyler Eldridge
This should be a helpValueName and not a shortOption. Signed-off-by: Schuyler Eldridge <schuyler.eldridge@ibm.com>
2019-08-19Refactor exceptions to remove stack trace from user errors (#1157)Jack Koenig
2019-08-13Infer reset (#1068)Jack Koenig
* Add abstract "Reset" which can be inferred to AsyncReset or UInt<1> * Enhance async reset initial value literal check to support aggregates
2019-08-09Remove unused CheckHighFormLike.IllegalChirrtlMemException (#1151)Albert Magyar
2019-08-07Improve RemoveReset handling of invalid initsSchuyler Eldridge
This modifies RemoveReset to NOT generate a mux for invalid (IsInvalid) inits. In the case of an invalid init, the reset is converted to a self-connect and no mux is generated. This is implemented as a new, initial pass over the module to populate a set of all invalid signals. During the subsequent, circuit-modifying pass, this invalid set is queried to special case the handling of invalid inits. Signed-off-by: Schuyler Eldridge <schuyler.eldridge@ibm.com>
2019-08-07Check mems for legal latencies; ban zero write latency. (#1147)Albert Magyar
* Check mems for legal latencies; ban zero write latency. * Trigger
2019-08-07DRY check chirrtl (#1148)Albert Magyar
* Avoid redundancy between CheckChirrtl and CheckHighForm, add more checks * Add test case for illegal Chirrtl memory in HighForm
2019-08-05Iterate 1x in FileUtils.getText, DRY out getTextSchuyler Eldridge
Signed-off-by: Schuyler Eldridge <schuyler.eldridge@ibm.com>
2019-08-01Followup to PR #1142chick
- use scala.io.Source instead of io.Source - .toList cleaner way to force stream to be read. - clear old commented out code in ProtoBufSpec
2019-08-01Followup to PR #1142chick
Fixes a threading bug in where lazy reading of file caused a problem for multithreaded access to the that was read. Changes all uses of io.Source to use new API getText getLines getTextResource getLinesResouce Make style to only import FileUtils and not its methods So code is more explicit as e.g. FileUtils.getText()
2019-07-31io.Source is not closed when used in most common text reading idiom (#1142)Chick Markley
- Provide new tools for reading in text - from a file - from a string file name - from a resource file - text can be read in as - a single string with newlines - a seq of strings, one string per line - FileUtils put in its own file - in same package to keep existing API the same Hopefully this will protect users from creating resource leaks that may explain sbt crashing. Also simpler interface should make code more streamlined, existing uses of io.Source seem often to be converting between text and seq unnecessarily. Add note of caution on requiring slash on resource readers
2019-07-30Fix "since" deprecation, should be "1.2" not "1.3" (#1139)Schuyler Eldridge
- Fixes BlackBoxSourceHelper deprecation "since"
2019-07-25Implement MultiTargetAnnotation (#1109)Sequencer
* add multi target annotation for advices * use Seq[Seq[Target]] store targets * add flat function * doc simplify
2019-07-25Allow name of blackbox resource .f file to change from static value (#1129)Albert Magyar
* Allow name of blackbox resource .f file to change from static value * Restore fileListName as a deprecated def per Jack's feedback * Support both local and absolute paths for .f resource files
2019-07-24Add ExpandConnects to TopWiringTransform fixup (#1135)Schuyler Eldridge
This fixes a bug in the TopWiringTransform when wiring aggregates by adding ExpandConnects to its list of fixup passes. TopWiringTransform is MidForm => MidForm, but when wiring aggregates, it will output bulk connects. This violates the MidForm prerequisite that ExpandConnects has run. Symptomatically, this will manifest as match errors in LowerTypes if a user tries to use the TopWiringTransform on aggregates. Signed-off-by: Schuyler Eldridge <schuyler.eldridge@ibm.com>
2019-07-23more constprop on muxes (#1052)Donggyu Kim
2019-07-21Fix RenameMap chaining (#1126)Albert Chen
* fix RenameMap chaining * fix order of chaining, add another test case
2019-07-19Add SimplifyMems transform to lower memories without splitting (#1111)Albert Magyar
* Add SimplifyMems transform to lower memories without splitting * Remove spurious anonymous function
2019-07-19Fix renaming of annotations with paths (#967)Albert Chen
* check isLocal before removing target tokens in RenameMap * add fix for Adam's test case, add more test cases * fix multiple renaming bug * call componentGet before checking underlying for ReferenceTargets in recursiveGet * add ModuleGet that implements new instance rename order * normalize target before renaming * fix forall/exists bug * add guards for isLocal cases * fix circuit renaming, fix traverseHierarchy, add debug prints * remove sensitivity stuff * add more tests * reapply parent path to renamed subpath, fix reference -> instance renames * remove debug prints * add instance as reference test case * fix Ref->IsMod, IsMod->Ref renamed, fix extra test cases * fix ofModule renaming for refs/instances * fix renaming of ofModules, change tests * fix more InstanceTarget rename bugs * remove bad ReferenceTarget test case * cleanup midRename of recursiveGet * fix comments * fix multiple ModuleTarget renames for InstanceTargets * dis-allow renaming of ModuleTargets to References * add back removed lines in RemoveCHIRRTL * fix indents * only add ofModule to refs if renaming an inst as a ref * change .moduleOpt.get to .module * disallow renaming ReferenceTarget->ModuleTarget * disallow ref->mod renames in tests, add inst as ref test cases * cache results of get functions * fix bot/mid/top renames, add andThen * fix andThen, add test case * add more test cases, fix ++ * fix comments, make things private * dont quit if earlier returns None, add dedup/inline rename tests * don't rename OfModules to instances paths * update dedup test * don't treat references as instances, don't reapply parents to absolute paths * fix more test cases * short-circuit OfModule renames if an absolute path is found * update andThen, remove orElse, deprecate ++ * removed commented code * update comments * respond to comments
2019-07-15Add type aliases for dependenciesSchuyler Eldridge
Signed-off-by: Schuyler Eldridge <schuyler.eldridge@ibm.com>
2019-07-11Change Dependency API to Class[_ <: A]Schuyler Eldridge
This changes the Dependency API to specify dependencies in terms of classes subtyping the DependencyAPI trait. Previously, this was invariant which caused a bunch of ugly, unneeded .asInstanceOf jank. Signed-off-by: Schuyler Eldridge <schuyler.eldridge@ibm.com>
2019-07-08Remove some warnings (#1118)Leway Colin
2019-07-03Make Transform extend TransformLikeSchuyler Eldridge
Signed-off-by: Schuyler Eldridge <schuyler.eldridge@ibm.com>
2019-07-03Add DependencyManager and PhaseManagerSchuyler Eldridge
Adds the DependencyManager class which can be used to determine a legal sequence of TransformLikes given their Dependency API constraints. A DependencyManager determines an ordering that results in some target TransformLikes being run (without invalidations) given an initial state (some other set of TransformLikes). Algorithmically, this works as follows: 1. A DAG of TransformLikes w/ invalidation edges is constructed (the "invalidate graph") 2. A DAG of TransformLikes w/ prerequisite and dependent edges is constructed (the "dependents graph") 3. A toplogical sort of the dependents graph, seeded with the reverse topological sort of the invalidate graph, gives an ordering of TransformLikes. 4. This ordering is examined, node by node, cleaning up any mismatches between TransformLikes by solving DependencyManager sub-problems. As new graph nodes (which are classes) are found, these are lazily constructed. Data structures are maintained that map from classes to objects and back. All discovered classes will point to the same object. Determinism is maintained internally using LinkedHashMap and LinkedHashSet. Other changes: - Some methods that generate Graphviz for a DependencyManager are added. - One concrete implementation of a DependencyManager is added for Phases called "PhaseManager". Signed-off-by: Schuyler Eldridge <schuyler.eldridge@ibm.com>
2019-07-03Add PreservesAll stackable trait for DependencyAPISchuyler Eldridge
This adds a PreservesAll that can be used to override the default invalidation scheme (invalidated everything except yourself) such that nothing is invalidated. Signed-off-by: Schuyler Eldridge <schuyler.eldridge@ibm.com>
2019-07-03Add a DependencyAPI to firrtl.options.PhaseSchuyler Eldridge
This adds a TransformLike mixin, DependencyAPI, that defines the basis of the Dependency API for Stage/Phase. DependencyAPI defines three members that define dependency relationships for some TransformLike "Foo": - "Prerequisites" define TransformLikes that should run before Foo - "Dependents" define TransformLikes that should run after Foo. This allows Foo to inject prerequisites into some other TransformLike. - "Invalidates" define a function that will return true if a specific TransformLike would be invalidated by Foo Prerequisites and Dependents are not Sets due to lack of a fast, immutable Set that preserves insertion order. Internally, these are converted to a private LinkedHashSet. Signed-off-by: Schuyler Eldridge <schuyler.eldridge@ibm.com>
2019-07-03Add seeded topological sort to DiGraphSchuyler Eldridge
This adds a method to DiGraph called "seededLinearize". This generalizes the original topological sort ("linearize") to be parametric in an initial set of vertices. This enables the user to massage the DFS to produce a better topological sort if they have information about how the DFS should proceed. The initial set of vertices is expected to be made ordered via a LinkedHashSet. Signed-off-by: Schuyler Eldridge <schuyler.eldridge@ibm.com>
2019-07-03Remove shadow type parameter (#1108)Leway Colin
2019-06-28Remove deprecated ComponentName from CombinationalPath annotation (#1107)Albert Magyar
2019-06-28Fix typo (#1101)Leway Colin
* Fix typo * Fix simple_rest typo Co-Authored-By: jack koenig <jack.koenig3@gmail.com> * simple_reset isn't a Array due to 'simple_reset+' change to 'simple_reset' in FIRRTL.g4
2019-06-20Use pattern match instead of hardcode position (#1102)Leway Colin
2019-06-18Use scalafix to remove unused import and deprecated procedure syntax (#1074)Leway Colin
* Add sbt-scalafix * Add scalafix guide to README * Remove Unused Import * Remove deprecated procedure syntax
2019-06-13Remove unused variablesLeway Colin
2019-06-06Fix bad FirrtlStage deprecation warning (#1094)Schuyler Eldridge
Signed-off-by: Schuyler Eldridge <schuyler.eldridge@ibm.com>
2019-06-06Fix typo.Leway Colin
Because of there isn't extends anything, delete the 'extends' keyword
2019-05-29make analog attachment order fixed with linked hash map (#1089)harrisonliew
2019-05-24Emit legal Verilog literals for ExtModule IntParams > 32-bit (#1087)Jack Koenig
Emit Verilog IntParams that fit in 32-bits as Integer literals
2019-05-09Bugfix: GroupComponents (#1082)Adam Izraelevitz
* Added test to GroupComponentsSpec demonstrating bug * Added bugfix to GroupComponents for invalid ports of grouped instances
2019-05-04Add register init to RemoveWires dependencies (#1078)Schuyler Eldridge
Signed-off-by: Schuyler Eldridge <schuyler.eldridge@ibm.com>
2019-05-04Use UnknownKind instead misrepresented NodeKind (#1076)Leway Colin
2019-04-29Update NoCircuitDedupAnnotation so it's available from firrtl.stage.FirrtlMainJim Lawson
2019-04-25Add ShellOption, DeletedWrapperSchuyler Eldridge
Abstracts away option writing such that users no longer have to understand scopt semantics. This adds a ShellOption class and a HasShellOptions trait for something which provides one or more ShellOptions. This refactors the FIRRTL codebase to use this style of option specification. Adds and uses DeletedWrapper to automatically generate DeletedAnnotations. Signed-off-by: Schuyler Eldridge <schuyler.eldridge@ibm.com>
2019-04-25OptionsView/Viewer typeclass canonicalizationsSchuyler Eldridge
This switches the OptionsView/Viewer typeclass to use more canonical approaches and helper methods. This uses a context bound instead of an explicitly specified implicit argument. Additionally, this adds an apply method to OptionsView to enable more canonical use of the OptionsView typeclass. With this, you can now do things like `Viewer[FirrtlOptions].view` in addition to the old (and still available) `Viewer.view[FirrtlOptions]`. Uses of the latter are updated to use the former. Signed-off-by: Schuyler Eldridge <schuyler.eldridge@ibm.com>
2019-04-25Add FirrtlStage, make Driver compatibility layerSchuyler Eldridge
This adds FirrtlStage, a reimplementation of the original FIRRTL Driver as a Stage. This updates the original firrtl.options package to implement FirrtlStage (namely, TransformLike is added) along with FirrtlMain. Finally, the original FIRRTL Driver is converted to a compatibility wrapper around FirrtlStage. For background, Stage and Phase form the basis of the Chisel/FIRRTL Hardware Compiler Framework (HCF). A Phase is a class that performs a mathematical transformation on an AnnotationSeq (in effect, a generalization of a FIRRTL transform). Curtly, a Stage is a Phase that also provides a user interface for generating annotations. By their construction, Phases are designed to be composed sequentially into a transformation pipeline. This modifies the existing options package (which provides Stage/Phase) to build out a type hierarchy around Stage/Phase. This adds TransformLike[A] which implements a mathematical transformation over some type A. Additionally, and as an interface between different TransformLikes, this adds Translator[A, B] which extends TransformLike[A], but does an internal transformation over type B. This is used to interface Phases with the existing FIRRTL compiler. This adds a runTransform method to Phase that, like Transform.runTransform, will automatically detect deleted Annotations and generate DeletedAnnotations. The new FirrtlStage, a reimplementation of FIRRTL's Driver, is added as a Stage composed of the following Phases: 1. AddDefaults - add default annotations 2. AddImplicitEmitter - adds an implicit emitter derived from the compiler 3. Checks - sanity check the AnnotationSeq 4. AddCircuit - convert FIRRTL input files/sources to circuits 5. AddImplicitOutputFile - add a default output file 6. Compiler - run the FIRRTL compiler 7. WriteEmitted - write any emitted modules/circuits to files The Driver is converted to a compatibility layer that replicates old Driver behavior. This is implemented by first using new toAnnotation methods for CommonOptions and FirrtlExecutionOptions that enable AnnotationSeq generation. Second, the generated AnnotationSeq is preprocessed and sent to FirrtlStage. The resulting Phase order is then: 1. AddImplicitAnnotationFile - adds a default annotation file 2. AddImplicitFirrtlFile - adds a default FIRRTL file using top name 3. AddImplicitOutputFile - adds an output file from top name 4. AddImplicitEmitter - adds a default emitter derived from a compiler and any split modules command line option 5. FirrtlStage - the aforementioned new FirrtlStage Finally, the output AnnotationSeq is then viewed as a FirrtlExecutionResult. This compatibility layer enables uninterrupted usage of old Driver infrastructure, e.g., FirrtlExecutionOptions and CommonOptions can still be mutated directly and used to run the Driver. This results in differing behavior between the new FirrtlStage and the old Driver, specifically: - FirrtlStage makes a clear delineation between a "compiler" and an "emitter". These are defined using separate options. A compiler is "-X/--compiler", while an emitter is one of "-E/--emit-circuit" or "-e/--emit-modules". - Related to the above, the "-fsm/--split-modules" has been removed from the FirrtlStage. This option is confusing once an implicit emitter is removed. It is also unclear how this should be handled once the user can specify multiple emitters, e.g., which emitter should "--split-modules" apply to? - WriteOutputAnnotations will, by default, not write DeletedAnnotations to the output file. - The old top name ("-tn/--top-name") option has been removed from FirrtlStage. This option is really a means to communicate what input and output files are as opposed to anything associated with the circuit name. This option is preserved for the Driver compatibility layer. Additionally, this changes existing transform scheduling to work for emitters (which subclass Transform). Previously, one emitter was explicitly scheduled at the end of all transforms for a given compiler. Additional emitters could be added, but they would be scheduled as transforms. This fixes this to rely on transform scheduling for all emitters. In slightly more detail: 1. The explicit emitter is removed from Compiler.compile 2. An explicit emitter is added to Compiler.compileAndEmit 3. Compiler.mergeTransforms will schedule emitters as late as possible, i.e., all emitters will occur after transforms that output their input form. 4. All AddImplicitEmitter phases (DriverCompatibility and normal) will add RunFirrtlTransformAnnotations to add implicit emitters The FIRRTL fat jar utilities are changed to point at FirrtlStage and not at the Driver. This has backwards incompatibility issues for users that are using the utilities directly, e.g., Rocket Chip. The Logger has been updated with methods for setting options based on an AnnotationSeq. This migrates the Logger to use AnnotationSeq as input parameters, e.g., for makeScope. Old-style methods are left in place and deprecated. However, the Logger is not itself a Stage. The options of Logger Annotations are included in the base Shell and Stage is updated to wrap its Phases in a Logger scope. Additionally, this changes any code that does option parsing to always prepend an annotation as opposed to appending an annotation. This is faster, but standardizing on this has implications for dealing with the parallel compilation annotation ordering. A Shell will now put the initial annotations first (in the order the user specified) and then place all annotations generating from parsing after that. This adds a test case to verify this behavior. Discovered custom transforms (via `RunFirrtlTransformAnnotation`s) are discovered by the compiler phase in a user-specified order, but are stored in reverse order to more efficiently prepend (as opposed to append) to a list. This now reverses the transform order before execution to preserve backwards compatibility of custom transform ordering. The Compiler phase also generates one deleted annotation for each `RunFirrtlTransformAnnotation`. These are also reversed. Miscellaneous small changes: - Split main method of Stage into StageMain class - Only mix in HasScoptOptions into Annotation companion objects (h/t @jackkoenig) - Store Compiler in CompilerAnnotation - CompilerNameAnnotation -> CompilerAnnotation - Make Emitter abstract in outputSuffix (move out of FirrtlOptions) - Add DriverCompatibility.AddImplicitOutputFile that will add an output file annotation based on the presence of a TopNameAnnotation. This is important for compatibility with the old Driver. - Cleanup Scaladoc - Refactor CircuitOption to be abstract in "toCircuit" that converts the option to a FirrtlCircuitAnnotation. This allows more of the conversion steps to be moved out of AddCircuit and into the actual annotation. - Add WriteDeletedAnnotation to module WriteOutputAnnotations - A method for accessing a FirrtlExecutionResultView is exposed in FIRRTL's DriverCompatibilityLayer - Using "--top-name/-tn" or "--split-modules/-fsm" with FirrtlStage generates an error indicating that this option is no longer supported - Using FirrtlStage without at least one emitter will generate a warning - Use vals for emitter in Compiler subclasses (these are used to build RunFirrtlTransformAnnotations and the object should be stable for comparisons) - Fixes to tests that use LowTransformSpec instead of MiddleTransformSpec. (SimpleTransformSpec is dumb and won't schedule transforms correctly. If you rely on an emitter, you need to use the right transform spec to test your transform if you're relying on an emitter.) Signed-off-by: Schuyler Eldridge <schuyler.eldridge@ibm.com>
2019-04-22Improve registered library help textSchuyler Eldridge
This changes the base Shell to print information about all registered libraries/transforms. This addresses an @azidar comment about difficulty debugging whether registration worked. This also changes the "FIRRTL Transform Options" help text for registered transforms to only print if registered transforms exist. Signed-off-by: Schuyler Eldridge <schuyler.eldridge@ibm.com>