Skip to content

Commit

Permalink
Makefile: XSTOP_PREFIX for nested prefix of XSTop (#2799)
Browse files Browse the repository at this point in the history
* This does not work for chisel 3
  • Loading branch information
Tang-Haojin authored Mar 20, 2024
1 parent b280e43 commit a5b77de
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 1 deletion.
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ FPGA_MEM_ARGS = --infer-rw --repl-seq-mem -c:$(FPGATOP):-o:$(@D)/$(@F).conf --ge
SIM_MEM_ARGS = --infer-rw --repl-seq-mem -c:$(SIMTOP):-o:$(@D)/$(@F).conf --gen-mem-verilog full
endif

ifneq ($(XSTOP_PREFIX),)
RELEASE_ARGS += --xstop-prefix $(XSTOP_PREFIX)
DEBUG_ARGS += --xstop-prefix $(XSTOP_PREFIX)
PLDM_ARGS += --xstop-prefix $(XSTOP_PREFIX)
endif

# co-simulation with DRAMsim3
ifeq ($(WITH_DRAMSIM3),1)
ifndef DRAMSIM3_HOME
Expand Down
3 changes: 2 additions & 1 deletion src/main/scala/system/SoC.scala
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ case class SoCParameters
level = 3,
ways = 8,
sets = 2048 // 1MB per bank
))
)),
XSTopPrefix: Option[String] = None
){
// L3 configurations
val L3InnerBusWidth = 256
Expand Down
4 changes: 4 additions & 0 deletions src/main/scala/top/ArgParser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ object ArgParser {
nextOption(config.alter((site, here, up) => {
case DebugOptionsKey => up(DebugOptionsKey).copy(EnablePerfDebug = false)
}), tail)
case "--xstop-prefix" :: value :: tail if chisel3.BuildInfo.version != "3.6.0" =>
nextOption(config.alter((site, here, up) => {
case SoCParamsKey => up(SoCParamsKey).copy(XSTopPrefix = Some(value))
}), tail)
case "--firtool-opt" :: option :: tail =>
firtoolOpts ++= option.split(" ").filter(_.nonEmpty)
nextOption(config, tail)
Expand Down
9 changes: 9 additions & 0 deletions src/main/scala/top/Top.scala
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import org.chipsalliance.cde.config._
import freechips.rocketchip.diplomacy._
import freechips.rocketchip.tilelink._
import freechips.rocketchip.jtag.JTAGIO
import chisel3.experimental.{annotate, ChiselAnnotation}
import sifive.enterprise.firrtl.NestedPrefixModulesAnnotation

abstract class BaseXSSoc()(implicit p: Parameters) extends LazyModule
with BindingScope
Expand Down Expand Up @@ -138,6 +140,13 @@ class XSTop()(implicit p: Parameters) extends BaseXSSoc() with HasSoCParameter
}

class XSTopImp(wrapper: LazyModule) extends LazyRawModuleImp(wrapper) {
soc.XSTopPrefix.foreach { prefix =>
val mod = this.toNamed
annotate(new ChiselAnnotation {
def toFirrtl = NestedPrefixModulesAnnotation(mod, prefix, true)
})
}

FileRegisters.add("dts", dts)
FileRegisters.add("graphml", graphML)
FileRegisters.add("json", json)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Hacked from CIRCT source code. Look like some SiFive internal annotations.
package sifive.enterprise.firrtl

import firrtl.annotations.{ModuleTarget, SingleTargetAnnotation}

case class NestedPrefixModulesAnnotation(
target: ModuleTarget,
prefix: String,
inclusive: Boolean = false,
) extends SingleTargetAnnotation[ModuleTarget] {
def duplicate(n: ModuleTarget): NestedPrefixModulesAnnotation = this.copy(n)
}

0 comments on commit a5b77de

Please sign in to comment.