Skip to content

Commit

Permalink
Merge pull request #8 from abs-tudelft/feature/ci
Browse files Browse the repository at this point in the history
Enable CI
  • Loading branch information
ccromjongh authored Jan 24, 2024
2 parents c5064c4 + 1ad178e commit f5c1171
Show file tree
Hide file tree
Showing 33 changed files with 797 additions and 588 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: CI
on:
push:
branches: ["main"]
tags: ["v*"]
pull_request:
branches: ["*"]

jobs:
build:
strategy:
fail-fast: false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
cache: 'sbt'

- name: Test
run: sbt --client ci

- name: Test publishing
run: sbt --client publishLocal
21 changes: 21 additions & 0 deletions .scalafix.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
rules = [
OrganizeImports,
DisableSyntax,
LeakingImplicitClassVal,
NoValInForComprehension,
ProcedureSyntax,
ExplicitResultTypes
]
ExplicitResultTypes.memberKind = [
Def
]
OrganizeImports {
coalesceToWildcardImportThreshold = 5
expandRelative = false
groupExplicitlyImportedImplicitsSeparately = false
groupedImports = Merge
groups = ["re:javax?\\.", "scala.", "*"]
importSelectorsOrder = SymbolsFirst
importsOrder = Ascii
removeUnused = false
}
9 changes: 9 additions & 0 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version = 3.7.17
maxColumn = 120
runner.dialect = scala213Source3
preset=IntelliJ
indent.extendSite = 6
align.preset=more
rewrite.redundantBraces.stringInterpolation = true
newlines.afterCurlyLambdaParams=squash
docstrings.style = keep
40 changes: 29 additions & 11 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,26 +1,44 @@
ThisBuild / name := "Tydi-Chisel"
ThisBuild / description := "Tydi-Chisel is an implementation of Tydi concepts in the Chisel HDL."
ThisBuild / homepage := Some(url("https://github.com/ccromjongh/tydi-chisel"))
ThisBuild / name := "Tydi-Chisel"
ThisBuild / description := "Tydi-Chisel is an implementation of Tydi concepts in the Chisel HDL."
ThisBuild / homepage := Some(url("https://github.com/abs-tudelft/tydi-chisel"))
ThisBuild / organizationHomepage := Some(url("https://github.com/abs-tudelft/"))
ThisBuild / licenses := List(License.Apache2)
ThisBuild / version := "0.1.0"
ThisBuild / organization := "nl.tudelft"
ThisBuild / licenses := List(License.Apache2)
ThisBuild / version := "0.1.0"
ThisBuild / organization := "nl.tudelft"
ThisBuild / organizationName := "ABS Group, Delft University of Technology"
ThisBuild / startYear := Some(2023)

ThisBuild / scalaVersion := "2.13.12"

val chiselVersion = "5.1.0"

lazy val root = (project in file("."))
.settings(
name := "Tydi-Chisel",
libraryDependencies += "org.chipsalliance" %% "chisel" % chiselVersion,
libraryDependencies += "edu.berkeley.cs" %% "chiseltest" % "5.0.2",
libraryDependencies += "org.chipsalliance" %% "chisel" % chiselVersion,
libraryDependencies += "edu.berkeley.cs" %% "chiseltest" % "5.0.2",
scalacOptions ++= Seq(
"-language:reflectiveCalls",
"-deprecation",
"-feature",
"-Xcheckinit",
"-Ymacro-annotations",
"-Ymacro-annotations"
),
addCompilerPlugin("org.chipsalliance" % "chisel-plugin" % chiselVersion cross CrossVersion.full),
addCompilerPlugin("org.chipsalliance" % "chisel-plugin" % chiselVersion cross CrossVersion.full)
)

inThisBuild(
List(
semanticdbEnabled := true,
semanticdbVersion := scalafixSemanticdb.revision,
scalafixScalaBinaryVersion := scalaBinaryVersion.value
)
)

val CICommands =
Seq("clean", "compile", "test", "scalafmtCheckAll", "scalafmtSbtCheck", "scalafixAll --check").mkString(";")

val PrepareCICommands = Seq("scalafixAll", "scalafmtAll", "scalafmtSbt").mkString(";")

addCommandAlias("ci", CICommands)

addCommandAlias("preCI", PrepareCICommands)
4 changes: 4 additions & 0 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
logLevel := Level.Warn

