Skip to content
This repository has been archived by the owner on Jun 16, 2024. It is now read-only.

Commit

Permalink
infer board if only 1 choice; BuildTask can use subdirs too.
Browse files Browse the repository at this point in the history
  • Loading branch information
kivikakk committed May 26, 2024
1 parent 23a0614 commit ac9b19a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 17 deletions.
29 changes: 21 additions & 8 deletions src/main/scala/ee/hrzn/chryse/ChryseApp.scala
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,22 @@ abstract class ChryseApp {
version(versionBanner)

object build extends Subcommand("build") {
banner("Build the design, and optionally program it.")
val onto =
if (targetPlatforms.length > 1) ""
else s" onto ${targetPlatforms(0).id}"
banner(s"Build the design$onto, and optionally program it.")

val board =
choice(
targetPlatforms.map(_.id),
argName = "board",
descr = s"Board to build for.", // XXX (Scallop): It appends " Choices: …". Kinda ugly.
required = true,
)
if (targetPlatforms.length > 1)
Some(
choice(
targetPlatforms.map(_.id),
argName = "board",
descr = s"Board to build for.", // XXX (Scallop): It appends " Choices: …". Kinda ugly.
required = true,
),
)
else None
val program =
opt[Boolean](
descr = "Program the design onto the board after building",
Expand Down Expand Up @@ -113,9 +121,14 @@ abstract class ChryseApp {
Conf.subcommand match {
case Some(Conf.build) =>
println(versionBanner)
val platform =
if (targetPlatforms.length > 1)
targetPlatforms.find(_.id == Conf.build.board.get()).get
else
targetPlatforms(0)
tasks.BuildTask(
this,
targetPlatforms.find(_.id == Conf.build.board()).get,
platform,
tasks.BuildTask.Options(
Conf.build.program(),
Conf.build.fullStacktrace(),
Expand Down
18 changes: 9 additions & 9 deletions src/main/scala/ee/hrzn/chryse/tasks/BuildTask.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ object BuildTask extends BaseTask {
): Unit = {
println(s"Building for ${platform.id} ...")

Files.createDirectories(Paths.get(buildDir))
Files.createDirectories(Paths.get(buildDir, platform.id))

val name = chryse.name

val verilogPath = s"$buildDir/$name-${platform.id}.sv"
val verilogPath = s"$buildDir/${platform.id}/$name.sv"
var lastPCF: Option[PCF] = None
val verilog =
ChiselStage.emitSystemVerilog(
Expand All @@ -48,8 +48,8 @@ object BuildTask extends BaseTask {
)
writePath(verilogPath, verilog)

val yosysScriptPath = s"$buildDir/$name-${platform.id}.ys"
val jsonPath = s"$buildDir/$name-${platform.id}.json"
val yosysScriptPath = s"$buildDir/${platform.id}/$name.ys"
val jsonPath = s"$buildDir/${platform.id}/$name.json"
writePath(
yosysScriptPath,
s"""read_verilog -sv $verilogPath
Expand All @@ -66,17 +66,17 @@ object BuildTask extends BaseTask {
"-q",
"-g",
"-l",
s"$buildDir/$name-${platform.id}.rpt",
s"$buildDir/${platform.id}/$name.rpt",
"-s",
yosysScriptPath,
),
)
runCu(CmdStepSynthesise, yosysCu)

val pcfPath = s"$buildDir/$name-${platform.id}.pcf"
val pcfPath = s"$buildDir/${platform.id}/$name.pcf"
writePath(pcfPath, lastPCF.get.toString())

val ascPath = s"$buildDir/$name-${platform.id}.asc"
val ascPath = s"$buildDir/${platform.id}/$name.asc"
val ascCu = CompilationUnit(
Some(jsonPath),
Seq(pcfPath),
Expand All @@ -85,7 +85,7 @@ object BuildTask extends BaseTask {
platform.nextpnrBinary,
"-q",
"--log",
s"$buildDir/$name-${platform.id}.tim",
s"$buildDir/${platform.id}/$name.tim",
"--json",
jsonPath,
"--pcf",
Expand All @@ -96,7 +96,7 @@ object BuildTask extends BaseTask {
)
runCu(CmdStepPNR, ascCu)

val binPath = s"$buildDir/$name-${platform.id}.bin"
val binPath = s"$buildDir/${platform.id}/$name.bin"
val binCu = CompilationUnit(
Some(ascPath),
Seq(),
Expand Down

0 comments on commit ac9b19a

Please sign in to comment.