Skip to content
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
3 changes: 2 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ libraryDependencies ++= (if (standalone) {
Nil
})

libraryDependencies += "com.typesafe.play" %% "play-json" % "2.9.3"

addCompilerPlugin("edu.berkeley.cs" % "chisel3-plugin"
% (if (standalone) "3.5.2" else "3.5.1") cross CrossVersion.full)

Expand All @@ -35,4 +37,3 @@ Test / testGrouping := (Test / testGrouping).value.flatMap { group =>
}
}
concurrentRestrictions := Seq(Tags.limit(Tags.ForkedTestGroup, 72))

2 changes: 1 addition & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Constellation is a Chisel NoC RTL generator framework designed from the ground u

.. image:: diagrams/bigsoc.svg
:width: 600px

.. toctree::
:maxdepth: 4
:caption: Contents:
Expand Down
115 changes: 115 additions & 0 deletions src/main/scala/noc/JsonConverter.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
package constellation.noc

import chisel3._
import chisel3.util._

import freechips.rocketchip.config.{Field, Parameters}
import freechips.rocketchip.diplomacy.{LazyModule, LazyModuleImp, BundleBridgeSink, InModuleBody}
import constellation.router._
import constellation.channel._
import constellation.routing._
import constellation.topology.{PhysicalTopology, UnidirectionalLine}

import play.api.libs.json._

object JSONConverters {
implicit val jsonUserVirtualChannelParams = new Writes[UserVirtualChannelParams] {
def writes(uvcp: UserVirtualChannelParams) = Json.obj(
"bufferSize" -> uvcp.bufferSize
)
}

implicit val jsonUserChannelParams = new Writes[UserChannelParams] {
def writes(ucp: UserChannelParams) = Json.obj(
"virtualChannelParams" -> ucp.virtualChannelParams,
// excluding channelGen
"crossingType" -> ucp.getClass.getName(),
"srcSpeedup" -> ucp.srcSpeedup,
"dstSpeedup" -> ucp.destSpeedup
)
}

case class UserChannelParamsWrapper(
srcId: Int,
destId: Int,
userChannelParams: UserChannelParams
)

implicit val jsonUserChannelParamsWrapper = new Writes[UserChannelParamsWrapper] {
def writes(ucpw: UserChannelParamsWrapper) = Json.obj(
"srcId" -> ucpw.srcId,
"destId" -> ucpw.destId,
"userChannelParams" -> ucpw.userChannelParams
)
}

implicit val jsonUserIngressParams = new Writes[UserIngressParams] {
def writes(uip: UserIngressParams) = Json.obj(
"destId" -> uip.destId,
"payloadBits" -> uip.payloadBits
)
}

implicit val jsonUserEgressParams = new Writes[UserEgressParams] {
def writes(uep: UserEgressParams) = Json.obj(
"srcId" -> uep.srcId,
"payloadBits" -> uep.payloadBits
)
}

implicit val jsonUserRouterParams = new Writes[UserRouterParams] {
def writes(urp: UserRouterParams) = Json.obj(
"payloadBits" -> urp.payloadBits,
"combineSAST" -> urp.combineSAST,
"combineRCVA" -> urp.combineRCVA,
"coupleSAVA" -> urp.coupleSAVA
)
}

implicit val jsonFlowParams = new Writes[FlowParams] {
def writes(fp: FlowParams) = Json.obj(
"ingressId" -> fp.ingressId,
"egressId" -> fp.egressId,
"vNetId" -> fp.vNetId
)
}

implicit val jsonNoCParams = new Writes[NoCParams] {
def writes(nocParams: NoCParams) = {
val nNodes = nocParams.topology.nNodes
val channelParams = Seq.tabulate(nNodes, nNodes) { case (i,j) =>
if (nocParams.topology.topo(i, j)) {
val cP = nocParams.channelParamGen(i, j)
Some(UserChannelParamsWrapper(
srcId = i,
destId = j,
userChannelParams = cP,
))
} else {
None
}
}.flatten.flatten

val routerParams = (0 until nNodes).map { i =>
nocParams.routerParams(i)
}

Json.obj(
"topology" -> nocParams.topology.getClass().getName(),
"channelParams" -> channelParams,
"ingresses" -> nocParams.ingresses,
"egresses" -> nocParams.egresses,
"routerParams" -> routerParams,
// vNetBlocking is a function
"flows" -> nocParams.flows,
"routingRelation" -> nocParams.routingRelation.getClass().getName(),
"nocName" -> nocParams.nocName
)
}
}

def printAsJson(np: NoCParams): JsValue = {
Json.toJson(np)
}

}
4 changes: 4 additions & 0 deletions src/main/scala/noc/NoC.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import constellation.channel._
import constellation.routing.{RoutingRelation, ChannelRoutingInfo}
import constellation.topology.{PhysicalTopology, UnidirectionalLine}

import play.api.libs.json._


class NoCTerminalIO(
val ingressParams: Seq[IngressChannelParams],
Expand Down Expand Up @@ -209,6 +211,8 @@ class NoC(nocParams: NoCParams)(implicit p: Parameters) extends LazyModule {
(outs ++ egresses ++ ingresses).mkString("\n")
}.mkString("\n")
ElaborationArtefacts.add(prepend("noc.edgeprops"), edgeProps)
import JSONConverters._
ElaborationArtefacts.add(prepend("noc_cfg.json"), Json.toJson(nocParams).toString())

println(s"Constellation: $nocName Finished NoC RTL generation")
}
Expand Down