Skip to content

Commit 5245cc0

Browse files
committed
Bump for 3.2.0-RC2
2 parents 7e74707 + b03006e commit 5245cc0

File tree

8 files changed

+90
-11
lines changed

8 files changed

+90
-11
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ jobs:
124124
executor: chisel-executor
125125
steps:
126126
- test-chisel:
127-
scalaVersion: "++2.12.7"
127+
scalaVersion: "++2.12.10"
128128

129129
checkstyle-chisel:
130130
executor: chisel-executor

build.sbt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,18 @@ def javacOptionsVersion(scalaVersion: String): Seq[String] = {
2828
}
2929
}
3030

31-
val defaultVersions = Map("firrtl" -> "1.2-091719-SNAPSHOT")
31+
val defaultVersions = Map("firrtl" -> "1.2.0-RC2")
3232

3333
lazy val commonSettings = Seq (
3434
resolvers ++= Seq(
3535
Resolver.sonatypeRepo("snapshots"),
3636
Resolver.sonatypeRepo("releases")
3737
),
3838
organization := "edu.berkeley.cs",
39-
version := "3.2-091719-SNAPSHOT",
39+
version := "3.2.0-RC2",
4040
autoAPIMappings := true,
41-
scalaVersion := "2.12.9",
42-
crossScalaVersions := Seq("2.12.9", "2.11.12"),
41+
scalaVersion := "2.12.10",
42+
crossScalaVersions := Seq("2.12.10", "2.11.12"),
4343
scalacOptions := Seq("-deprecation", "-feature") ++ scalacOptionsVersion(scalaVersion.value),
4444
libraryDependencies += "org.scala-lang" % "scala-reflect" % scalaVersion.value,
4545
addCompilerPlugin("org.scalamacros" % "paradise" % "2.1.0" cross CrossVersion.full),

build.sc

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ object chiselCompileOptions {
3232
)
3333
}
3434

35-
val crossVersions = Seq("2.12.9", "2.11.12")
35+
val crossVersions = Seq("2.12.10", "2.11.12")
3636

3737
// Provide a managed dependency on X if -DXVersion="" is supplied on the command line.
38-
val defaultVersions = Map("firrtl" -> "1.2-091719-SNAPSHOT")
38+
val defaultVersions = Map("firrtl" -> "1.2.0-RC2")
3939

4040
def getVersion(dep: String, org: String = "edu.berkeley.cs") = {
4141
val version = sys.env.getOrElse(dep + "Version", defaultVersions(dep))
@@ -67,7 +67,7 @@ trait CommonChiselModule extends SbtModule {
6767

6868
trait PublishChiselModule extends CommonChiselModule with PublishModule {
6969
override def artifactName = "chisel3"
70-
def publishVersion = "3.2-091719-SNAPSHOT"
70+
def publishVersion = "3.2.0-RC2"
7171

7272
def pomSettings = PomSettings(
7373
description = artifactName(),
@@ -99,6 +99,10 @@ object chisel3 extends Cross[ChiselTopModule](crossVersions: _*) {
9999
chisel3(crossVersions.head).test.test()
100100
}
101101

102+
def testOne(args: String*) = T.command {
103+
chisel3(crossVersions.head).test.testOne(args: _*)
104+
}
105+
102106
def publishLocal = T{
103107
chisel3(crossVersions.head).publishLocal()
104108
}
@@ -224,6 +228,11 @@ trait AbstractChiselModule extends PublishChiselModule with CommonBuild.BuildInf
224228
ivy"org.scalacheck::scalacheck:1.14.0"
225229
)
226230
def testFrameworks = Seq("org.scalatest.tools.Framework")
231+
232+
def testOne(args: String*) = T.command {
233+
super.runMain("org.scalatest.run", args: _*)
234+
}
235+
227236
}
228237

229238
// This is required for building a library, but not for a `run` target.

chiselFrontend/src/main/scala/chisel3/Aggregate.scala

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,37 @@ sealed class Vec[T <: Data] private[chisel3] (gen: => T, val length: Int)
263263
// scalastyle:on if.brace
264264
PString("Vec(") + Printables(elts) + PString(")")
265265
}
266+
267+
/** A reduce operation in a tree like structure instead of sequentially
268+
* @example An adder tree
269+
* {{{
270+
* val sumOut = inputNums.reduceTree((a: T, b: T) => (a + b))
271+
* }}}
272+
*/
273+
def reduceTree(redOp: (T, T) => T): T = macro VecTransform.reduceTreeDefault
274+
275+
/** A reduce operation in a tree like structure instead of sequentially
276+
* @example A pipelined adder tree
277+
* {{{
278+
* val sumOut = inputNums.reduceTree(
279+
* (a: T, b: T) => RegNext(a + b),
280+
* (a: T) => RegNext(a)
281+
* )
282+
* }}}
283+
*/
284+
def reduceTree(redOp: (T, T) => T, layerOp: (T) => T): T = macro VecTransform.reduceTree
285+
286+
def do_reduceTree(redOp: (T, T) => T, layerOp: (T) => T = (x: T) => x)
287+
(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions) : T = {
288+
require(!isEmpty, "Cannot apply reduction on a vec of size 0")
289+
var curLayer = this
290+
while (curLayer.length > 1) {
291+
curLayer = VecInit(curLayer.grouped(2).map( x =>
292+
if (x.length == 1) layerOp(x(0)) else redOp(x(0), x(1))
293+
).toSeq)
294+
}
295+
curLayer(0)
296+
}
266297
}
267298

