mirror of
https://github.com/SpinalHDL/SpinalTemplateSbt.git
synced 2025-10-24 16:38:43 +08:00
Compare commits
3 Commits
9ccca0f64a
...
121ba1514d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
121ba1514d | ||
|
|
07a5beaf08 | ||
|
|
4849860e14 |
14
README.md
14
README.md
@@ -37,7 +37,7 @@ unsetenv VERILATOR_ROOT # For csh; ignore error if on bash
|
||||
unset VERILATOR_ROOT # For bash
|
||||
cd verilator
|
||||
git pull # Make sure we're up-to-date
|
||||
git checkout v4.040
|
||||
git checkout v4.216
|
||||
autoconf # Create ./configure script
|
||||
./configure
|
||||
make -j$(nproc)
|
||||
@@ -59,13 +59,13 @@ Open a terminal in the root of it and run "sbt run". At the first execution, the
|
||||
cd SpinalTemplateSbt
|
||||
|
||||
//If you want to generate the Verilog of your design
|
||||
sbt "runMain mylib.MyTopLevelVerilog"
|
||||
sbt "runMain projectname.MyTopLevelVerilog"
|
||||
|
||||
//If you want to generate the VHDL of your design
|
||||
sbt "runMain mylib.MyTopLevelVhdl"
|
||||
sbt "runMain projectname.MyTopLevelVhdl"
|
||||
|
||||
//If you want to run the scala written testbench
|
||||
sbt "runMain mylib.MyTopLevelSim"
|
||||
sbt "runMain projectname.MyTopLevelSim"
|
||||
```
|
||||
|
||||
The top level spinal code is defined into src\main\scala\mylib
|
||||
@@ -128,13 +128,13 @@ Open a terminal in the root of it and execute your favorite mill command. At the
|
||||
cd SpinalTemplateSbt
|
||||
|
||||
//If you want to generate the Verilog of your design
|
||||
mill mylib.runMain mylib.MyTopLevelVerilog
|
||||
mill projectname.runMain projectname.MyTopLevelVerilog
|
||||
|
||||
//If you want to generate the VHDL of your design
|
||||
mill mylib.runMain mylib.MyTopLevelVhdl
|
||||
mill projectname.runMain projectname.MyTopLevelVhdl
|
||||
|
||||
//If you want to run the scala written testbench
|
||||
mill mylib.runMain mylib.MyTopLevelSim
|
||||
mill projectname.runMain projectname.MyTopLevelSim
|
||||
```
|
||||
|
||||
The top level spinal code is defined into src\main\scala\mylib
|
||||
|
||||
@@ -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