This repository has been archived by the owner on Jun 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 10135c6
Showing
14 changed files
with
251 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: Update Dependency Graph | ||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
dependency-graph: | ||
name: Update Dependency Graph | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: scalacenter/sbt-dependency-submission@v2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: Unit tests | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up JDK 22 | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: '22' | ||
distribution: 'temurin' | ||
cache: 'sbt' | ||
- name: Run tests | ||
run: sbt test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
target/ | ||
test_run_dir/ | ||
|
||
.metals/ | ||
.bloop/ | ||
metals.sbt | ||
|
||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
ThisBuild / scalaVersion := "2.13.12" | ||
ThisBuild / version := "0.1.0-SNAPSHOT" | ||
ThisBuild / organization := "ee.hrzn" | ||
|
||
val chiselVersion = "6.3.0" | ||
|
||
lazy val root = (project in file(".")) | ||
.settings( | ||
name := "chryse", | ||
libraryDependencies ++= Seq( | ||
"org.chipsalliance" %% "chisel" % chiselVersion, | ||
"org.scalatest" %% "scalatest" % "3.2.18" % "test", | ||
"edu.berkeley.cs" %% "chiseltest" % "6.0.0", | ||
), | ||
scalacOptions ++= Seq( | ||
"-language:reflectiveCalls", "-deprecation", "-feature", "-Xcheckinit", | ||
"-Ymacro-annotations", | ||
), | ||
addCompilerPlugin( | ||
"org.chipsalliance" % "chisel-plugin" % chiselVersion cross CrossVersion.full, | ||
), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
sbt.version = 1.9.7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
logLevel := Level.Warn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package ee.hrzn.chryse | ||
|
||
import chisel3._ | ||
|
||
// This looks a lot like the FixedIO*Module stuff. | ||
|
||
trait HasIO[ContainedIO <: Data] extends RawModule { | ||
def createIo(): ContainedIO | ||
|
||
val io = IO(createIo()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package ee.hrzn.chryse.platform | ||
|
||
import chisel3._ | ||
import ee.hrzn.chryse.HasIO | ||
import ee.hrzn.chryse.platform.Platform | ||
|
||
class GenericTop[Top <: HasIO[_ <: Data]](genTop: => Top)(implicit | ||
platform: Platform, | ||
) extends Module { | ||
override def desiredName = "top" | ||
|
||
private val top = Module(genTop) | ||
private val io = IO(top.createIo()) | ||
io :<>= top.io.as[Data] | ||
} | ||
|
||
object GenericTop { | ||
def apply[Top <: HasIO[_ <: Data]](genTop: => Top)(implicit | ||
platform: Platform, | ||
) = new GenericTop(genTop) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package ee.hrzn.chryse.platform | ||
|
||
import chisel3._ | ||
import ee.hrzn.chryse.HasIO | ||
|
||
// Similar to chisel3.choice.ModuleChoice. | ||
|
||
trait Platform { | ||
val id: String | ||
val clockHz: Int | ||
} | ||
|
||
trait ElaboratablePlatform extends Platform { | ||
def apply[Top <: HasIO[_ <: Data]](top: => Top)(implicit | ||
platform: Platform, | ||
): RawModule | ||
} |
16 changes: 16 additions & 0 deletions
16
src/main/scala/ee/hrzn/chryse/platform/cxxrtl/CXXRTLPlatform.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package ee.hrzn.chryse.platform.cxxrtl | ||
|
||
import chisel3._ | ||
import ee.hrzn.chryse.HasIO | ||
import ee.hrzn.chryse.platform.ElaboratablePlatform | ||
import ee.hrzn.chryse.platform.GenericTop | ||
import ee.hrzn.chryse.platform.Platform | ||
|
||
case object CXXRTLPlatform extends ElaboratablePlatform { | ||
val id = "cxxrtl" | ||
val clockHz = 3_000_000 | ||
|
||
override def apply[Top <: HasIO[_ <: Data]](top: => Top)(implicit | ||
platform: Platform, | ||
) = GenericTop(top) | ||
} |
15 changes: 15 additions & 0 deletions
15
src/main/scala/ee/hrzn/chryse/platform/ice40/ICE40Platform.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package ee.hrzn.chryse.platform.ice40 | ||
|
||
import chisel3._ | ||
import ee.hrzn.chryse.HasIO | ||
import ee.hrzn.chryse.platform.ElaboratablePlatform | ||
import ee.hrzn.chryse.platform.Platform | ||
|
||
case object ICE40Platform extends ElaboratablePlatform { | ||
val id = "ice40" | ||
val clockHz = 12_000_000 | ||
|
||
override def apply[Top <: HasIO[_ <: Data]](top: => Top)(implicit | ||
platform: Platform, | ||
) = ICE40Top(top) | ||
} |
43 changes: 43 additions & 0 deletions
43
src/main/scala/ee/hrzn/chryse/platform/ice40/ICE40Top.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package ee.hrzn.chryse.platform.ice40 | ||
|
||
import chisel3._ | ||
import chisel3.util._ | ||
import ee.hrzn.chryse.HasIO | ||
import ee.hrzn.chryse.platform.Platform | ||
import ee.hrzn.chryse.sb.SB_GB | ||
|
||
class ICE40Top[Top <: HasIO[_ <: Data]](genTop: => Top)(implicit | ||
platform: Platform, | ||
) extends RawModule { | ||
override def desiredName = "top" | ||
|
||
private val clki = IO(Input(Clock())) | ||
|
||
private val clk_gb = Module(new SB_GB) | ||
clk_gb.USER_SIGNAL_TO_GLOBAL_BUFFER := clki | ||
private val clk = clk_gb.GLOBAL_BUFFER_OUTPUT | ||
|
||
private val timerLimit = (15e-6 * platform.clockHz).toInt | ||
private val resetTimerReg = | ||
withClock(clk)(Reg(UInt(unsignedBitLength(timerLimit).W))) | ||
private val reset = Wire(Bool()) | ||
|
||
when(resetTimerReg === timerLimit.U) { | ||
reset := false.B | ||
}.otherwise { | ||
reset := true.B | ||
resetTimerReg := resetTimerReg + 1.U | ||
} | ||
private val io_ubtn = IO(Input(Bool())) | ||
|
||
private val top = | ||
withClockAndReset(clk, reset | ~io_ubtn)(Module(genTop)) | ||
private val io = IO(top.createIo()) | ||
io :<>= top.io.as[Data] | ||
} | ||
|
||
object ICE40Top { | ||
def apply[Top <: HasIO[_ <: Data]](genTop: => Top)(implicit | ||
platform: Platform, | ||
) = new ICE40Top(genTop) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package ee.hrzn.chryse.sb | ||
|
||
import chisel3._ | ||
import chisel3.experimental.ExtModule | ||
|
||
class SB_GB extends ExtModule { | ||
val USER_SIGNAL_TO_GLOBAL_BUFFER = IO(Input(Clock())) | ||
val GLOBAL_BUFFER_OUTPUT = IO(Output(Clock())) | ||
} |