268299
object VecInit extends SourceInfoDoc {

coreMacros/src/main/scala/chisel3/internal/sourceinfo/SourceInfoTransform.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,12 @@ class VecTransform(val c: Context) extends SourceInfoTransformMacro {
8484
def contains(x: c.Tree)(ev: c.Tree): c.Tree = {
8585
q"$thisObj.do_contains($x)($implicitSourceInfo, $ev, $implicitCompileOptions)"
8686
}
87+
def reduceTree(redOp: c.Tree, layerOp: c.Tree): c.Tree = {
88+
q"$thisObj.do_reduceTree($redOp,$layerOp)($implicitSourceInfo, $implicitCompileOptions)"
89+
}
90+
def reduceTreeDefault(redOp: c.Tree ): c.Tree = {
91+
q"$thisObj.do_reduceTree($redOp)($implicitSourceInfo, $implicitCompileOptions)"
92+
}
8793
}
8894

8995
/** "Automatic" source information transform / insertion macros, which generate the function name

project/build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version=1.2.7
1+
sbt.version=1.3.0

project/plugins.sbt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
resolvers += Resolver.url("scalasbt", new URL("http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases")) (Resolver.ivyStylePatterns)
1+
resolvers += Resolver.url("scalasbt", new URL("https://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases")) (Resolver.ivyStylePatterns)
22

33
resolvers += Classpaths.sbtPluginReleases
44

5-
resolvers += "jgit-repo" at "http://download.eclipse.org/jgit/maven"
5+
resolvers += "jgit-repo" at "https://download.eclipse.org/jgit/maven"
66

77
addSbtPlugin("org.scalastyle" %% "scalastyle-sbt-plugin" % "1.0.0")
88

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package chiselTests
2+
3+
import chisel3._
4+
import chisel3.testers.BasicTester
5+
6+
class AdderTree[T <: Bits with Num[T]](genType: T, vecSize: Int) extends Module {
7+
val io = IO(new Bundle {
8+
val numIn = Input(Vec(vecSize, genType))
9+
val numOut = Output(genType)
10+
})
11+
io.numOut := io.numIn.reduceTree((a : T, b : T) => (a + b))
12+
}
13+
14+
class AdderTreeTester(bitWidth: Int, numsToAdd: List[Int]) extends BasicTester {
15+
val genType = UInt(bitWidth.W)
16+
val dut = Module(new AdderTree(genType, numsToAdd.size))
17+
dut.io.numIn := VecInit(numsToAdd.map(x => x.asUInt(bitWidth.W)))
18+
val sumCorrect = dut.io.numOut === (numsToAdd.reduce(_+_) % (1 << bitWidth)).asUInt(bitWidth.W)
19+
assert(sumCorrect)
20+
stop()
21+
}
22+
23+
class AdderTreeSpec extends ChiselPropSpec {
24+
property("All numbers should be added correctly by an Adder Tree") {
25+
forAll(safeUIntN(20)) {
26+
case (w: Int, v: List[Int]) => {
27+
whenever(v.size > 0 && w > 0) {
28+
assertTesterPasses { new AdderTreeTester(w, v.map(x => math.abs(x) % ( 1 << w )).toList) }
29+
}
30+
}
31+
}
32+
}
33+
}

0 commit comments

Comments
 (0)