27 Commits

Author SHA1 Message Date
Dolu1990
324e3dce52 SpinalHDL 1.12.3 2025-08-15 12:31:10 +02:00
Dolu1990
976ceca3a3 Update Config.scala
onlyStdLogicVectorAtTopLevelIo = false as it prevent VHDL / GHDL sim
2025-04-06 14:58:20 +02:00
Dolu1990
2aefabbbad SpinalHDL 1.12.0 2025-03-19 07:53:23 +01:00
Dolu1990
52417f9d8c SpinalHDL 1.11.0 2024-12-17 11:00:48 +01:00
Dolu1990
1629b51311 Merge pull request #42 from samuelgruetter/update_build_tools
update mill and sbt version
2024-10-14 10:16:44 +02:00
Samuel Gruetter
fc9ca1ffd9 update mill and sbt version 2024-10-10 14:26:47 +02:00
Dolu1990
d7575b9a5d Merge pull request #41 from cheungxi/master
upgrade scala version to 2.13.14
2024-09-03 17:53:48 +02:00
Zhang Xi
c2950be884 upgrade scala version to 2.13.14 2024-09-02 17:50:22 +08:00
Dolu1990
8456715b1c SpinalHDL 1.10.2a 2024-07-04 10:10:06 +02:00
Dolu1990
4b7dfe2d2b SpinalHDL 1.10.2 2024-06-13 11:12:43 +02:00
Dolu1990
3b84555158 SpinalHDL 1.10.1 2024-02-01 10:35:36 +01:00
Dolu1990
51249d4c6e SpinalHDL 1.10.0 2024-01-04 10:10:33 +01:00
Dolu1990
17607424ab Merge pull request #36 from IanBoyanZhang/patch-1
Fix typo in README
2023-11-06 11:46:07 +01:00
Ian Zhang
f3256ed4e1 Fix typo in README 2023-11-04 16:35:54 -07:00
Dolu1990
766b80b3f1 SpinalHDL 1.9.4 2023-11-01 09:41:06 +01:00
Dolu1990
f47ac2f65f SpinalHDL 1.9.3 2023-08-16 10:01:33 +02:00
Dolu1990
9fe5ded40a SpinalHDL 1.9.0 for build.sc too <3 2023-07-21 17:46:38 +02:00
Dolu1990
2bf3acd857 SpinalHDL 1.9.0 2023-07-21 17:42:13 +02:00
Dolu1990
a4eb1e65ef SpinalHDL 1.8.1 2023-03-27 09:57:17 +02:00
Dolu1990
88fb4a7f49 SpinalHDL 1.8.0 2022-12-05 20:26:59 +01:00
Dolu1990
950e9c2c72 Merge pull request #27 from SpinalHDL/25-readme-pointing-to-getting-started-from-rtd
Readme pointing to Getting started from RTD
2022-11-30 18:39:16 +01:00
Côme
dd76ac14f7 Update README.md 2022-11-30 14:45:35 +01:00
Côme
3929e815a5 Add instructions to modify the template 2022-11-30 14:42:49 +01:00
Côme
cb8b3565b9 Readme pointing to Getting started from RTD 2022-11-30 14:17:32 +01:00
Dolu1990
121ba1514d Update README.md 2022-11-28 10:49:19 +01:00
Dolu1990
07a5beaf08 Merge pull request #23 from numero-744/rework-structure
Structure suggestion
2022-11-28 10:47:29 +01:00
Côme ALLART
4849860e14 refactor: simplify project structure 2022-11-25 10:39:48 +01:00
13 changed files with 96 additions and 149 deletions

View File

@@ -1 +1 @@
0.9.8
0.11.11

165
README.md
View File

