Skip to content

Commit cf7573e

Browse files
committed
Create empty Chisel project
0 parents  commit cf7573e

9 files changed

+266
-0
lines changed

.gitignore

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Scala .gitignore
2+
#
3+
# JARs aren't checked in, they are fetched by sbt
4+
#
5+
/lib/*.jar
6+
/test/files/codelib/*.jar
7+
/test/files/lib/*.jar
8+
/test/files/speclib/instrumented.jar
9+
/tools/*.jar
10+
11+
# Developer specific properties
12+
/build.properties
13+
/buildcharacter.properties
14+
15+
# might get generated when testing Jenkins scripts locally
16+
/jenkins.properties
17+
18+
# target directory for build
19+
/build/
20+
21+
# other
22+
/out/
23+
/bin/
24+
/sandbox/
25+
26+
# intellij
27+
/src/intellij*/*.iml
28+
/src/intellij*/*.ipr
29+
/src/intellij*/*.iws
30+
**/.cache
31+
/.idea
32+
/.settings
33+
34+
# vscode
35+
/.vscode
36+
37+
# Standard symbolic link to build/quick/bin
38+
/qbin
39+
40+
# sbt's target directories
41+
/target/
42+
/project/**/target/
43+
/test/macro-annot/target/
44+
/test/files/target/
45+
/test/target/
46+
/build-sbt/
47+
local.sbt
48+
jitwatch.out
49+
50+
# Used by the restarr/restarrFull commands as target directories
51+
/build-restarr/
52+
/target-restarr/
53+
54+
# metals
55+
.metals
56+
.bloop
57+
project/**/metals.sbt
58+
project/metals.sbt
59+
60+
# custom
61+
.bsp
62+
.addons-dont-touch
63+
.DS_Store
64+
generated
65+
docs/generated
66+
test_run_dir
67+
tmp

.scalafix.conf

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
rules = [
2+
RemoveUnused,
3+
DisableSyntax,
4+
LeakingImplicitClassVal,
5+
NoAutoTupling,
6+
NoValInForComprehension,
7+
OrganizeImports,
8+
ProcedureSyntax,
9+
]
10+
11+
OrganizeImports {
12+
groupedImports = Merge
13+
}
14+
15+
RemoveUnused {
16+
imports = false // handled by OrganizeImports
17+
}

.scalafmt.conf

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
version = "2.7.5"
2+
maxColumn = 120
3+
align.preset = most
4+
align.multiline = false
5+
continuationIndent.defnSite = 2
6+
assumeStandardLibraryStripMargin = true
7+
docstrings = JavaDoc
8+
lineEndings = preserve
9+
includeCurlyBraceInSelectChains = false
10+
danglingParentheses.preset = true
11+
optIn.annotationNewlines = true
12+
newlines.alwaysBeforeMultilineDef = false
13+
14+
rewrite.rules = [RedundantBraces]
15+
16+
rewrite.redundantBraces.generalExpressions = false
17+
rewriteTokens = {
18+
"⇒": "=>"
19+
"→": "->"
20+
"←": "<-"
21+
}

LICENSE

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
© IBM Corp. 2019
2+
This softcore is licensed under and subject to the terms of the CC-BY 4.0
3+
license (https://creativecommons.org/licenses/by/4.0/legalcode).
4+
Additional rights, including the right to physically implement a softcore
5+
that is compliant with the required sections of the Power ISA
6+
Specification, will be available at no cost via the OpenPOWER Foundation.
7+
This README will be updated with additional information when OpenPOWER's
8+
license is available.

Makefile

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
SHELL = bash
2+
# Project name
3+
project = toplevel
4+
5+
generated_files = generated
6+
7+
# Targets
8+
chisel: check-board-vars clean ## Generates Verilog code from Chisel sources using Mill
9+
scripts/mill $(project).run -board ${BOARD} -td $(generated_files)
10+
11+
chisel-sbt: check-board-vars clean ## Generates Verilog code from Chisel sources using SBT
12+
sbt "run -board ${BOARD} -td $(generated_files)"
13+
14+
chisel_tests:
15+
scripts/mill $(project).test
16+
17+
chisel_tests_sbt:
18+
sbt "test"
19+
20+
check: chisel_tests ## Run Chisel tests using Mill
21+
check-sbt: chisel_tests_sbt ## Run Chisel tests using SBT
22+
23+
fmt: ## Formats code using scalafmt and scalafix
24+
scripts/mill all $(project).{reformat,fix}
25+
26+
check-board-vars:
27+
@test -n "$(BOARD)" || (echo "Set BOARD variable to one of the supported boards: " ; cat pmod1.core|grep "\-board" |cut -d '-' -f 2|sed s/\"//g | sed s/board\ //g |tr -s '\n' ','| sed 's/,$$/\n/'; echo "Eg. make chisel BOARD=ulx3s"; echo; exit 1)
28+
29+
clean: ## Clean all generated files
30+
@./scripts/mill clean
31+
@rm -rf obj_dir test_run_dir target
32+
@rm -rf $(generated_files)
33+
@rm -rf out
34+
@rm -f $(project)
35+
36+
help:
37+
@echo "Makefile targets:"
38+
@echo ""
39+
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = "[:##]"}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$4}'
40+
@echo ""
41+
42+
.PHONY: chisel clean prog help
43+
.DEFAULT_GOAL := help

