This repository is a base project to help Spinal users to design their ysyx npc using Spinal HDL.
This project is a fork from offical SpinalTemplateSbt.
Based on the original template, this template for ysyx npc adds:
- Add
Makefile
to introduce the GNU Make tool and some essential target that ysyx requires (such as tracer). - Delete
build.sbt
and related files to completely remove sbt build tool as Makefile is made only for mill. - Adjust names of objects to be consistent with ysyx project.
Once in the YsyxSpinalTemplate
directory, when tools are installed, the commands below can be run to use make
.
// To generate the Verilog from the example
make verilog
// To run the testbench
make test
- The example hardware description is into
hw/spinal/projectname/MyTopLevel.scala
- The testbench is into
hw/spinal/projectname/MyTopLevelSim.scala
Just like original template, you can still directly run mill
commands to get Verilog, VHDL or start simulation (unit tests).However, this is strongly not recommanded , as elaboration and simulation will not be traced by this way. Just list commands here as reference.
// To generate the Verilog from the example
mill projectname.runMain projectname.Elaborate
// To run the testbench
mill projectname.runMain projectname.Simulate
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):
- Update
build.sc
by replacingprojectname
by the name of your projectmyproject
. - Update
Makefile
by replacingprojectname
by the name of your projectmyproject
. - Put all your scala files into
hw/spinal/myproject/
(remove the unusedhw/spinal/projectname/
folder) . - Start all your scala files with
package myproject
.
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
):
- you must have a
myproject
folder and files in it must start withpackage myproject
. - if you have a file in a subfolder
myproject/somepackage/MyElement.scala
it must start withpackage myproject.somepackage
. mill
must be run right in the folder containing their configurations (recommended to not move these files).
Once the project structure is modified, update configurations:
- In
build.sc
(see above) replace/ "hw" / "spinal"
by the new path to the folder containing themyproject
folder. - In the spinal configuration file (if you kept it, by default it is in
projectname/Config.scala
),targetDirectory = sys.env.getOrElse("TARGET_DIR", "hw/gen")
defines the location of generated verilog. TheTARGET_DIR
is used inMakefile
to cooperate with make variables (BUILD_DIR
) and targets. You may change bothtargetDirectory
in spinal configuration file andBUILD_DIR
inMakefile
.