@@ -1,140 +1,83 @@
Spinal Base Project
============
This repository is a base SBT project added to help non Scala/SBT native people in their first steps.
# SpinalHDL Base Project
Just one important note, you need a java JDK >= 8
This repository is a base project to help Spinal users set-up project without knowledge about Scala and SBT.
On debian :
## If it is your are learning SpinalHDL
You can follow the tutorial on the [Getting Started](https://spinalhdl.github.io/SpinalDoc-RTD/master/SpinalHDL/Getting%20Started/index.html) page.
More specifically:
* instructions to install tools can be found on the [Install and setup](https://spinalhdl.github.io/SpinalDoc-RTD/master/SpinalHDL/Getting%20Started/Install%20and%20setup.html#install-and-setup) page
* instructions to get this repository locally are available in the [Create a SpinalHDL project](https://spinalhdl.github.io/SpinalDoc-RTD/master/SpinalHDL/Getting%20Started/Install%20and%20setup.html#create-a-spinalhdl-project) section.
### TL;DR Things have already been set up in my environment, how do I run things to try SpinalHDL?
Once in the `SpinalTemplateSbt` directory, when tools are installed, the commands below can be run to use `sbt`.
```sh
sudo add-apt-repository -y ppa:openjdk-r/ppa
sudo apt-get update
sudo apt-get install openjdk-8-jdk -y
// To generate the Verilog from the example
sbt "runMain projectname.MyTopLevelVerilog"
#To set the default java
sudo update-alternatives --config java
sudo update-alternatives --config javac
// To generate the VHDL from the example
sbt "runMain projectname.MyTopLevelVhdl"
// To run the testbench
sbt "runMain projectname.MyTopLevelSim"
```
## Basics, without any IDE
* The example hardware description is into `hw/spinal/projectname/MyTopLevel.scala`
* The testbench is into `hw/spinal/projectname/MyTopLevelSim.scala`
You need to install SBT
When you really start working with SpinalHDL, it is recommended (both for comfort and efficiency) to use an IDE, see the [Getting started](https://spinalhdl.github.io/SpinalDoc-RTD/master/SpinalHDL/Getting%20Started/index.html).
```sh
echo "deb https://repo.scala-sbt.org/scalasbt/debian all main" | sudo tee /etc/apt/sources.list.d/sbt.list
echo "deb https://repo.scala-sbt.org/scalasbt/debian /" | sudo tee /etc/apt/sources.list.d/sbt_old.list
curl -sL "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x2EE0EA64E40A89B84B2DF73499E82A75642AC823" | sudo apt-key add
sudo apt-get update
sudo apt-get install sbt
```
If you want to run the scala written testbench, you have to be on linux and have Verilator installed (a recent version) :
## If you want to create a new project from this template
```sh
sudo apt-get install git make autoconf g++ flex bison -y # First time prerequisites
git clone http://git.veripool.org/git/verilator # Only first time
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
autoconf # Create ./configure script
./configure
make -j$(nproc)
sudo make install
cd ..
echo "DONE"
### Change project name
```
You might want to change the project name, which is currently `projectname`. To do so (let's say your actual project name is `myproject`; it must be all lowercase with no separators):
Clone or download this repository.
* Update `build.sbt` and/or `build.sc` by replacing `projectname` by the name of your project `myproject` (1 occurrence in each file). The better is to replace in both (it will always work), but in some contexts you can keep only one of these two files:
* If you are sure all people only use `sbt`, you can replace only in `build.sbt` and remove `build.sc`
* If you are sure all people only use `mill`, you can replace only in `build.sc` and remove `build.sbt`
* Replace in both files for open-source project.
* Put all your scala files into `hw/spinal/myproject/` (remove the unused `hw/spinal/projectname/` folder)
* Start all your scala files with `package myproject`
```sh
git clone https://github.com/SpinalHDL/SpinalTemplateSbt.git
```
Open a terminal in the root of it and run "sbt run". At the first execution, the process could take some seconds
### Change project structure
```sh
cd SpinalTemplateSbt
You can change the project structure as you want. The only restrictions (from Scala environment) are (let's say your actual project name is `myproject`):
//If you want to generate the Verilog of your design
sbt "runMain mylib.MyTopLevelVerilog"
* you must have a `myproject` folder and files in it must start with `package myproject`
* if you have a file in a subfolder `myproject/somepackage/MyElement.scala` it must start with `package myproject.somepackage`.
* `sbt` and `mill` must be run right in the folder containing their configurations (recommended to not move these files)
//If you want to generate the VHDL of your design
sbt "runMain mylib.MyTopLevelVhdl"
Once the project structure is modified, update configurations:
//If you want to run the scala written testbench
sbt "runMain mylib.MyTopLevelSim"
```
* In `build.sbt` and/or `build.sc` (see above) replace `/ "hw" / "spinal"` by the new path to the folder containing the `myproject` folder.
* In the spinal configuration file (if you kept it, by default it is in `projectname/Config.scala`) change the path in `targetDirectory = "hw/gen"` to the directory where you want generated files to be written. If you don't use a config or if it doesn't contain this element, generated files will be written in the root directory.
The top level spinal code is defined into src\main\scala\mylib
## Basics, with Intellij IDEA and its scala plugin
### Update this README
You need to install :
Of course you can replace/modify this file to help people with your own project!
- Java JDK 8
- SBT
- Intellij IDEA (the free Community Edition is good enough)
- Intellij IDEA Scala plugin (when you run Intellij IDEA the first time, he will ask you about it)
And do the following :
- Clone or download this repository.
- In Intellij IDEA, "import project" with the root of this repository, Import project from external model SBT
- In addition maybe you need to specify some path like JDK to Intellij
- In the project (Intellij project GUI), go in src/main/scala/mylib/MyTopLevel.scala, right click on MyTopLevelVerilog, "Run MyTopLevelVerilog"
Normally, this must generate an MyTopLevel.v output files.
## Basics, with Eclipse and its scala plugin
First, i "strongly" suggest to use intellij idea instead.
You need to install :
- Java JDK
- Scala
- SBT
- Eclipse (tested with Mars.2 - 4.5.2)
- [scala plugin](http://scala-ide.org/) (tested with 4.4.1)
And do the following :
- Clone or download this repository.
- Revert changes from https://github.com/SpinalHDL/SpinalTemplateSbt/commit/173bbb9bb8cbf70087339104f6ebced9321908dd
- Run ```sbt eclipse``` in the ```SpinalTemplateSbt``` directory.
- Import the eclipse project from eclipse.
- In the project (eclipse project GUI), right click on src/main/scala/mylib/MyTopLevel.scala, right click on MyTopLevelVerilog, and select run it
Normally, this must generate output file ```MyTopLevel.v```.
## Mill Support (Experimental)
This Spinal Base Project contains support for the [Mill build tool](https://com-lihaoyi.github.io/mill).
The prerequisites are the same as for using SBT, except for sbt itself. Additionally, the ```mill``` executable needs to be installed on the path. Download it to ```/usr/local/bin/mill``` or ```~/bin/mill``` according to the [installation instructions](https://com-lihaoyi.github.io/mill/mill/Intro_to_Mill.html#_installation).
You can clone and use this repository in the following way.
The [Mill build tool](https://com-lihaoyi.github.io/mill) can be installed and used instead of `sbt`.
```sh
git clone https://github.com/SpinalHDL/SpinalTemplateSbt.git
// To generate the Verilog from the example
mill projectname.runMain projectname.MyTopLevelVerilog
// To generate the VHDL from the example
mill projectname.runMain projectname.MyTopLevelVhdl
// To run the testbench
mill projectname.runMain projectname.MyTopLevelSim
```
Open a terminal in the root of it and execute your favorite mill command. At the first execution, the process could take some seconds
```sh
cd SpinalTemplateSbt
//If you want to generate the Verilog of your design
mill mylib.runMain mylib.MyTopLevelVerilog
//If you want to generate the VHDL of your design
mill mylib.runMain mylib.MyTopLevelVhdl
//If you want to run the scala written testbench
mill mylib.runMain mylib.MyTopLevelSim
```
The top level spinal code is defined into src\main\scala\mylib

View File

@@ -1,15 +1,16 @@
ThisBuild / version := "1.0"
ThisBuild / scalaVersion := "2.12.16"
ThisBuild / scalaVersion := "2.13.14"
ThisBuild / organization := "org.example"
val spinalVersion = "1.7.3"
val spinalVersion = "1.12.3"
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",
name := "myproject",
Compile / scalaSource := baseDirectory.value / "hw" / "spinal",
libraryDependencies ++= Seq(spinalCore, spinalLib, spinalIdslPlugin)
)

View File

@@ -1,10 +1,13 @@
import mill._, scalalib._
val spinalVersion = "1.7.3"
val spinalVersion = "1.12.3"
object mylib extends SbtModule {
def scalaVersion = "2.12.14"
object projectname extends SbtModule {
def scalaVersion = "2.13.14"
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
View File

@@ -0,0 +1 @@
*

View 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 = false
)
def sim = SimConfig.withConfig(spinal).withFstWave
}

View File

@@ -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())
}

View File

@@ -1,4 +1,4 @@
package mylib
package projectname
import spinal.core._
import spinal.core.formal._

View File

@@ -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
View File

0
hw/vhdl/.gitignore vendored Normal file
View File

View File

@@ -1 +1 @@
sbt.version=1.6.0
sbt.version=1.10.2

View 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())
}