diff --git a/template/.github/workflows/dependency-graph.yml b/template/.github/workflows/dependency-graph.yml deleted file mode 100644 index dce40a4..0000000 --- a/template/.github/workflows/dependency-graph.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: update dependency graph - -on: - push: - branches: - - main - -permissions: - contents: write - -jobs: - dependency-graph: - runs-on: ubuntu-latest - steps: - - name: Checkout chryse - uses: actions/checkout@v4 - with: - repository: kivikakk/chryse - - name: Set up JDK 22 - uses: actions/setup-java@v4 - with: - java-version: '22' - distribution: 'temurin' - cache: 'sbt' - - name: Build and install chryse locally - run: sbt publishLocal - - - name: Checkout this - uses: actions/checkout@v4 - - uses: scalacenter/sbt-dependency-submission@v2 diff --git a/template/.github/workflows/synth-ice40.yml b/template/.github/workflows/synth-ice40.yml deleted file mode 100644 index d860284..0000000 --- a/template/.github/workflows/synth-ice40.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: iCE40 synthesis - -on: - push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] - -permissions: - contents: read - -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout chryse - uses: actions/checkout@v4 - with: - repository: kivikakk/chryse - - name: Set up JDK 22 - uses: actions/setup-java@v4 - with: - java-version: '22' - distribution: 'temurin' - cache: 'sbt' - - name: Build and install chryse locally - run: sbt publishLocal - - - name: Install OSS CAD Suite - uses: YosysHQ/setup-oss-cad-suite@v3 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - - run: yosys --version - - - name: Checkout this - uses: actions/checkout@v4 - - name: Elaborate - run: sbt run - - name: Synthesise - run: make ice40 diff --git a/template/.github/workflows/unit-tests.yml b/template/.github/workflows/unit-tests.yml deleted file mode 100644 index de45f39..0000000 --- a/template/.github/workflows/unit-tests.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: Unit tests - -on: - push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] - -permissions: - contents: read - -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout chryse - uses: actions/checkout@v4 - with: - repository: kivikakk/chryse - - name: Set up JDK 22 - uses: actions/setup-java@v4 - with: - java-version: '22' - distribution: 'temurin' - cache: 'sbt' - - name: Build and install chryse locally - run: sbt publishLocal - - - name: Checkout this - uses: actions/checkout@v4 - - name: Run tests - run: sbt test diff --git a/template/.gitignore b/template/.gitignore deleted file mode 100644 index cdb525f..0000000 --- a/template/.gitignore +++ /dev/null @@ -1,18 +0,0 @@ -build/ - -*.asc -*.bin -*.vcd -*.json -*.rpt -*.tim -*.sv - -target/ -test_run_dir/ - -.metals/ -.bloop/ -metals.sbt - -.DS_Store diff --git a/template/.scalafmt.conf b/template/.scalafmt.conf deleted file mode 100644 index a72825b..0000000 --- a/template/.scalafmt.conf +++ /dev/null @@ -1,47 +0,0 @@ -version = "3.7.15" -runner.dialect = scala213 - -maxColumn = 80 - -newlines.avoidForSimpleOverflow = [slc, tooLong] - -assumeStandardLibraryStripMargin = true - -align.preset = most -align.multiline = false -align.tokens."+" = [ - { code = ":=", owner = "Term.ApplyInfix" }, - { code = "+=", owner = "Term.ApplyInfix" }, - { code = "++=", owner = "Term.ApplyInfix" }, - { code = "--=", owner = "Term.ApplyInfix" }, - { code = "-=", owner = "Term.ApplyInfix" }, -] - -binPack.literalArgumentLists = true -binPack.literalsIncludeSimpleExpr = true -binPack.literalsExclude = [ "Term.Name" ] - -# do I care about this? -docstrings.style = "SpaceAsterisk" -docstrings.wrap = yes -docstrings.oneline = fold - -rewrite.rules = [ - AvoidInfix, # do I want this? - RedundantBraces, - RedundantParens, - SortModifiers, - PreferCurlyFors, - Imports, -] - -rewrite.redundantBraces.maxBreaks = 1 -rewrite.redundantBraces.stringInterpolation = true - -rewrite.trailingCommas.style = always - -# unsure. -# includeCurlyBraceInSelectChains = false - -project.includePaths = ["glob:**.scala", "glob:**.sbt", "glob:**.sc", "glob:**.md"] -project.excludePaths = ["glob:**metals.sbt"] \ No newline at end of file diff --git a/template/Makefile b/template/Makefile deleted file mode 100644 index ca26dcb..0000000 --- a/template/Makefile +++ /dev/null @@ -1,41 +0,0 @@ -BASENAME = Top -BUILD_DIR = build -ARTIFACT_PREFIX = $(BUILD_DIR)/$(BASENAME) - -SCALA_SRCS = $(shell find src/main/scala) - -.PHONY: ice40-prog clean - -all: - @echo "Targets:" - @echo " make ice40" - @echo " make ice40-prog" - @echo " make clean" - -clean: - -rm build/* - -$(BASENAME)-%.sv: $(SCALA_SRCS) - sbt run - -ice40: $(ARTIFACT_PREFIX).bin - -ice40-prog: $(ARTIFACT_PREFIX).bin - iceprog $< - -$(ARTIFACT_PREFIX).bin: $(ARTIFACT_PREFIX).asc - icepack $< $@ - -$(ARTIFACT_PREFIX).asc: $(ARTIFACT_PREFIX).json $(BASENAME)-ice40.pcf - nextpnr-ice40 -q --log $(ARTIFACT_PREFIX).tim \ - --up5k --package sg48 \ - --json $(ARTIFACT_PREFIX).json \ - --pcf $(BASENAME)-ice40.pcf \ - --asc $@ - -$(ARTIFACT_PREFIX).json: $(BASENAME)-ice40.sv - @mkdir -p $(BUILD_DIR) - yosys -q -g -l $(ARTIFACT_PREFIX).rpt \ - -p 'read_verilog -sv $<' \ - -p 'synth_ice40 -top top' \ - -p 'write_json $@' diff --git a/template/Top-ice40.pcf b/template/Top-ice40.pcf deleted file mode 100644 index 1fea5ba..0000000 --- a/template/Top-ice40.pcf +++ /dev/null @@ -1,7 +0,0 @@ -set_io clki 35 -set_frequency clki 12.0 - -set_io io_ubtn 10 - -set_io io_ledr 11 -set_io io_ledg 37 diff --git a/template/build.sbt b/template/build.sbt deleted file mode 100644 index da08b59..0000000 --- a/template/build.sbt +++ /dev/null @@ -1,44 +0,0 @@ -import scala.sys.process._ - -ThisBuild / scalaVersion := "2.13.12" -ThisBuild / version := "0.1.0" -ThisBuild / organization := "com.example" - -val chiselVersion = "6.3.0" - -lazy val root = (project in file(".")) - .settings( - name := "newproject", - libraryDependencies ++= Seq( - "org.chipsalliance" %% "chisel" % chiselVersion, - "org.scalatest" %% "scalatest" % "3.2.18" % "test", - "edu.berkeley.cs" %% "chiseltest" % "6.0.0", - "ee.hrzn" %% "chryse" % "0.1.0-SNAPSHOT", - ), - scalacOptions ++= Seq( - "-language:reflectiveCalls", "-deprecation", "-feature", "-Xcheckinit", - "-Ymacro-annotations", - ), - addCompilerPlugin( - "org.chipsalliance" % "chisel-plugin" % chiselVersion cross CrossVersion.full, - ), - ) - -// TODO: we want to move these into chryse itself, to be imported into projects that use it. -// Same for cxxsim stuff. -lazy val ice40 = inputKey[Unit]("Elaborate and synthesise for ice40") -ice40 := { - (Compile / run).evaluated - if (("make ice40" !) != 0) { - throw new IllegalStateException("ice40 failed to synthesise") - } -} - -lazy val ice40prog = - inputKey[Unit]("Elaborate, synthesise for ice40, and program the board") -ice40prog := { - (Compile / run).evaluated - if (("make ice40-prog" !) != 0) { - throw new IllegalStateException("ice40 failed to synthesise") - } -} diff --git a/template/project/build.properties b/template/project/build.properties deleted file mode 100644 index b19d4e1..0000000 --- a/template/project/build.properties +++ /dev/null @@ -1 +0,0 @@ -sbt.version = 1.9.7 diff --git a/template/project/plugins.sbt b/template/project/plugins.sbt deleted file mode 100644 index 5708f81..0000000 --- a/template/project/plugins.sbt +++ /dev/null @@ -1 +0,0 @@ -logLevel := Level.Warn diff --git a/template/src/main/scala/com/example/newproject/Top.scala b/template/src/main/scala/com/example/newproject/Top.scala deleted file mode 100644 index 63aa141..0000000 --- a/template/src/main/scala/com/example/newproject/Top.scala +++ /dev/null @@ -1,54 +0,0 @@ -package com.example.newproject - -import _root_.circt.stage.ChiselStage -import chisel3._ -import chisel3.util._ -import ee.hrzn.chryse.HasIO -import ee.hrzn.chryse.platform.ElaboratablePlatform -import ee.hrzn.chryse.platform.Platform -import ee.hrzn.chryse.platform.ice40.ICE40Platform - -import java.io.PrintWriter - -class TopIO extends Bundle { - val ledr = Output(Bool()) - val ledg = Output(Bool()) -} - -class Top(implicit platform: Platform) extends Module with HasIO[TopIO] { - def createIo() = new TopIO - - private val ledReg = RegInit(true.B) - io.ledr := ledReg - val timerReg = RegInit( - ((platform.clockHz / 4) - 1) - .U(unsignedBitLength((platform.clockHz / 2) - 1).W), - ) - when(timerReg === 0.U) { - ledReg := ~ledReg - timerReg := ((platform.clockHz / 2) - 1).U - }.otherwise { - timerReg := timerReg - 1.U - } - - io.ledg := false.B -} - -object Top extends App { - def apply()(implicit platform: ElaboratablePlatform) = - platform(new Top) - - implicit private val platform: ElaboratablePlatform = ICE40Platform - private val firtoolOpts = Array( - "--lowering-options=disallowLocalVariables", - "-disable-all-randomization", - "-strip-debug-info", - ) - val verilog = - ChiselStage.emitSystemVerilog(Top(), firtoolOpts = firtoolOpts) - new PrintWriter(s"Top-${platform.id}.sv", "utf-8") { - try - write(verilog) - finally close() - } -} diff --git a/template/src/test/scala/com/example/newproject/TopSpec.scala b/template/src/test/scala/com/example/newproject/TopSpec.scala deleted file mode 100644 index 2f043f0..0000000 --- a/template/src/test/scala/com/example/newproject/TopSpec.scala +++ /dev/null @@ -1,28 +0,0 @@ -package com.example.newproject - -import chisel3._ -import chiseltest._ -import chiseltest.simulator.WriteVcdAnnotation -import ee.hrzn.chryse.platform.Platform -import org.scalatest.flatspec.AnyFlatSpec - -class TopSpec extends AnyFlatSpec with ChiselScalatestTester { - behavior.of("Top") - - implicit private val platform: Platform = new Platform { - val id = "topspec" - val clockHz = 8 - } - - it should "blink the light" in { - test(new Top()).withAnnotations(Seq(WriteVcdAnnotation)) { c => - // ledg is always false (on). - // ledr starts true (off) for 1/4 duty, then toggles evenly at 1/2 duty. - for { ledr <- Seq(1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1) } { - c.io.ledg.expect(false.B) - c.io.ledr.expect((ledr == 1).B) - c.clock.step() - } - } - } -}