From fa1ec62a0474c9ee1fabd02cf55484134451fe30 Mon Sep 17 00:00:00 2001 From: Dolu Date: Tue, 21 Apr 2015 12:28:03 +0200 Subject: [PATCH] Boot --- .gitignore | 28 +++++++++++++++++ README.md | 38 +++++++++++++++++++++++ build.sbt | 11 +++++++ project/plugin.sbt | 0 src/main/scala/MyCode/TopLevel.scala | 46 ++++++++++++++++++++++++++++ 5 files changed, 123 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 build.sbt create mode 100644 project/plugin.sbt create mode 100644 src/main/scala/MyCode/TopLevel.scala diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7e2b277 --- /dev/null +++ b/.gitignore @@ -0,0 +1,28 @@ +*.class +*.log +*.bak + +# sbt specific +.cache/ +.history/ +.lib/ +dist/* +target +lib_managed/ +src_managed/ +project/boot/ +project/plugins/project/ + +# Scala-IDE specific +.scala_dependencies +.worksheet + +.idea +out + + +#User +*.vhd +*.cf +*.json +!tester/src/test/resources/*.vhd diff --git a/README.md b/README.md new file mode 100644 index 0000000..fb91661 --- /dev/null +++ b/README.md @@ -0,0 +1,38 @@ +Spinal Base Project +============ +This repository is a base SBT project added to help non Scala/SBT native people in their first steps. + +## Basics, without any IDE + +You need to install : + +- Java JDK +- Scala +- SBT + +And do the following : + +- Clone or download this repository. +- Open a terminal in the root of it and run "sbt run". At the first execution, the process could take some seconds + +Normally, this command must generate output files MyTopLevel.vhd. +The top level spinal code is defined into src\main\scala\MyCode + +## Basics, with Intellij IDEA and his scala plugin + +You need to install : + +- Java JDK +- Scala +- SBT +- Intellij IDEA (the free Community Edition is nice) +- Intellij IDEA Scala plugin + +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, Check all box +- In addition maybe you need to specify some path like JDK to Intellij +- In the project (Intellij project GUI), right click on src/main/scala/MyCode/TopLeve.scala and select "Run MyTopLevel" + +Normally, this must generate output files MyTopLevel.vhd. \ No newline at end of file diff --git a/build.sbt b/build.sbt new file mode 100644 index 0000000..a67d812 --- /dev/null +++ b/build.sbt @@ -0,0 +1,11 @@ +name := "SpinalBaseProject" + +version := "1.0" + +scalaVersion := "2.11.6" + + +libraryDependencies ++= Seq( + "com.github.spinalhdl" % "spinalhdl-core_2.11" % "latest.release", + "com.github.spinalhdl" % "spinalhdl-lib_2.11" % "latest.release" +) \ No newline at end of file diff --git a/project/plugin.sbt b/project/plugin.sbt new file mode 100644 index 0000000..e69de29 diff --git a/src/main/scala/MyCode/TopLevel.scala b/src/main/scala/MyCode/TopLevel.scala new file mode 100644 index 0000000..852512d --- /dev/null +++ b/src/main/scala/MyCode/TopLevel.scala @@ -0,0 +1,46 @@ +/* + * SpinalHDL + * Copyright (c) Dolu, All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3.0 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. + */ + +package MyCode + +import spinal.core._ +import spinal.lib._ + +class MyTopLevel extends Component { + val io = new Bundle { + val cond0 = in Bool + val cond1 = in Bool + val flag = out Bool + val state = out UInt(8 bit) + } + val counter = Reg(UInt(8 bit)) init(0) + + when(io.cond0){ + counter := counter + 1 + } + + io.state := counter + io.flag := (counter === 0) | io.cond1 +} + +object MyTopLevel { + def main(args: Array[String]) { + SpinalVhdl(new MyTopLevel) + } +} +