graphML: CTO's like colour
This commit is contained in:
parent
fe0875b084
commit
f2ca2178bf
@ -60,6 +60,7 @@ object IntImp extends NodeImp[IntSourcePortParameters, IntSinkPortParameters, In
|
|||||||
Vec(ei.size, Vec(ei.map(_.source.num).max, Bool())).flip
|
Vec(ei.size, Vec(ei.map(_.source.num).max, Bool())).flip
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def colour = "#0000ff" // blue
|
||||||
def connect(bo: => Vec[Bool], bi: => Vec[Bool], ei: => IntEdge)(implicit sourceInfo: SourceInfo): (Option[LazyModule], () => Unit) = {
|
def connect(bo: => Vec[Bool], bi: => Vec[Bool], ei: => IntEdge)(implicit sourceInfo: SourceInfo): (Option[LazyModule], () => Unit) = {
|
||||||
(None, () => {
|
(None, () => {
|
||||||
// Cannot use bulk connect, because the widths could differ
|
// Cannot use bulk connect, because the widths could differ
|
||||||
|
@ -35,7 +35,8 @@ abstract class LazyModule
|
|||||||
val buf = new StringBuilder
|
val buf = new StringBuilder
|
||||||
buf ++= "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
|
buf ++= "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
|
||||||
buf ++= "<graphml xmlns=\"http://graphml.graphdrawing.org/xmlns\" xmlns:y=\"http://www.yworks.com/xml/graphml\">\n"
|
buf ++= "<graphml xmlns=\"http://graphml.graphdrawing.org/xmlns\" xmlns:y=\"http://www.yworks.com/xml/graphml\">\n"
|
||||||
buf ++= " <key for=\"node\" id=\"d1\" yfiles.type=\"nodegraphics\"/>\n"
|
buf ++= " <key for=\"node\" id=\"n\" yfiles.type=\"nodegraphics\"/>\n"
|
||||||
|
buf ++= " <key for=\"edge\" id=\"e\" yfiles.type=\"edgegraphics\"/>\n"
|
||||||
buf ++= " <graph id=\"G\" edgedefault=\"directed\">\n"
|
buf ++= " <graph id=\"G\" edgedefault=\"directed\">\n"
|
||||||
nodesGraphML(buf, " ")
|
nodesGraphML(buf, " ")
|
||||||
edgesGraphML(buf, " ")
|
edgesGraphML(buf, " ")
|
||||||
@ -48,7 +49,7 @@ abstract class LazyModule
|
|||||||
|
|
||||||
private def nodesGraphML(buf: StringBuilder, pad: String) {
|
private def nodesGraphML(buf: StringBuilder, pad: String) {
|
||||||
buf ++= s"""${pad}<node id=\"${index}\">\n"""
|
buf ++= s"""${pad}<node id=\"${index}\">\n"""
|
||||||
buf ++= s"""${pad} <data key=\"d1\"><y:ShapeNode><y:NodeLabel modelName=\"sides\" modelPosition=\"w\" fontSize=\"10\" borderDistance=\"1.0\" rotationAngle=\"270.0\">${module.name}</y:NodeLabel></y:ShapeNode></data>\n"""
|
buf ++= s"""${pad} <data key=\"n\"><y:ShapeNode><y:NodeLabel modelName=\"sides\" modelPosition=\"w\" fontSize=\"10\" borderDistance=\"1.0\" rotationAngle=\"270.0\">${module.name}</y:NodeLabel></y:ShapeNode></data>\n"""
|
||||||
buf ++= s"""${pad} <graph id=\"${index}::\" edgedefault=\"directed\">\n"""
|
buf ++= s"""${pad} <graph id=\"${index}::\" edgedefault=\"directed\">\n"""
|
||||||
nodes.filter(!_.omitGraphML).foreach { n =>
|
nodes.filter(!_.omitGraphML).foreach { n =>
|
||||||
buf ++= s"""${pad} <node id=\"${index}::${n.index}\"/>\n"""
|
buf ++= s"""${pad} <node id=\"${index}::${n.index}\"/>\n"""
|
||||||
@ -62,7 +63,7 @@ abstract class LazyModule
|
|||||||
buf ++= pad
|
buf ++= pad
|
||||||
buf ++= "<edge"
|
buf ++= "<edge"
|
||||||
buf ++= s""" source=\"${index}::${n.index}\""""
|
buf ++= s""" source=\"${index}::${n.index}\""""
|
||||||
buf ++= s""" target=\"${o.lazyModule.index}::${o.index}\"/>\n"""
|
buf ++= s""" target=\"${o.lazyModule.index}::${o.index}\"><data key=\"e\"><y:PolyLineEdge><y:Arrows source=\"none\" target=\"standard\"/><y:LineStyle color=\"${o.colour}\" type=\"line\" width=\"1.0\"/></y:PolyLineEdge></data></edge>\n"""
|
||||||
} }
|
} }
|
||||||
children.filter(!_.omitGraphML).foreach { c => c.edgesGraphML(buf, pad) }
|
children.filter(!_.omitGraphML).foreach { c => c.edgesGraphML(buf, pad) }
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ trait InwardNodeImp[DI, UI, EI, BI <: Data]
|
|||||||
def edgeI(pd: DI, pu: UI): EI
|
def edgeI(pd: DI, pu: UI): EI
|
||||||
def bundleI(ei: Seq[EI]): Vec[BI]
|
def bundleI(ei: Seq[EI]): Vec[BI]
|
||||||
def mixI(pu: UI, node: InwardNode[DI, UI, BI]): UI = pu
|
def mixI(pu: UI, node: InwardNode[DI, UI, BI]): UI = pu
|
||||||
|
def colour: String
|
||||||
def connect(bo: => BI, bi: => BI, e: => EI)(implicit sourceInfo: SourceInfo): (Option[LazyModule], () => Unit)
|
def connect(bo: => BI, bi: => BI, e: => EI)(implicit sourceInfo: SourceInfo): (Option[LazyModule], () => Unit)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,11 +43,11 @@ abstract class BaseNode
|
|||||||
lazyModule.nodes = this :: lazyModule.nodes
|
lazyModule.nodes = this :: lazyModule.nodes
|
||||||
|
|
||||||
def name = lazyModule.name + "." + getClass.getName.split('.').last
|
def name = lazyModule.name + "." + getClass.getName.split('.').last
|
||||||
def colour = "blue"
|
|
||||||
def omitGraphML = outputs.isEmpty && inputs.isEmpty
|
def omitGraphML = outputs.isEmpty && inputs.isEmpty
|
||||||
|
|
||||||
protected[tilelink2] def outputs: Seq[BaseNode]
|
protected[tilelink2] def outputs: Seq[BaseNode]
|
||||||
protected[tilelink2] def inputs: Seq[BaseNode]
|
protected[tilelink2] def inputs: Seq[BaseNode]
|
||||||
|
protected[tilelink2] def colour: String
|
||||||
}
|
}
|
||||||
|
|
||||||
trait InwardNode[DI, UI, BI <: Data] extends BaseNode
|
trait InwardNode[DI, UI, BI <: Data] extends BaseNode
|
||||||
@ -109,6 +110,7 @@ class MixedNode[DI, UI, EI, BI <: Data, DO, UO, EO, BO <: Data](
|
|||||||
extends BaseNode with InwardNode[DI, UI, BI] with OutwardNode[DO, UO, BO]
|
extends BaseNode with InwardNode[DI, UI, BI] with OutwardNode[DO, UO, BO]
|
||||||
{
|
{
|
||||||
// meta-data for printing the node graph
|
// meta-data for printing the node graph
|
||||||
|
protected[tilelink2] def colour = inner.colour
|
||||||
protected[tilelink2] def outputs = oPorts.map(_._2)
|
protected[tilelink2] def outputs = oPorts.map(_._2)
|
||||||
protected[tilelink2] def inputs = iPorts.map(_._2)
|
protected[tilelink2] def inputs = iPorts.map(_._2)
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@ object TLImp extends NodeImp[TLClientPortParameters, TLManagerPortParameters, TL
|
|||||||
Vec(ei.size, TLBundle(ei.map(_.bundle).reduce(_.union(_)))).flip
|
Vec(ei.size, TLBundle(ei.map(_.bundle).reduce(_.union(_)))).flip
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def colour = "#000000" // black
|
||||||
def connect(bo: => TLBundle, bi: => TLBundle, ei: => TLEdgeIn)(implicit sourceInfo: SourceInfo): (Option[LazyModule], () => Unit) = {
|
def connect(bo: => TLBundle, bi: => TLBundle, ei: => TLEdgeIn)(implicit sourceInfo: SourceInfo): (Option[LazyModule], () => Unit) = {
|
||||||
val monitor = LazyModule(new TLMonitor(() => new TLBundleSnoop(bo.params), () => ei, sourceInfo))
|
val monitor = LazyModule(new TLMonitor(() => new TLBundleSnoop(bo.params), () => ei, sourceInfo))
|
||||||
(Some(monitor), () => {
|
(Some(monitor), () => {
|
||||||
@ -85,6 +86,7 @@ object TLAsyncImp extends NodeImp[TLAsyncClientPortParameters, TLAsyncManagerPor
|
|||||||
Vec(ei.size, new TLAsyncBundle(ei(0).bundle)).flip
|
Vec(ei.size, new TLAsyncBundle(ei(0).bundle)).flip
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def colour = "#ff0000" // red
|
||||||
def connect(bo: => TLAsyncBundle, bi: => TLAsyncBundle, ei: => TLAsyncEdgeParameters)(implicit sourceInfo: SourceInfo): (Option[LazyModule], () => Unit) = {
|
def connect(bo: => TLAsyncBundle, bi: => TLAsyncBundle, ei: => TLAsyncEdgeParameters)(implicit sourceInfo: SourceInfo): (Option[LazyModule], () => Unit) = {
|
||||||
(None, () => { bi <> bo })
|
(None, () => { bi <> bo })
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user