README.md

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Chisel Blinky
2+
3+
This is a simple Blinky project to demonstrate Chisel functionality with scripts
4+
and tooling to be able to synth on FPGA boards.
5+
6+
## Synthesis using Open Source tools (yosys/nextpnr)
7+
8+
Synthesis on FPGAs is supported with yosys/nextpnr. At the moment the tools support
9+
Lattice ECP5 FPGAs. The build process uses Docker images, so no software other than Docker needs
10+
to be installed. If you prefer podman you can use that too, just adjust it in
11+
`Makefile`, `DOCKER=podman`.
12+
13+
### Building and programming the FPGA
14+
15+
The `Makefile` currently supports the following FPGA boards by defining the `BOARD` parameter on make:
16+
17+
* Lattice [ECP5 Evaluation Board](http://www.latticesemi.com/ecp5-evaluation) - `evn`
18+
* Radiona [ULX3S](https://radiona.org/ulx3s/) - `ulx3s`
19+
* Greg Davill [Orangecrab](https://github.com/gregdavill/OrangeCrab) - `orangecrab`
20+
* Q3k [Colorlight](https://github.com/q3k/chubby75/tree/master/5a-75b) - `colorlight`
21+
22+
For example, to build for the ULX3S Board, run:
23+
24+
```sh
25+
make BOARD=ulx3s synth`
26+
```
27+
28+
and to program the FPGA:
29+
30+
```sh
31+
make BOARD=ulx3s prog
32+
33+
# or if your USB device has a different path, pass it on USBDEVICE, like:
34+
35+
make BOARD=ulx3s USBDEVICE=/dev/tty.usbserial-120001 prog
36+
```
37+
38+
Programming using OpenOCD on Docker does not work on Docker Desktop for Mac/Windows since the container is run in a Linux VM and can not see the physical devices connected to the Host.
39+
40+
For the ULX3S board, the current OpenOCD does not support ft232 protocol so to program it, download [ujprog](https://github.com/emard/ulx3s-bin/tree/master/usb-jtag) for your platform and program using `./ujprog chiselwatt.bit` or to persist in the flash, `./ujprog -j FLASH chiselwatt.bit`.

build.sbt

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
// See README.md for license details.
2+
3+
ThisBuild / organization := "com.carlosedp"
4+
ThisBuild / description := "ChiselV is a RISC-V core written in Chisel"
5+
ThisBuild / homepage := Some(url("https://carlosedp.com"))
6+
ThisBuild / licenses := Seq("MIT" -> url("https://opensource.org/licenses/MIT"))
7+
ThisBuild / scmInfo := Some(
8+
ScmInfo(url("https://github.com/carlosedp/"), "[email protected]:carlosedp/.git")
9+
)
10+
ThisBuild / developers := List(
11+
Developer("carlosedp", "Carlos Eduardo de Paula", "[email protected]", url("https://github.com/carlosedp"))
12+
)
13+
ThisBuild / scalafixDependencies += "com.github.liancheng" %% "organize-imports" % "0.5.0"
14+
Global / semanticdbEnabled := true
15+
Global / semanticdbVersion := "4.4.28" //scalafixSemanticdb.revision // Force version due to compatibility issues
16+
Global / onChangedBuildSource := ReloadOnSourceChanges
17+
18+
lazy val chiselv = (project in file("."))
19+
.settings(
20+
name := "chiselv",
21+
version := "0.0.1",
22+
scalaVersion := "2.13.6"
23+
)
24+
25+
// Default library versions
26+
val defaultVersions = Map(
27+
"chisel3" -> "3.5-SNAPSHOT",
28+
"chiseltest" -> "0.5-SNAPSHOT",
29+
"scalatest" -> "3.2.9",
30+
"organize-imports" -> "0.5.0"
31+
)
32+
// Import libraries
33+
libraryDependencies ++= Seq("chisel3", "chiseltest").map { dep: String =>
34+
"edu.berkeley.cs" %% dep % sys.props
35+
.getOrElse(dep + "Version", defaultVersions(dep))
36+
}
37+
libraryDependencies += "org.scalatest" %% "scalatest" % defaultVersions("scalatest")
38+
libraryDependencies += "com.carlosedp" %% "scalautils" % "0.4.0"
39+
ThisBuild / scalafixDependencies += "com.github.liancheng" %% "organize-imports" % defaultVersions("organize-imports")
40+
addCompilerPlugin("edu.berkeley.cs" % "chisel3-plugin" % defaultVersions("chisel3") cross CrossVersion.full)
41+
42+
// Aliases
43+
addCommandAlias("com", "all compile test:compile")
44+
addCommandAlias("rel", "reload")
45+
addCommandAlias("fmt", "all scalafmtSbt scalafmtAll;all compile:scalafix test:scalafix")
46+
addCommandAlias("fix", "all Compile / scalafixAll Test / scalafixAll")
47+
addCommandAlias("lint", "fmt;fix")
48+
addCommandAlias("deps", "reload plugins; dependencyUpdates; reload return; dependencyUpdates")
49+
50+
resolvers ++= Seq(
51+
Resolver.sonatypeRepo("snapshots"),
52+
Resolver.sonatypeRepo("releases")
53+
)
54+
55+
scalacOptions ++= Seq(
56+
"-unchecked",
57+
"-deprecation",
58+
"-language:reflectiveCalls",
59+
"-feature",
60+
"-Xcheckinit",
61+
"-Xfatal-warnings",
62+
"-Ywarn-value-discard",
63+
"-Ywarn-dead-code",
64+
"-Ywarn-unused"
65+
)

project/build.properties

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
sbt.version=1.5.5

project/plugins.sbt

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.2")
2+
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.29")
3+
addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.19")
4+
addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.6.0")

0 commit comments

Comments
 (0)