diff --git a/build.sbt b/build.sbt index bf44f25..f1c1c33 100644 --- a/build.sbt +++ b/build.sbt @@ -7,9 +7,9 @@ val spinalCore = "com.github.spinalhdl" %% "spinalhdl-core" % spinalVersion val spinalLib = "com.github.spinalhdl" %% "spinalhdl-lib" % spinalVersion val spinalIdslPlugin = compilerPlugin("com.github.spinalhdl" %% "spinalhdl-idsl-plugin" % spinalVersion) -lazy val mylib = (project in file(".")) +lazy val projectname = (project in file(".")) .settings( - name := "SpinalTemplateSbt", + Compile / scalaSource := baseDirectory.value / "hw" / "spinal", libraryDependencies ++= Seq(spinalCore, spinalLib, spinalIdslPlugin) ) diff --git a/build.sc b/build.sc index 9070381..688b576 100644 --- a/build.sc +++ b/build.sc @@ -2,9 +2,12 @@ import mill._, scalalib._ val spinalVersion = "1.7.3" -object mylib extends SbtModule { - def scalaVersion = "2.12.14" +object projectname extends SbtModule { + def scalaVersion = "2.12.16" override def millSourcePath = os.pwd + def sources = T.sources( + millSourcePath / "hw" / "spinal" + ) def ivyDeps = Agg( ivy"com.github.spinalhdl::spinalhdl-core:$spinalVersion", ivy"com.github.spinalhdl::spinalhdl-lib:$spinalVersion" diff --git a/hw/gen/.gitignore b/hw/gen/.gitignore new file mode 100644 index 0000000..72e8ffc --- /dev/null +++ b/hw/gen/.gitignore @@ -0,0 +1 @@ +* diff --git a/hw/spinal/projectname/Config.scala b/hw/spinal/projectname/Config.scala new file mode 100644 index 0000000..f3a2e3e --- /dev/null +++ b/hw/spinal/projectname/Config.scala @@ -0,0 +1,16 @@ +package projectname + +import spinal.core._ +import spinal.core.sim._ + +object Config { + def spinal = SpinalConfig( + targetDirectory = "hw/gen", + defaultConfigForClockDomains = ClockDomainConfig( + resetActiveLevel = HIGH + ), + onlyStdLogicVectorAtTopLevelIo = true + ) + + def sim = SimConfig.withConfig(spinal).withFstWave +} diff --git a/src/main/scala/mylib/MyTopLevel.scala b/hw/spinal/projectname/MyTopLevel.scala similarity index 67% rename from src/main/scala/mylib/MyTopLevel.scala rename to hw/spinal/projectname/MyTopLevel.scala index bda00e5..894096e 100644 --- a/src/main/scala/mylib/MyTopLevel.scala +++ b/hw/spinal/projectname/MyTopLevel.scala @@ -1,4 +1,4 @@ -package mylib +package projectname import spinal.core._ @@ -20,3 +20,11 @@ case class MyTopLevel() extends Component { io.state := counter io.flag := (counter === 0) | io.cond1 } + +object MyTopLevelVerilog extends App { + Config.spinal.generateVerilog(MyTopLevel()) +} + +object MyTopLevelVhdl extends App { + Config.spinal.generateVhdl(MyTopLevel()) +} diff --git a/src/main/scala/mylib/MyTopLevelFormal.scala b/hw/spinal/projectname/MyTopLevelFormal.scala similarity index 97% rename from src/main/scala/mylib/MyTopLevelFormal.scala rename to hw/spinal/projectname/MyTopLevelFormal.scala index 7047665..608bf8a 100644 --- a/src/main/scala/mylib/MyTopLevelFormal.scala +++ b/hw/spinal/projectname/MyTopLevelFormal.scala @@ -1,4 +1,4 @@ -package mylib +package projectname import spinal.core._ import spinal.core.formal._ diff --git a/src/main/scala/mylib/MyTopLevelSim.scala b/hw/spinal/projectname/MyTopLevelSim.scala similarity index 92% rename from src/main/scala/mylib/MyTopLevelSim.scala rename to hw/spinal/projectname/MyTopLevelSim.scala index 1442a16..d6cbb42 100644 --- a/src/main/scala/mylib/MyTopLevelSim.scala +++ b/hw/spinal/projectname/MyTopLevelSim.scala @@ -1,10 +1,10 @@ -package mylib +package projectname import spinal.core._ import spinal.core.sim._ object MyTopLevelSim extends App { - SimConfig.withWave.doSim(MyTopLevel()) { dut => + Config.sim.compile(MyTopLevel()).doSim { dut => // Fork a process to generate the reset and the clock on the dut dut.clockDomain.forkStimulus(period = 10) diff --git a/hw/verilog/.gitignore b/hw/verilog/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/hw/vhdl/.gitignore b/hw/vhdl/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/src/main/scala/mylib/MyTopLevelGen.scala b/src/main/scala/mylib/MyTopLevelGen.scala deleted file mode 100644 index cbcaa0b..0000000 --- a/src/main/scala/mylib/MyTopLevelGen.scala +++ /dev/null @@ -1,25 +0,0 @@ -package mylib - -import spinal.core._ - -object MyTopLevelVerilog extends App { - // Generate the MyTopLevel's Verilog - SpinalVerilog(MyTopLevel()) -} - -object MyTopLevelVhdl extends App { - // Generate the MyTopLevel's VHDL - SpinalVhdl(MyTopLevel()) -} - -// Custom SpinalHDL configuration with synchronous reset instead of the default asynchronous one -// This configuration can be resued everywhere -object MySpinalConfig - extends SpinalConfig( - defaultConfigForClockDomains = ClockDomainConfig(resetKind = SYNC) - ) - -object MyTopLevelVerilogWithCustomConfig extends App { - // Generate the MyTopLevel's Verilog using the above custom configuration. - MySpinalConfig.generateVerilog(MyTopLevel()) -}