Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update scalafmt-core to 2.7.5 #72

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = 2.6.4
version = 2.7.5

maxColumn = 120
align = most
Expand Down
3 changes: 1 addition & 2 deletions src/main/scala/dotvisualizer/FirrtlDiagrammer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import dotvisualizer.stage.DiagrammerStage
import firrtl.FileUtils.isCommandAvailable
import firrtl._

/**
* This library implements a graphviz dot file render.
/** This library implements a graphviz dot file render.
*/
object FirrtlDiagrammer {
def main(args: Array[String]): Unit = {
Expand Down
10 changes: 4 additions & 6 deletions src/main/scala/dotvisualizer/ToLoFirrtl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import firrtl.options.{Dependency, Phase}
import firrtl.stage.{FirrtlCircuitAnnotation, Forms}
import firrtl.transforms.BlackBoxSourceHelper

/**
* Use these lowering transforms to prepare circuit for compiling
/** Use these lowering transforms to prepare circuit for compiling
*/
class ToLoFirrtl extends Phase {
private val targets = Forms.LowFormOptimized ++ Seq(
Expand All @@ -34,8 +33,8 @@ class ToLoFirrtl extends Phase {
annotationSeq.flatMap {
case FirrtlCircuitAnnotation(circuit) =>
val state = CircuitState(circuit, annotationSeq)
val newState = transforms.foldLeft(state) {
case (prevState, transform) => transform.runTransform(prevState)
val newState = transforms.foldLeft(state) { case (prevState, transform) =>
transform.runTransform(prevState)
}
Some(FirrtlCircuitAnnotation(newState.circuit))
case other =>
Expand All @@ -44,8 +43,7 @@ class ToLoFirrtl extends Phase {
}
}

/**
* Workaround for https://github.com/freechipsproject/firrtl/issues/498 from @jackkoenig
/** Workaround for https://github.com/freechipsproject/firrtl/issues/498 from @jackkoenig
*/
class FixupOps extends Transform with DependencyAPIMigration {
override def prerequisites = Seq.empty
Expand Down
20 changes: 9 additions & 11 deletions src/main/scala/dotvisualizer/dotnodes/ModuleNode.scala
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,14 @@ case class ModuleNode(

val connectionTargetNames = connections.values.map(_.split(":").head).toSet

connections.foreach {
case (rhs, lhs) =>
val source = lhs.split(":").head
val target = rhs.split(":").head

if (target.nonEmpty && connectionTargetNames.contains(target)) {
linkedHashMap(source) += target
linkedHashMap(target)
}
connections.foreach { case (rhs, lhs) =>
val source = lhs.split(":").head
val target = rhs.split(":").head

if (target.nonEmpty && connectionTargetNames.contains(target)) {
linkedHashMap(source) += target
linkedHashMap(target)
}
}
DiGraph(linkedHashMap)
}
Expand Down Expand Up @@ -92,8 +91,7 @@ case class ModuleNode(
rankInfo + "\n " + s"""{ rank=same; ${outputPorts.mkString(" ")} };"""
}

/**
* Renders this node
/** Renders this node
* @return
*/
def render: String = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ class GenerateDotFilePhase extends Phase {

override def invalidates(a: Phase) = false

/**
* Make a simple css file that controls highlighting
/** Make a simple css file that controls highlighting
*
* @param targetDir where to put the css
*/
Expand All @@ -48,8 +47,7 @@ class GenerateDotFilePhase extends Phase {
printWriter.close()
}

/**
* Open an svg file using the open program
/** Open an svg file using the open program
*
* @param fileName file to be opened
* @param openProgram program to use
Expand All @@ -72,12 +70,12 @@ class GenerateDotFilePhase extends Phase {

addCss(targetDir)

val dotProgram = annotationSeq.collectFirst {
case SetRenderProgramAnnotation(program) => program
val dotProgram = annotationSeq.collectFirst { case SetRenderProgramAnnotation(program) =>
program
}.getOrElse("dot")

val dotTimeOut = annotationSeq.collectFirst {
case DotTimeoutSecondsAnnotation(secs) => secs
val dotTimeOut = annotationSeq.collectFirst { case DotTimeoutSecondsAnnotation(secs) =>
secs
}.getOrElse(7)

val renderer = new RenderSvg(dotProgram, dotTimeOut)
Expand All @@ -91,8 +89,8 @@ class GenerateDotFilePhase extends Phase {
}

val fileName = s"$targetDir/${circuitState.circuit.main}_hierarchy.dot"
val openProgram = annotationSeq.collectFirst {
case OpenCommandAnnotation(program) => program
val openProgram = annotationSeq.collectFirst { case OpenCommandAnnotation(program) =>
program
}.getOrElse("open")

show(fileName, openProgram)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ class GetFirrtlCircuitPhase extends Phase {
val rawFirrtl = firrtl.Parser.parse(firrtlText)
val processedFirrtlCircuit = (new ToLoFirrtl)
.transform(Seq(FirrtlCircuitAnnotation(rawFirrtl)))
.collectFirst {
case circuitAnnotation: FirrtlCircuitAnnotation => circuitAnnotation
.collectFirst { case circuitAnnotation: FirrtlCircuitAnnotation =>
circuitAnnotation
}
.getOrElse {
throw new DiagrammerException("Error: Could not lower firrtl circuit")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ class MakeDiagramGroup(renderSvg: RenderSvg) extends Transform with DependencyAP

override def invalidates(a: Transform) = false

/**
* Creates a series of diagrams starting with the startModule and continuing
/** Creates a series of diagrams starting with the startModule and continuing
* through all descendant sub-modules.
* @param state the state to be diagrammed
* @return
Expand All @@ -31,8 +30,8 @@ class MakeDiagramGroup(renderSvg: RenderSvg) extends Transform with DependencyAP
s"test_run_dir/${state.circuit.main}/"
}

val startModule = state.annotations.collectFirst {
case StartModuleNameAnnotation(moduleName) => moduleName
val startModule = state.annotations.collectFirst { case StartModuleNameAnnotation(moduleName) =>
moduleName
}.getOrElse(state.circuit.main)

val queue = new mutable.Queue[String]()
Expand Down
16 changes: 6 additions & 10 deletions src/main/scala/dotvisualizer/transforms/MakeOneDiagram.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ import firrtl.{CircuitState, DependencyAPIMigration, Transform, WDefInstance, WR

import scala.collection.mutable

/**
* Annotations specify where to start rendering. Currently the first encountered module that matches an annotation
/** Annotations specify where to start rendering. Currently the first encountered module that matches an annotation
* will start the rendering, rendering continues per the depth specified in the annotation.
* This pass is intermixed with other low to low transforms, it is not treated as a separate
* emit, so if so annotated it will run with every firrtl compilation.
Expand All @@ -37,8 +36,8 @@ class MakeOneDiagram(renderSvg: RenderSvg) extends Transform with DependencyAPIM
val c = state.circuit
val targetDir = state.annotations.collectFirst { case TargetDirAnnotation(dir) => dir }.get

val startModuleName = state.annotations.collectFirst {
case StartModuleNameAnnotation(moduleName) => moduleName
val startModuleName = state.annotations.collectFirst { case StartModuleNameAnnotation(moduleName) =>
moduleName
}.getOrElse(state.circuit.main)

var linesPrintedSinceFlush = 0
Expand All @@ -64,8 +63,7 @@ class MakeOneDiagram(renderSvg: RenderSvg) extends Transform with DependencyAPIM
}
}

/**
* finds the specified module name in the circuit
/** finds the specified module name in the circuit
*
* @param moduleName name to find
* @param circuit circuit being analyzed
Expand All @@ -82,8 +80,7 @@ class MakeOneDiagram(renderSvg: RenderSvg) extends Transform with DependencyAPIM
}
}

/**
* If rendering started, construct a graph inside moduleNode
/** If rendering started, construct a graph inside moduleNode
* @param modulePrefix the path to this node
* @param myModule the firrtl module currently being parsed
* @param moduleNode a node renderable to dot notation constructed from myModule
Expand All @@ -97,8 +94,7 @@ class MakeOneDiagram(renderSvg: RenderSvg) extends Transform with DependencyAPIM
subModuleDepth: Int = 0
): DotNode = {

/**
* Half the battle here is matching references between firrtl full name for an element and
/** Half the battle here is matching references between firrtl full name for an element and
* dot's reference to a connect-able module
* Following functions compute the two kinds of name
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ import firrtl.options.TargetDirAnnotation

import scala.collection.mutable

/**
* Represents a module instance in the graph of instances in a circuit.
/** Represents a module instance in the graph of instances in a circuit.
*
* @param graphName How `dot` will refer to this node
* @param instanceName The instance name within the parent module
Expand All @@ -23,8 +22,7 @@ import scala.collection.mutable
class ModuleDotNode private (val graphName: String, val instanceName: String, val moduleName: String) {
val children = new mutable.ArrayBuffer[ModuleDotNode]()

/**
* Render this node as a small HTML table with the module name at the top
/** Render this node as a small HTML table with the module name at the top
* and each child instance as a row
* children are sorted by moduleName then instanceName
* @return
Expand Down Expand Up @@ -59,14 +57,12 @@ class ModuleDotNode private (val graphName: String, val instanceName: String, va
}
}

/**
* Is the factory for ModuleDotNode creation
/** Is the factory for ModuleDotNode creation
*/
object ModuleDotNode {
var nodeCounter: Int = 0

/**
* This factor created a new unique dot graph node name for this instance
/** This factor created a new unique dot graph node name for this instance
* @param instanceName The instance
* @param moduleName The module
* @return
Expand All @@ -77,8 +73,7 @@ object ModuleDotNode {
}
}

/**
* Creates a high level diagram that shows the instances in the circuit and their Module names
/** Creates a high level diagram that shows the instances in the circuit and their Module names
*/
//
//TODO: Make even more links from these graph nodes back to the other generated graphs
Expand All @@ -95,8 +90,8 @@ class ModuleLevelDiagrammer(renderSvg: RenderSvg) extends Transform with Depende
def execute(circuitState: CircuitState): CircuitState = {
val c = circuitState.circuit
val targetDir = circuitState.annotations.collectFirst { case TargetDirAnnotation(dir) => dir }.get
val startModule = circuitState.annotations.collectFirst {
case StartModuleNameAnnotation(moduleName) => moduleName
val startModule = circuitState.annotations.collectFirst { case StartModuleNameAnnotation(moduleName) =>
moduleName
}.getOrElse(circuitState.circuit.main)

val TopLevel = startModule + "_hierarchy"
Expand All @@ -115,8 +110,7 @@ class ModuleLevelDiagrammer(renderSvg: RenderSvg) extends Transform with Depende

val top = WDefInstance(startModule, startModule)

/**
* Find the given instance in the Module Hierarchy
/** Find the given instance in the Module Hierarchy
* This is almost certainly inefficient. Should not have to map the modules every time
* @param instance instance being searched for
* @return
Expand All @@ -137,8 +131,7 @@ class ModuleLevelDiagrammer(renderSvg: RenderSvg) extends Transform with Depende
}
}

/**
* Walk through the instance graph adding ModuleDotNodes and a record of their connections
/** Walk through the instance graph adding ModuleDotNodes and a record of their connections
* @param wDefInstance start instance
* @param path underscore separated path to the start instance
* @return
Expand Down
19 changes: 7 additions & 12 deletions src/main/scala/dotvisualizer/transforms/RemoveTempWires.scala
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ class RemoveTempWires extends Transform with DependencyAPIMigration {

override def invalidates(a: Transform) = false

/**
* Foreach Module in a firrtl circuit
/** Foreach Module in a firrtl circuit
* Find all the DefNodes with temp names and render their expression
* Remove all the found dev nodes
* recursively replace their references with their associated expression
Expand All @@ -43,17 +42,15 @@ class RemoveTempWires extends Transform with DependencyAPIMigration {

val c = state.circuit

/**
* removes all references to temp wires in module
/** removes all references to temp wires in module
* @param module the module to be altered
* @return
*/
def removeTempWiresFromModule(module: Module): Module = {

val toRemove = new mutable.HashMap[String, Expression]()

/**
* Saves reference to the expression associated
/** Saves reference to the expression associated
* with a temp wire associated with a Node statement
* @param s statement to be checked
*/
Expand All @@ -75,8 +72,7 @@ class RemoveTempWires extends Transform with DependencyAPIMigration {
case _ => //do nothing
}

/**
* recursively find any references to temp wires in the expression and replace the
/** recursively find any references to temp wires in the expression and replace the
* references with the associated expression
* @param e expression to be altered
* @return
Expand All @@ -86,7 +82,7 @@ class RemoveTempWires extends Transform with DependencyAPIMigration {
case wire: WRef =>
if (
(wire.name.startsWith(RemoveTempWires.GenPrefix) ||
wire.name.startsWith(RemoveTempWires.TempPrefix)) && toRemove.contains(wire.name)
wire.name.startsWith(RemoveTempWires.TempPrefix)) && toRemove.contains(wire.name)
) {
val new_node = toRemove(wire.name)
removeGen(new_node)
Expand All @@ -96,7 +92,7 @@ class RemoveTempWires extends Transform with DependencyAPIMigration {
case wire: WSubField =>
if (
(wire.name.startsWith(RemoveTempWires.GenPrefix) ||
wire.name.startsWith(RemoveTempWires.TempPrefix)) && toRemove.contains(wire.name)
wire.name.startsWith(RemoveTempWires.TempPrefix)) && toRemove.contains(wire.name)
) {
val new_node = toRemove(wire.name)
removeGen(new_node)
Expand All @@ -109,8 +105,7 @@ class RemoveTempWires extends Transform with DependencyAPIMigration {
}
}

/**
* Removes node definition statements for temp wires
/** Removes node definition statements for temp wires
* @param s statement to be altered
* @return
*/
Expand Down
3 changes: 1 addition & 2 deletions src/test/scala/dotvisualizer/AttachExample.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ import org.scalatest.matchers.should.Matchers

import scala.io.Source

/**
* Checks that attaches are double headed arrows connected to each node
/** Checks that attaches are double headed arrows connected to each node
*/
class AttachExample extends AnyFreeSpec with Matchers {

Expand Down
6 changes: 2 additions & 4 deletions src/test/scala/dotvisualizer/HierarchicalModulesExample.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ import org.scalatest.freespec.AnyFreeSpec
import org.scalatest.matchers.should.Matchers
import scala.language.reflectiveCalls

/**
* This class has parameterizable widths, it will generate different hardware
/** This class has parameterizable widths, it will generate different hardware
*
* @param widthC io width
*/
Expand All @@ -27,8 +26,7 @@ class VizModC(widthC: Int) extends Module {
io.out := io.in
}

/**
* instantiates a C of a particular size, VizModA does not generate different hardware
/** instantiates a C of a particular size, VizModA does not generate different hardware
* based on it's parameter
* @param annoParam parameter is only used in annotation not in circuit
*/
Expand Down