Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Chisel IP Contribution Tests

on: [push, pull_request]

jobs:
test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Install Verilator
run: |
sudo apt-get install -y verilator
verilator --version

- name: Setup Scala
uses: olafurpg/setup-scala@v11
with:
java-version: openjdk@1.11

- name: Compile
run: sbt compile

- name: Unit Tests
run: sbt test
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
### Project Specific stuff
test_run_dir/*
/generated/

### XilinxISE template
# intermediate build files
*.bgn
Expand Down
122 changes: 48 additions & 74 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,79 +1,53 @@
// See README.md for license details.

def scalacOptionsVersion(scalaVersion: String): Seq[String] = {
Seq() ++ {
// If we're building with Scala > 2.11, enable the compile option
// switch to support our anonymous Bundle definitions:
// https://github.com/scala/bug/issues/10047
CrossVersion.partialVersion(scalaVersion) match {
case Some((2, scalaMajor: Long)) if scalaMajor < 12 => Seq()
case _ => Seq("-Xsource:2.11")
}
}
}

def javacOptionsVersion(scalaVersion: String): Seq[String] = {
Seq() ++ {
// Scala 2.12 requires Java 8. We continue to generate
// Java 7 compatible code for Scala 2.11
// for compatibility with old clients.
CrossVersion.partialVersion(scalaVersion) match {
case Some((2, scalaMajor: Long)) if scalaMajor < 12 =>
Seq("-source", "1.7", "-target", "1.7")
case _ =>
Seq("-source", "1.8", "-target", "1.8")
}
}
}

name := "ip-contributions"

version := "0.4.0"

// groupId, SCM, license information
organization := "edu.berkeley.cs"
homepage := Some(url("https://github.com/freechipsproject/ip-contributions"))
scmInfo := Some(ScmInfo(url("https://github.com/freechipsproject/ip-contributions"), "git@github.com/freechipsproject/ip-contributions"))
developers := List(Developer("schoeberl", "schoeberl", "martin@jopdesign.com", url("https://github.com/schoeberl")))
licenses += ("Unlicense", url("https://unlicense.org/"))
publishMavenStyle := true

// disable publishw ith scala version, otherwise artifact name will include scala version
// e.g cassper_2.11
crossPaths := false

// add sonatype repository settings
// snapshot versions publish to sonatype snapshot repository
// other versions publish to sonatype staging repository
publishTo := Some(
if (isSnapshot.value)
Opts.resolver.sonatypeSnapshots
else
Opts.resolver.sonatypeStaging
)

val scala211 = "2.11.12"
val scala212 = "2.12.8"

scalaVersion := scala212

crossScalaVersions := Seq(scala212, scala211)

resolvers ++= Seq(
Resolver.sonatypeRepo("snapshots"),
Resolver.sonatypeRepo("releases")
ThisBuild / scalaVersion := "2.12.13"
ThisBuild / crossScalaVersions := Seq("2.12.13", "2.13.5")
ThisBuild / version := "0.5-SNAPSHOT"


lazy val publishSettings = Seq (
// groupId, SCM, license information
organization := "edu.berkeley.cs",
homepage := Some(url("https://github.com/freechipsproject/ip-contributions")),
scmInfo := Some(ScmInfo(url("https://github.com/freechipsproject/ip-contributions"), "git@github.com/freechipsproject/ip-contributions")),
developers := List(Developer("schoeberl", "schoeberl", "martin@jopdesign.com", url("https://github.com/schoeberl"))),
licenses += ("Unlicense", url("https://unlicense.org/")),
publishMavenStyle := true,

// disable publish with scala version, otherwise artifact name will include scala version
// e.g cassper_2.11
crossPaths := false,

// add sonatype repository settings
// snapshot versions publish to sonatype snapshot repository
// other versions publish to sonatype staging repository
publishTo := Some(
if (isSnapshot.value)
Opts.resolver.sonatypeSnapshots
else
Opts.resolver.sonatypeStaging
),
)

// Provide a managed dependency on X if -DXVersion="" is supplied on the command line.
val defaultVersions = Map(
"chisel-iotesters" -> "1.5.0",
"chiseltest" -> "0.3.1",
"dsptools" -> "1.4.1"
lazy val root = (project in file("."))
.settings(
name := "ip-contributions",
resolvers += Resolver.sonatypeRepo("snapshots"),
libraryDependencies ++= Seq(
"edu.berkeley.cs" %% "chisel3" % "3.5-SNAPSHOT",
"edu.berkeley.cs" %% "dsptools" % "1.5-SNAPSHOT",
"edu.berkeley.cs" %% "chisel-iotesters" % "2.5-SNAPSHOT" % "test",
"edu.berkeley.cs" %% "chiseltest" % "0.5-SNAPSHOT" % "test",
),
scalacOptions ++= Seq(
"-language:reflectiveCalls",
"-deprecation",
"-feature",
"-Xcheckinit",
// Enables autoclonetype2 in 3.4.x (on by default in 3.5)
"-P:chiselplugin:useBundlePlugin"
),
addCompilerPlugin("edu.berkeley.cs" % "chisel3-plugin" % "3.4.3" cross CrossVersion.full),
addCompilerPlugin("org.scalamacros" % "paradise" % "2.1.1" cross CrossVersion.full)
)

libraryDependencies ++= Seq("chiseltest", "chisel-iotesters", "dsptools").map {
dep: String => "edu.berkeley.cs" %% dep % sys.props.getOrElse(dep + "Version", defaultVersions(dep)) }

scalacOptions ++= scalacOptionsVersion(scalaVersion.value)

javacOptions ++= javacOptionsVersion(scalaVersion.value)
.settings(publishSettings: _*)
5 changes: 3 additions & 2 deletions src/main/scala/chisel/lib/bitonicsorter/BitonicSorter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
package chisel.lib.bitonicsorter

import chisel3._
import chisel3.stage.ChiselStage
import chisel3.util._

/**
Expand Down Expand Up @@ -85,10 +86,10 @@ class BitonicSorterModule[T <: Data]( n : Int, proto : T, lt : (T,T) => Bool) ex

//scalastyle:off magic.number
object BitonicSorterUInt8_64Driver extends App {
Driver.execute( args, () => new BitonicSorterModule( 64, UInt(8.W), (x:UInt,y:UInt)=>x<y))
(new ChiselStage).emitSystemVerilog(new BitonicSorterModule( 64, UInt(8.W), (x:UInt,y:UInt)=>x<y), args)
}

//scalastyle:off magic.number
object BitonicSorterUInt8_384Driver extends App {
Driver.execute( args, () => new BitonicSorterModule( 384, UInt(8.W), (x:UInt,y:UInt)=>x<y))
(new ChiselStage).emitSystemVerilog(new BitonicSorterModule( 384, UInt(8.W), (x:UInt,y:UInt)=>x<y), args)
}
3 changes: 2 additions & 1 deletion src/main/scala/chisel/lib/cordic/iterative/CordicApp.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
package chisel.lib.cordic.iterative

import chisel3._
import chisel3.stage.ChiselStage

/**
* Make an unapply function for the argument parser.
Expand Down Expand Up @@ -62,5 +63,5 @@ object CordicApp extends App {
)
val (chiselArgs, params) = argParse(args.toList, defaultParams)
// Run the Chisel driver to generate a cordic
Driver.execute(chiselArgs.toArray, () => new IterativeCordic(params))
(new ChiselStage).emitSystemVerilog(new IterativeCordic(params), chiselArgs.toArray)
}
3 changes: 2 additions & 1 deletion src/main/scala/chisel/lib/uart/Uart.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
package chisel.lib.uart

import chisel3._
import chisel3.stage.ChiselStage
import chisel3.util._

class UartIO extends DecoupledIO(UInt(8.W)) {
Expand Down Expand Up @@ -209,6 +210,6 @@ class UartMain(frequency: Int, baudRate: Int) extends Module {
}

object UartMain extends App {
chisel3.Driver.execute(Array("--target-dir", "generated"), () => new UartMain(50000000, 115200))
(new ChiselStage).emitSystemVerilog(new UartMain(50000000, 115200), Array("--target-dir", "generated"))
}

Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ package chisel.lib.bitonicsorter

import chisel3._
import chisel3.iotesters._
import org.scalatest.{FlatSpec, Matchers}
import org.scalatest.flatspec.AnyFlatSpec

/**
* Test generator that tests all possible input patterns
* @param factory The generator
* @tparam T The type of elements
*/
class ExhaustiveSorterTest[T <: Bool]( factory : () => SorterModuleIfc[T]) extends FlatSpec with Matchers {
class ExhaustiveSorterTest[T <: Bool]( factory : () => SorterModuleIfc[T]) extends AnyFlatSpec {
behavior of "SorterTest"

it should "work" in {
chisel3.iotesters.Driver( factory, "treadle") { c =>
assert(chisel3.iotesters.Driver( factory, "treadle") { c =>
new PeekPokeTester( c) {
def example( a:IndexedSeq[BigInt]) {
poke( c.io.a, a)
Expand All @@ -33,7 +33,7 @@ class ExhaustiveSorterTest[T <: Bool]( factory : () => SorterModuleIfc[T]) exten
}

}
} should be (true)
})
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package chisel.lib.bitonicsorter

import chisel3._
import chisel3.iotesters._
import org.scalatest.{FlatSpec, Matchers}
import org.scalatest.flatspec.AnyFlatSpec

//scalastyle:off magic.number

Expand All @@ -19,12 +19,12 @@ import org.scalatest.{FlatSpec, Matchers}
class RandomSorterTest[T <: UInt](
val numExamples : Int,
factory : () => SorterModuleIfc[T]
) extends FlatSpec with Matchers {
) extends AnyFlatSpec {

behavior of "SorterTest"

it should "work" in {
chisel3.iotesters.Driver( factory, "treadle") { c =>
assert(chisel3.iotesters.Driver( factory, "treadle") { c =>
new PeekPokeTester( c) {
def example( a:IndexedSeq[BigInt]) {
poke( c.io.a, a)
Expand All @@ -38,7 +38,7 @@ class RandomSorterTest[T <: UInt](
}

}
} should be (true)
})
}
}

Expand Down
20 changes: 10 additions & 10 deletions src/test/scala/chisel/lib/cordic/iterative/FixedCordicSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
package chisel.lib.cordic.iterative

import dsptools.numbers._
import org.scalatest.{FlatSpec, Matchers}
import org.scalatest.flatspec.AnyFlatSpec

import scala.math.{ceil, max}

class FixedCordicSpec extends FlatSpec with Matchers {
class FixedCordicSpec extends AnyFlatSpec {
behavior of "FixedIterativeCordic"

val params = FixedCordicParams(
Expand All @@ -20,13 +20,13 @@ class FixedCordicSpec extends FlatSpec with Matchers {
val baseTrial = XYZ(xin= 1.0, yin=0.0, zin=0.0, vectoring=false)
val angles = Seq(-3, -2, -1, -0.5, 0, 0.25, 0.5, 1, 2, 3)
val trials = angles.map { phi => baseTrial.copy(zin = phi, xout = Some(math.cos(phi)), yout = Some(math.sin(phi)), zout = Some(0)) }
FixedCordicTester(params, trials) should be (true)
assert(FixedCordicTester(params, trials))
}
it should "vector" in {
val baseTrial = XYZ(xin= 1.0, yin=0.0, zin=0.0, vectoring=true)
val angles = Seq(-3, -2, -1, -0.5, 0, 0.25, 0.5, 1, 2, 3)
val trials = angles.map { phi => baseTrial.copy(xin = math.cos(phi), yin = math.sin(phi), xout = Some(1), yout = Some(0), zout = Some(phi)) }
FixedCordicTester(params, trials) should be (true)
assert(FixedCordicTester(params, trials))
}

// No gain tests.
Expand All @@ -43,13 +43,13 @@ class FixedCordicSpec extends FlatSpec with Matchers {
val baseTrial = XYZ(xin= 1.0, yin=0.0, zin=0.0, vectoring=false)
val angles = Seq(-3, -2, -1, -0.5, 0, 0.25, 0.5, 1, 2, 3)
val trials = angles.map { phi => baseTrial.copy(zin = phi, xout = Some(math.cos(phi)*gainCor), yout = Some(math.sin(phi)*gainCor), zout = Some(0)) }
FixedCordicTester(paramsNoGain, trials) should be (true)
assert(FixedCordicTester(paramsNoGain, trials))
}
it should "vector without gain correction" in {
val baseTrial = XYZ(xin= 1.0, yin=0.0, zin=0.0, vectoring=true)
val angles = Seq(-3, -2, -1, -0.5, 0, 0.25, 0.5, 1, 2, 3)
val trials = angles.map { phi => baseTrial.copy(xin = math.cos(phi), yin = math.sin(phi), xout = Some(gainCor), yout = Some(0), zout = Some(phi)) }
FixedCordicTester(paramsNoGain, trials) should be (true)
assert(FixedCordicTester(paramsNoGain, trials))
}


Expand All @@ -67,13 +67,13 @@ class FixedCordicSpec extends FlatSpec with Matchers {
val baseTrial = XYZ(xin= 1.0, yin=0.0, zin=0.0, vectoring=false)
val angles = Seq(-3, -2, -1, -0.5, 0, 0.25, 0.5, 1, 2, 3)
val trials = angles.map { phi => baseTrial.copy(zin = phi, xout = Some(math.cos(phi)), yout = Some(math.sin(phi)), zout = Some(0)) }
RealCordicTester(realParams, trials) should be (true)
assert(RealCordicTester(realParams, trials))
}
it should "vector" in {
val baseTrial = XYZ(xin= 1.0, yin=0.0, zin=0.0, vectoring=true)
val angles = Seq(-3, -2, -1, -0.5, 0, 0.25, 0.5, 1, 2, 3)
val trials = angles.map { phi => baseTrial.copy(xin = math.cos(phi), yin = math.sin(phi), xout = Some(1), yout = Some(0), zout = Some(phi)) }
RealCordicTester(realParams, trials) should be (true)
assert(RealCordicTester(realParams, trials))
}

// No gain tests.
Expand All @@ -91,13 +91,13 @@ class FixedCordicSpec extends FlatSpec with Matchers {
val baseTrial = XYZ(xin= 1.0, yin=0.0, zin=0.0, vectoring=false)
val angles = Seq(-3, -2, -1, -0.5, 0, 0.25, 0.5, 1, 2, 3)
val trials = angles.map { phi => baseTrial.copy(zin = phi, xout = Some(math.cos(phi)*gainCor), yout = Some(math.sin(phi)*gainCor), zout = Some(0)) }
RealCordicTester(realParamsNoGain, trials) should be (true)
assert(RealCordicTester(realParamsNoGain, trials))
}
it should "vector without gain correction" in {
val baseTrial = XYZ(xin= 1.0, yin=0.0, zin=0.0, vectoring=true)
val angles = Seq(-3, -2, -1, -0.5, 0, 0.25, 0.5, 1, 2, 3)
val trials = angles.map { phi => baseTrial.copy(xin = math.cos(phi), yin = math.sin(phi), xout = Some(gainCor), yout = Some(0), zout = Some(phi)) }
RealCordicTester(realParamsNoGain, trials) should be (true)
assert(RealCordicTester(realParamsNoGain, trials))
}

}
6 changes: 2 additions & 4 deletions src/test/scala/chisel/lib/dclib/CreditTester.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ package chisel.lib.dclib
import chisel3._
import chisel3.util._
import chiseltest._
import org.scalatest._
import chiseltest.experimental.TestOptionBuilder._
import chiseltest.internal.WriteVcdAnnotation
import org.scalatest.flatspec.AnyFlatSpec

class CreditHarness(delay : Int, maxCredit : Int) extends Module {
val io = IO(new Bundle {
Expand Down Expand Up @@ -45,7 +43,7 @@ class CreditHarness(delay : Int, maxCredit : Int) extends Module {
io.backpressured := backpressured
}

class CreditTester extends FlatSpec with ChiselScalatestTester with Matchers {
class CreditTester extends AnyFlatSpec with ChiselScalatestTester {
behavior of "Testers2 with Queue"

it should "test fixed credit with variable delay" in {
Expand Down
Loading