mirror of
https://github.com/SpinalHDL/SpinalTemplateSbt.git
synced 2025-10-22 23:58:44 +08:00
refactor: simplify project structure
This commit is contained in:
@@ -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)
|
||||
)
|
||||
|
||||
|
7
build.sc
7
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"
|
||||
|
1
hw/gen/.gitignore
vendored
Normal file
1
hw/gen/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
*
|
16
hw/spinal/projectname/Config.scala
Normal file
16
hw/spinal/projectname/Config.scala
Normal file
@@ -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
|
||||
}
|
@@ -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())
|
||||
}
|
@@ -1,4 +1,4 @@
|
||||
package mylib
|
||||
package projectname
|
||||
|
||||
import spinal.core._
|
||||
import spinal.core.formal._
|
@@ -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)
|
||||
|
0
hw/verilog/.gitignore
vendored
Normal file
0
hw/verilog/.gitignore
vendored
Normal file
0
hw/vhdl/.gitignore
vendored
Normal file
0
hw/vhdl/.gitignore
vendored
Normal file
@@ -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())
|
||||
}
|
Reference in New Issue
Block a user