diff options
| author | Albert Chen | 2020-05-28 09:33:58 -0700 |
|---|---|---|
| committer | GitHub | 2020-05-28 09:33:58 -0700 |
| commit | 0845fcdb0c25e73c3299fc0463790f57a2219a0c (patch) | |
| tree | 9b8055e6c2604980ca663a0a2db1ed0fe2acba20 /src/main/scala/firrtl/annotations/analysis | |
| parent | 01919d31422c73a4b71daa405ddbe37f81e709c0 (diff) | |
Implement InstanceTarget Behavior for Dedup + EliminateTargetPaths (#1539)
- RenameMap Behavior
-- Prevent transitive renaming A -> B -> C (continueRenaming)
-- Prevent transitive renaming for self-renames
- Target
-- Override toString as serialize for CompleteTarget
-- Expansion of stripHierarchy to enable stripping InstanceTargets to become ModuleTargets
Annotations
-- Bugfix in extractComponents where Products were not iterated over
-- Converts renamed targets to local targets using Target.referringModule to preserve sticky behavior
- Eliminate Target Paths
-- Make DuplicationHelper use LinkedHashMap, as we iterate over its contents and convert to Seq in def makePathless
-- Add DupedResult to map original module to new module targets
-- Update renaming to record a map from all relative instance paths to original module, to new module target
-- Consumes DedupedResult to give better name to new duplicated module if it was originally deduplicated
-- Reorder modules in attempt to preserve original ordering, pre-deduplication
-- Move utility functions to object
-- Bugfix: add self-renames to prevent ofModule _ of target _ cannot be renamed to Vector(_, _, _, ...) errors
- Dedup
-- Changed NoDedupAnnotation to contain ModuleTarget, rather than ModuleName
-- Added DedupedResult to map original module to the duplicate module
-- Consumes DupedResult to pick better name, if it existed
-- Updates renaming to chain the following: instancify deduped modules, remap differently named internal signals, then remap AST modules
-- Move utility functions to object
-- Remove annotations as part of determination of dedup correctness
-- Bugfix: add instance renames so that deduped modules have their instances properly renamed
- Dead Code Elimination
-- Add deletion of ASTModules
- Tests
-- Morphism Spec to ensure Dedup -> EliminateTargetPaths and EliminateTargetPaths -> Dedup patterns work properly
-- Update existing tests to make sure they work properly
-- Add Dedup tests to demonstrate instance renaming bug, EliminateTargetPaths for ofModule rename bug, and update RenameMap tests
Co-authored-by: Schuyler Eldridge <schuyler.eldridge@ibm.com>
Co-authored-by: Adam Izraelevitz <adam.izraelevitz@sifive.com>
Co-authored-by: Adam Izraelevitz <azidar@gmail.com>
Co-authored-by: Jack Koenig <koenig@sifive.com>
Diffstat (limited to 'src/main/scala/firrtl/annotations/analysis')
| -rw-r--r-- | src/main/scala/firrtl/annotations/analysis/DuplicationHelper.scala | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/main/scala/firrtl/annotations/analysis/DuplicationHelper.scala b/src/main/scala/firrtl/annotations/analysis/DuplicationHelper.scala index f892c508..8f925ee7 100644 --- a/src/main/scala/firrtl/annotations/analysis/DuplicationHelper.scala +++ b/src/main/scala/firrtl/annotations/analysis/DuplicationHelper.scala @@ -12,24 +12,25 @@ import scala.collection.mutable * Calculates needed modifications to a circuit's module/instance hierarchy */ case class DuplicationHelper(existingModules: Set[String]) { + // Maps instances to the module it instantiates (an ofModule) - type InstanceOfModuleMap = mutable.HashMap[Instance, OfModule] + type InstanceOfModuleMap = mutable.LinkedHashMap[Instance, OfModule] // Maps a module to the instance/ofModules it instantiates - type ModuleHasInstanceOfModuleMap = mutable.HashMap[String, InstanceOfModuleMap] + type ModuleHasInstanceOfModuleMap = mutable.LinkedHashMap[String, InstanceOfModuleMap] // Maps original module names to new duplicated modules and their encapsulated instance/ofModules - type DupMap = mutable.HashMap[String, ModuleHasInstanceOfModuleMap] + type DupMap = mutable.LinkedHashMap[String, ModuleHasInstanceOfModuleMap] // Internal state to keep track of how paths duplicate private val dupMap = new DupMap() // Internal record of which paths are renamed to which new names, in the case of a collision - private val cachedNames = mutable.HashMap[(String, Seq[(Instance, OfModule)]), String]() ++ + private val cachedNames = mutable.LinkedHashMap[(String, Seq[(Instance, OfModule)]), String]() ++ existingModules.map(m => (m, Nil) -> m) // Internal record of all paths to ensure unique name generation - private val allModules = mutable.HashSet[String]() ++ existingModules + private val allModules = mutable.LinkedHashSet[String]() ++ existingModules /** Updates internal state (dupMap) to calculate instance hierarchy modifications so t's tokens in an instance can be * expressed as a tokens in a module (e.g. uniquify/duplicate the instance path in t's tokens) |
