Upgrade sbt to 0.13.8, simplify build.scala Tasks, generate tests from TestGenerator App, set addons with env variable ROCKETCHIP_ADDONS
This commit is contained in:
parent
25e1412a33
commit
bd4ff35a4b
4
Makefrag
4
Makefrag
@ -26,7 +26,7 @@ timeout_cycles = 100000000
|
||||
#--------------------------------------------------------------------
|
||||
|
||||
$(generated_dir)/$(MODEL).$(CONFIG).v: $(chisel_srcs)
|
||||
cd $(base_dir) && mkdir -p $(generated_dir) && $(SBT) "project rocketchip" "elaborate $(MODEL) --backend $(BACKEND) --targetDir $(generated_dir) --W0W --configDump --noInlineMem --configInstance rocketchip.$(CONFIG)"
|
||||
cd $(base_dir) && mkdir -p $(generated_dir) && $(SBT) "run $(MODEL) --backend $(BACKEND) --targetDir $(generated_dir) --W0W --configDump --noInlineMem --configInstance rocketchip.$(CONFIG)"
|
||||
cd $(generated_dir) && \
|
||||
if [ -a $(MODEL).$(CONFIG).conf ]; then \
|
||||
$(mem_gen) $(generated_dir)/$(MODEL).$(CONFIG).conf >> $(generated_dir)/$(MODEL).$(CONFIG).v; \
|
||||
@ -39,7 +39,7 @@ $(generated_dir)/consts.$(CONFIG).vh: $(generated_dir)/$(MODEL).$(CONFIG).v
|
||||
echo "\`endif // CONST_VH" >> $@
|
||||
|
||||
$(generated_dir)/memdessertMemDessert.$(CONFIG).v: $(base_dir)/$(src_path)/*.scala $(base_dir)/uncore/$(src_path)/*.scala
|
||||
cd $(base_dir) && mkdir -p $(generated_dir) && $(SBT) "project rocketchip" "elaborate MemDessert --backend v --targetDir $(generated_dir) --W0W --moduleNamePrefix memdessert --configInstance rocketchip.$(CONFIG)"
|
||||
cd $(base_dir) && mkdir -p $(generated_dir) && $(SBT) "run MemDessert --backend v --targetDir $(generated_dir) --W0W --moduleNamePrefix memdessert --configInstance rocketchip.$(CONFIG)"
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# DRAMSim2
|
||||
|
@ -26,10 +26,10 @@ CHISEL_ARGS := $(MODEL) --W0W --noIoDebug --backend c --configInstance $(PROJECT
|
||||
CHISEL_ARGS_DEBUG := $(CHISEL_ARGS)-debug --debug --vcd --ioDebug
|
||||
|
||||
generated-src/$(MODEL).$(CONFIG).h: $(chisel_srcs)
|
||||
cd $(base_dir) && $(SBT) "project $(PROJECT)" "elaborate $(CHISEL_ARGS)"
|
||||
cd $(base_dir) && $(SBT) "project $(PROJECT)" "run $(CHISEL_ARGS)"
|
||||
|
||||
generated-src-debug/$(MODEL).$(CONFIG).h: $(chisel_srcs)
|
||||
cd $(base_dir) && $(SBT) "project $(PROJECT)" "elaborate $(CHISEL_ARGS_DEBUG)"
|
||||
cd $(base_dir) && $(SBT) "project $(PROJECT)" "run $(CHISEL_ARGS_DEBUG)"
|
||||
|
||||
$(MODEL).$(CONFIG).o: %.o: generated-src/%.h
|
||||
$(MAKE) -j $(patsubst %.cpp,%.o,$(shell ls generated-src/$(MODEL).$(CONFIG)-*.cpp))
|
||||
|
@ -1 +1 @@
|
||||
sbt.version=0.13.0
|
||||
sbt.version=0.13.8
|
||||
|
@ -1,100 +1,44 @@
|
||||
import sbt._
|
||||
import Keys._
|
||||
import scala.language.postfixOps
|
||||
//val extracted: Extracted = Project.extract(state)
|
||||
//import extracted._
|
||||
import complete._
|
||||
import complete.DefaultParsers._
|
||||
|
||||
object BuildSettings extends Build {
|
||||
val buildOrganization = "berkeley"
|
||||
val buildVersion = "1.1"
|
||||
val buildScalaVersion = "2.10.2"
|
||||
|
||||
val buildSettings = Defaults.defaultSettings ++ Seq (
|
||||
//unmanagedBase <<= baseDirectory { base => base / ".." / custom_lib" },
|
||||
organization := buildOrganization,
|
||||
version := buildVersion,
|
||||
scalaVersion := buildScalaVersion,
|
||||
override lazy val settings = super.settings ++ Seq(
|
||||
organization := "berkeley",
|
||||
version := "1.2",
|
||||
scalaVersion := "2.10.2",
|
||||
parallelExecution in Global := false,
|
||||
traceLevel := 15,
|
||||
scalacOptions ++= Seq("-deprecation","-unchecked"),
|
||||
libraryDependencies ++= Seq("org.scala-lang" % "scala-reflect" % scalaVersion.value)
|
||||
// "edu.berkeley.cs" %% "chisel" % "2.3-SNAPSHOT",
|
||||
// "edu.berkeley.cs" %% "hardfloat" % "1.2"),
|
||||
//resolvers ++= Seq(
|
||||
// "Sonatype Snapshots" at "http://oss.sonatype.org/content/repositories/snapshots",
|
||||
// "Sonatype Releases" at "http://oss.sonatype.org/content/repositories/releases",
|
||||
// "scct-github-repository" at "http://mtkopone.github.com/scct/maven-repo"
|
||||
//)
|
||||
)
|
||||
|
||||
lazy val chisel = Project("chisel", file("chisel"), settings = buildSettings)
|
||||
lazy val hardfloat = Project("hardfloat", file("hardfloat"), settings = buildSettings) dependsOn(chisel)
|
||||
lazy val uncore = Project("uncore", file("uncore"), settings = buildSettings) dependsOn(hardfloat)
|
||||
lazy val rocket = Project("rocket", file("rocket"), settings = buildSettings) dependsOn(uncore)
|
||||
lazy val zscale = Project("zscale", file("zscale"), settings = buildSettings) dependsOn(rocket)
|
||||
lazy val chisel = project
|
||||
lazy val hardfloat = project.dependsOn(chisel)
|
||||
lazy val uncore = project.dependsOn(hardfloat)
|
||||
lazy val rocket = project.dependsOn(uncore)
|
||||
lazy val zscale = project.dependsOn(rocket)
|
||||
lazy val rocketchip = (project in file(".")).settings(chipSettings).dependsOn(zscale)
|
||||
|
||||
val baselist = Vector("chisel", "uncore", "rocket", "zscale", "hardfloat")
|
||||
def getsubdirs = {
|
||||
val blacklist = (baselist ++ Vector("target", "project"))
|
||||
IO.listFiles(file(".")) map (_.toString.split("/").last) filter (f=> !blacklist.contains(f) && (f(0)!='.')) filter (f=> !IO.listFiles(file(f+"/src/main/scala")).isEmpty)
|
||||
}
|
||||
val addonsources = getsubdirs map (f=>s"${f}/src/main/scala") map (f=>file(f))
|
||||
addonsources.foreach(a => println(s"[info] Found addon: " + a.toString.split("/").head))
|
||||
|
||||
val prepareTask = TaskKey[Unit]("prepare","Remove old sources and copy over new ones to addon/src")
|
||||
def prepareTaskImpl = {
|
||||
import IO._
|
||||
delete(file(".addons-dont-touch/src"))
|
||||
createDirectory(file(".addons-dont-touch/src/main/scala"))
|
||||
addonsources.foreach(as => {
|
||||
val addonname = as.toString.split("/").head
|
||||
copyDirectory(as, file(".addons-dont-touch/src/main/scala/"+addonname))
|
||||
})
|
||||
}
|
||||
|
||||
lazy val addons = Project("addons", file(".addons-dont-touch"), settings = buildSettings ++ Seq(
|
||||
prepareTask := prepareTaskImpl,
|
||||
(compile in Compile) <<= (compile in Compile) dependsOn (prepareTask)
|
||||
)) dependsOn(chisel, hardfloat, uncore, rocket, zscale)
|
||||
lazy val rocketchip = Project("rocketchip", file("."), settings = buildSettings ++ chipSettings).dependsOn(chisel, uncore, rocket, zscale, addons)
|
||||
|
||||
val elaborateTask = InputKey[Unit]("elaborate", "convert chisel components into backend source code")
|
||||
val makeTask = InputKey[Unit]("make", "trigger backend-specific makefile command")
|
||||
|
||||
def runChisel(args: Seq[String], cp: Classpath, pr: ResolvedProject) = {
|
||||
val numArgs = 1
|
||||
require(args.length >= numArgs, "syntax: elaborate <component> [chisel args]")
|
||||
val projectName = pr.id
|
||||
val packageName = projectName //TODO: valid convention?
|
||||
val componentName = args(0)
|
||||
val classLoader = new java.net.URLClassLoader(cp.map(_.data.toURI.toURL).toArray, cp.getClass.getClassLoader)
|
||||
val chiselMainClass = classLoader.loadClass("Chisel.chiselMain$")
|
||||
val chiselMainObject = chiselMainClass.getDeclaredFields.head.get(null)
|
||||
val chiselMain = chiselMainClass.getMethod("run", classOf[Array[String]], classOf[Function0[_]])
|
||||
val chiselArgs = args.drop(numArgs)
|
||||
val component = classLoader.loadClass((if (!componentName.contains('.')) packageName+"." else "")+componentName)
|
||||
val generator = () => component.newInstance()
|
||||
chiselMain.invoke(chiselMainObject, Array(chiselArgs.toArray, generator):_*)
|
||||
}
|
||||
lazy val addons = settingKey[Seq[String]]("list of addons used for this build")
|
||||
lazy val make = inputKey[Unit]("trigger backend-specific makefile command")
|
||||
val setMake = NotSpace ~ ( Space ~> NotSpace )
|
||||
|
||||
val chipSettings = Seq(
|
||||
elaborateTask <<= inputTask { (argTask: TaskKey[Seq[String]]) =>
|
||||
(argTask, fullClasspath in Runtime, thisProject) map {
|
||||
runChisel
|
||||
}
|
||||
addons := {
|
||||
val a = sys.env.getOrElse("ROCKETCHIP_ADDONS", "")
|
||||
println(s"Using addons: $a")
|
||||
a.split(",")
|
||||
},
|
||||
makeTask <<= inputTask { (argTask: TaskKey[Seq[String]]) =>
|
||||
(argTask, fullClasspath in Runtime, thisProject) map {
|
||||
(args: Seq[String], cp: Classpath, pr: ResolvedProject) => {
|
||||
require(args.length >= 2, "syntax: <dir> <target>")
|
||||
runChisel(args.drop(2), cp, pr)
|
||||
val makeDir = args(0)
|
||||
val target = args(1)
|
||||
val jobs = java.lang.Runtime.getRuntime.availableProcessors
|
||||
val make = "make -C" + makeDir + " -j" + jobs + " " + target
|
||||
make!
|
||||
}
|
||||
}
|
||||
unmanagedSourceDirectories in Compile ++= addons.value.map(baseDirectory.value / _ / "src/main/scala"),
|
||||
mainClass in (Compile, run) := Some("rocketchip.TestGenerator"),
|
||||
make := {
|
||||
val jobs = java.lang.Runtime.getRuntime.availableProcessors
|
||||
val (makeDir, target) = setMake.parsed
|
||||
(run in Compile).evaluated
|
||||
s"make -C $makeDir -j $jobs $target" !
|
||||
}
|
||||
)
|
||||
}
|
||||
|
@ -78,8 +78,6 @@ class Top extends Module with TopLevelParameters {
|
||||
val temp = Module(new ZscaleTop)
|
||||
io.host <> temp.io.host
|
||||
}
|
||||
|
||||
TestGeneration.generateMakefrag
|
||||
}
|
||||
|
||||
class MultiChannelTop extends Module with TopLevelParameters {
|
||||
|
@ -60,7 +60,7 @@ run-$kind-tests: $$(addprefix $$(output_dir)/, $$(addsuffix .out, $targets))
|
||||
\t@echo; perl -ne 'print " [$$$$1] $$$$ARGV \\t$$$$2\\n" if /\\*{3}(.{8})\\*{3}(.*)/' $$^; echo;
|
||||
run-$kind-tests-debug: $$(addprefix $$(output_dir)/, $$(addsuffix .vpd, $targets))
|
||||
\t@echo; perl -ne 'print " [$$$$1] $$$$ARGV \\t$$$$2\\n" if /\\*{3}(.{8})\\*{3}(.*)/' $$(patsubst %.vpd,%.out,$$^); echo;
|
||||
run-$kind-fast: $$(addprefix $$(output_dir)/, $$(addsuffix .run, $targets))
|
||||
run-$kind-tests-fast: $$(addprefix $$(output_dir)/, $$(addsuffix .run, $targets))
|
||||
\t@echo; perl -ne 'print " [$$$$1] $$$$ARGV \\t$$$$2\\n" if /\\*{3}(.{8})\\*{3}(.*)/' $$^; echo;
|
||||
"""
|
||||
} else { "\n" }
|
||||
@ -118,3 +118,9 @@ object DefaultTestSuites {
|
||||
"bb","bc","bf","bh","bj","bk","bm","bo","br","bs","ce","cf","cg","ci","ck","cl",
|
||||
"cm","cs","cv","cy","dc","df","dm","do","dr","ds","du","dv").map(_+"_matmul")).toSet)
|
||||
}
|
||||
|
||||
object TestGenerator extends App {
|
||||
val gen = () => Class.forName("rocketchip."+args(0)).newInstance().asInstanceOf[Module]
|
||||
chiselMain.run(args.drop(1), gen)
|
||||
TestGeneration.generateMakefrag
|
||||
}
|
||||
|
@ -71,6 +71,4 @@ class ZscaleTop extends Module {
|
||||
sys.io.host <> io.host
|
||||
bootmem.io <> sys.io.bootmem
|
||||
dram.io <> sys.io.dram
|
||||
|
||||
TestGeneration.generateMakefrag
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user