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

Commit

Permalink
just really pog off
Browse files Browse the repository at this point in the history
  • Loading branch information
kivikakk committed May 14, 2024
1 parent fb93e39 commit 564cbae
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
17 changes: 13 additions & 4 deletions src/main/scala/ee/hrzn/chryse/ChryseApp.scala
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,17 @@ abstract class ChryseApp {
opt[Unit]('d', "debug")
.action((_, c) => c.copy(cxxrtlDebug = true))
.text("generate source-level debug information"),
opt[Unit]('v', "vcd")
.action((_, c) => c.copy(cxxrtlVcd = true))
.text("output a VCD file when running cxxsim (passes --vcd)"),
opt[String]('v', "vcd")
.valueName("<file>")
.action((p, c) => c.copy(cxxrtlVcdOutPath = Some(p)))
.text(
"output a VCD file when running cxxsim (passes --vcd <file> to the executable)",
),
arg[String]("<arg>...")
.unbounded()
.optional()
.action((arg, c) => c.copy(cxxrtlArgs = c.cxxrtlArgs :+ arg))
.text("other arguments for the cxxsim executable"),
note(""),
)
}
Expand Down Expand Up @@ -133,7 +141,8 @@ final case class ChryseAppConfig(
cxxrtlCompileOnly: Boolean = false,
cxxrtlOptimize: Boolean = false,
cxxrtlDebug: Boolean = false,
cxxrtlVcd: Boolean = false,
cxxrtlVcdOutPath: Option[String] = None,
cxxrtlArgs: List[String] = List(),
)

class ChryseAppStepFailureException(step: String)
Expand Down
17 changes: 13 additions & 4 deletions src/main/scala/ee/hrzn/chryse/tasks/CxxsimTask.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import scala.sys.process._

object CxxsimTask extends BaseTask {
private val cxxsimDir = "cxxsim"
private val cxxOpts = Seq("-std=c++14", "-g", "-pedantic", "-Wall", "-Wextra",
"-Wno-zero-length-array", "-Wno-unused-parameter")
private val baseCxxOpts = Seq("-std=c++14", "-g", "-pedantic", "-Wall",
"-Wextra", "-Wno-zero-length-array", "-Wno-unused-parameter")

def apply(
name: String,
Expand Down Expand Up @@ -78,6 +78,12 @@ object CxxsimTask extends BaseTask {
val headers = filesInDirWithExt(cxxsimDir, ".h").toSeq

val yosysDatDir = Seq("yosys-config", "--datdir").!!.trim()
val cxxOpts =
baseCxxOpts ++ (if (config.cxxrtlDebug) Seq("-g")
else Seq()) ++
(if (config.cxxrtlOptimize)
Seq("-O3")
else Seq())

def buildPathForCc(cc: String) =
cc.replace(s"$cxxsimDir/", s"$buildDir/")
Expand Down Expand Up @@ -112,8 +118,11 @@ object CxxsimTask extends BaseTask {

if (config.cxxrtlCompileOnly) return

val binArgs = if (config.cxxrtlVcd) Seq("--vcd") else Seq()
val binCmd = Seq(binPath) ++ binArgs
val binArgs = config.cxxrtlVcdOutPath match {
case Some(vcdOutPath) => Seq("--vcd", vcdOutPath)
case _ => Seq()
}
val binCmd = Seq(binPath) ++ binArgs ++ config.cxxrtlArgs

println(s"running: $binCmd")
val rc = binCmd.!
Expand Down

0 comments on commit 564cbae

Please sign in to comment.