// Code quality
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2")
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.11.1")
2 changes: 1 addition & 1 deletion src/main/scala/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ object Main {
def main(args: Array[String]): Unit = {
println("Hello world!")
}
}
}
18 changes: 9 additions & 9 deletions src/main/scala/gcd/DecoupledGCD.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class GcdOutputBundle(val w: Int) extends Bundle {
* Can handle stalls on the producer or consumer side
*/
class DecoupledGcd(width: Int) extends Module {
val input = IO(Flipped(Decoupled(new GcdInputBundle(width))))
val input = IO(Flipped(Decoupled(new GcdInputBundle(width))))
val output = IO(Decoupled(new GcdOutputBundle(width)))

val xInitial = Reg(UInt())
Expand All @@ -34,11 +34,11 @@ class DecoupledGcd(width: Int) extends Module {
val busy = RegInit(false.B)
val resultValid = RegInit(false.B)

input.ready := ! busy
input.ready := !busy
output.valid := resultValid
output.bits := DontCare
output.bits := DontCare

when(busy) {
when(busy) {
when(x > y) {
x := x - y
}.otherwise {
Expand All @@ -53,21 +53,21 @@ class DecoupledGcd(width: Int) extends Module {

output.bits.value1 := xInitial
output.bits.value2 := yInitial
resultValid := true.B
resultValid := true.B

when(output.ready && resultValid) {
busy := false.B
busy := false.B
resultValid := false.B
}
}
}.otherwise {
when(input.valid) {
val bundle = input.deq()
x := bundle.value1
y := bundle.value2
x := bundle.value1
y := bundle.value2
xInitial := bundle.value1
yInitial := bundle.value2
busy := true.B
busy := true.B
}
}
}
6 changes: 3 additions & 3 deletions src/main/scala/gcd/GCD.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ class GCD extends Module {
val outputValid = Output(Bool())
})

val x = Reg(UInt())
val y = Reg(UInt())
val x = Reg(UInt())
val y = Reg(UInt())

when(x > y) { x := x - y }
.otherwise { y := y - x }
Expand All @@ -29,6 +29,6 @@ class GCD extends Module {
y := io.value2
}

io.outputGCD := x
io.outputGCD := x
io.outputValid := y === 0.U
}
27 changes: 14 additions & 13 deletions src/main/scala/nl/tudelft/tydi_chisel/ReverseTranspiler.scala
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
package nl.tudelft.tydi_chisel

import chisel3.Data
import scala.collection.mutable

import chisel3.Data

object ReverseTranspiler {
implicit class BitsTranspile(e: Data) extends TranspileExtend {
def tydiCode: String = {
e match {
case el: PhysicalStreamBase => el.tydiCode
case el: Group => el.tydiCode
case el: Union => el.tydiCode
case el: Null => el.tydiCode
case el: Group => el.tydiCode
case el: Union => el.tydiCode
case el: Null => el.tydiCode
case _ => {
s"$fingerprint = Bit(${e.getWidth}); // ${e.toString}"
}
Expand All @@ -21,9 +22,9 @@ object ReverseTranspiler {
var m = map
e match {
case el: PhysicalStreamBase => el.transpile(m)
case el: Group => el.transpile(m)
case el: Union => el.transpile(m)
case el: Null => el.transpile(m)
case el: Group => el.transpile(m)
case el: Union => el.transpile(m)
case el: Null => el.transpile(m)
case _ => {
val s = fingerprint
if (m.contains(s)) return m
Expand All @@ -36,16 +37,16 @@ object ReverseTranspiler {
def fingerprint: String = {
e match {
case el: PhysicalStreamBase => el.fingerprint
case el: Group => el.fingerprint
case el: Union => el.fingerprint
case el: Null => el.fingerprint
case el: Group => el.fingerprint
case el: Union => el.fingerprint
case el: Null => el.fingerprint
case _ => {
val strRep = e.toString
val name = strRep.replace("<", "_").replace(">", "_").stripSuffix("_")
val hash = name.hashCode.toHexString.substring(0, 4)
val name = strRep.replace("<", "_").replace(">", "_").stripSuffix("_")
val hash = name.hashCode.toHexString.substring(0, 4)
s"${name}_$hash"
}
}
}
}
}
}
Loading

0 comments on commit f5c1171

Please sign in to comment.