Skip to content

Commit

Permalink
Merge branch 'master' into release; update to 3.1.0 release.
Browse files Browse the repository at this point in the history
  • Loading branch information
ucbjrl committed Apr 18, 2018
2 parents 0cc9e8f + 2990411 commit ebcced5
Show file tree
Hide file tree
Showing 34 changed files with 71 additions and 55 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Chisel Tutorials (Release branch)
Chisel Tutorials (Development branch)
================

These are the tutorials for [Chisel](https://github.com/ucb-bar/chisel3).
Expand All @@ -14,7 +14,7 @@ Getting the Repo
$ git clone https://github.com/ucb-bar/chisel-tutorial.git
$ cd chisel-tutorial
$ git fetch origin
$ git checkout release
$ git checkout master


Executing Chisel
Expand Down
16 changes: 8 additions & 8 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ def scalacOptionsVersion(scalaVersion: String): Seq[String] = {
// switch to support our anonymous Bundle definitions:
// https://github.com/scala/bug/issues/10047
CrossVersion.partialVersion(scalaVersion) match {
case Some((2, scalaMajor: Int)) if scalaMajor < 12 => Seq()
case Some((2, scalaMajor: Long)) if scalaMajor < 12 => Seq()
case _ => Seq("-Xsource:2.11")
}
}
Expand All @@ -16,7 +16,7 @@ def javacOptionsVersion(scalaVersion: String): Seq[String] = {
// Java 7 compatible code for Scala 2.11
// for compatibility with old clients.
CrossVersion.partialVersion(scalaVersion) match {
case Some((2, scalaMajor: Int)) if scalaMajor < 12 =>
case Some((2, scalaMajor: Long)) if scalaMajor < 12 =>
Seq("-source", "1.7", "-target", "1.7")
case _ =>
Seq("-source", "1.8", "-target", "1.8")
Expand All @@ -26,21 +26,21 @@ def javacOptionsVersion(scalaVersion: String): Seq[String] = {

organization := "edu.berkeley.cs"

version := "3.0.0"
version := "3.1.0"

name := "chisel-tutorial"

scalaVersion := "2.11.11"
scalaVersion := "2.11.12"

crossScalaVersions := Seq("2.11.11", "2.12.3")
crossScalaVersions := Seq("2.11.12", "2.12.4")

scalacOptions ++= Seq("-deprecation", "-feature", "-unchecked", "-language:reflectiveCalls")

// Provide a managed dependency on X if -DXVersion="" is supplied on the command line.
// The following are the default development versions, not the "release" versions.
// The following are the current "release" versions.
val defaultVersions = Map(
"chisel3" -> "3.0.+",
"chisel-iotesters" -> "1.1.+"
"chisel3" -> "3.1.+",
"chisel-iotesters" -> "1.2.+"
)

libraryDependencies ++= (Seq("chisel3","chisel-iotesters").map {
Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version = 0.13.16
sbt.version = 1.1.1
2 changes: 1 addition & 1 deletion run-examples.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env bash
args=$@
sbt -v "test:run-main examples.Launcher $args"
sbt -v "test:runMain examples.Launcher $args"
2 changes: 1 addition & 1 deletion run-problem.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env bash
args=$@
sbt "test:run-main problems.Launcher $args"
sbt "test:runMain problems.Launcher $args"
2 changes: 1 addition & 1 deletion run-solution.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env bash
args=$@
sbt "test:run-main solutions.Launcher $args"
sbt "test:runMain solutions.Launcher $args"
2 changes: 1 addition & 1 deletion src/main/scala/examples/Router.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Packet extends Bundle {
*
* @param n is the number of fanned outputs for the routed packet
*/
class RouterIO(n: Int) extends Bundle {
class RouterIO(val n: Int) extends Bundle {
val read_routing_table_request = DeqIO(new ReadCmd())
val read_routing_table_response = EnqIO(UInt(Router.addressWidth.W))
val load_routing_table_request = DeqIO(new WriteCmd())
Expand Down
4 changes: 0 additions & 4 deletions src/main/scala/examples/Stack.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ package examples
import chisel3._
import chisel3.util.log2Ceil

import scala.collection.mutable.HashMap
import scala.collection.mutable.{Stack => ScalaStack}
import scala.util.Random

class Stack(val depth: Int) extends Module {
val io = IO(new Bundle {
val push = Input(Bool())
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/problems/VecShiftRegisterSimple.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class VecShiftRegisterSimple extends Module {
})

val initValues = Seq.fill(4) { 0.U(8.W) }
val delays = RegInit(Vec(initValues))
val delays = RegInit(VecInit(initValues))

// Implement below ----------

Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/solutions/Mul.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Mul extends Module {
for (i <- 0 until 16)
for (j <- 0 until 16)
mulsValues += (i * j).asUInt(8.W)
val tbl = Vec(mulsValues)
val tbl = VecInit(mulsValues)
io.z := tbl((io.x << 4.U) | io.y)

}
2 changes: 1 addition & 1 deletion src/main/scala/solutions/VecShiftRegisterParam.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class VecShiftRegisterParam(val n: Int, val w: Int) extends Module {
})

val initValues = Seq.fill(n) { 0.U(w.W) }
val delays = RegInit(Vec(initValues))
val delays = RegInit(VecInit(initValues))

for (i <- n-1 to 1 by -1) {
delays(i) := delays(i - 1)
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/solutions/VecShiftRegisterSimple.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class VecShiftRegisterSimple extends Module {
})

val initValues = Seq.fill(4) { 0.U(8.W) }
val delays = RegInit(Vec(initValues))
val delays = RegInit(VecInit(initValues))

delays(0) := io.in
delays(1) := delays(0)
Expand Down
1 change: 0 additions & 1 deletion src/test/scala/examples/Adder4Tests.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// See LICENSE.txt for license details.
package examples


import chisel3.iotesters.{PeekPokeTester, Driver, ChiselFlatSpec}

class Adder4Tests(c: Adder4) extends PeekPokeTester(c) {
Expand Down
11 changes: 6 additions & 5 deletions src/test/scala/examples/AdderTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,20 @@ package examples
import chisel3.iotesters.{PeekPokeTester, Driver, ChiselFlatSpec}

class AdderTests(c: Adder) extends PeekPokeTester(c) {
for (t <- 0 until 4) {
val rnd0 = rnd.nextInt(c.n)
val rnd1 = rnd.nextInt(c.n)
val rnd2 = rnd.nextInt(1)
for (t <- 0 until (1 << (c.n + 1))) {
val rnd0 = rnd.nextInt(1 << c.n)
val rnd1 = rnd.nextInt(1 << c.n)
val rnd2 = rnd.nextInt(2)

poke(c.io.A, rnd0)
poke(c.io.B, rnd1)
poke(c.io.Cin, rnd2)
step(1)
val rsum = rnd0 + rnd1 + rnd2
val mask = BigInt("1"*c.n, 2)

expect(c.io.Sum, rsum & mask)
expect(c.io.Cout, rsum % 1)
expect(c.io.Cout, ((1 << c.n) & rsum) >> c.n)
}
}

Expand Down
1 change: 0 additions & 1 deletion src/test/scala/examples/ByteSelectorTests.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// See LICENSE.txt for license details.
package examples


import chisel3.iotesters.{PeekPokeTester, Driver, ChiselFlatSpec}

class ByteSelectorTests(c: ByteSelector) extends PeekPokeTester(c) {
Expand Down
1 change: 0 additions & 1 deletion src/test/scala/examples/CombinationalTests.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// See LICENSE.txt for license details.
package examples


import chisel3.iotesters.{PeekPokeTester, Driver, ChiselFlatSpec}

class CombinationalTests(c: Combinational) extends PeekPokeTester(c) {
Expand Down
1 change: 0 additions & 1 deletion src/test/scala/examples/DarkenTests.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// See LICENSE.txt for license details.
package examples


import chisel3.iotesters.{PeekPokeTester, Driver, ChiselFlatSpec}

class DarkenTests(c: Darken, infile: java.io.InputStream, outfilename: String) extends PeekPokeTester(c) {
Expand Down
1 change: 0 additions & 1 deletion src/test/scala/examples/EnableShiftRegisterTests.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// See LICENSE.txt for license details.
package examples


import chisel3.iotesters.{PeekPokeTester, Driver, ChiselFlatSpec}

class EnableShiftRegisterTests(c: EnableShiftRegister) extends PeekPokeTester(c) {
Expand Down
1 change: 0 additions & 1 deletion src/test/scala/examples/FullAdderTests.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// See LICENSE.txt for license details.
package examples


import chisel3.iotesters.{PeekPokeTester, Driver, ChiselFlatSpec}

class FullAdderTests(c: FullAdder) extends PeekPokeTester(c) {
Expand Down
1 change: 0 additions & 1 deletion src/test/scala/examples/FunctionalityTests.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// See LICENSE.txt for license details.
package examples


import chisel3.iotesters.{PeekPokeTester, Driver, ChiselFlatSpec}

class FunctionalityTests(c: Functionality) extends PeekPokeTester(c) {
Expand Down
1 change: 0 additions & 1 deletion src/test/scala/examples/GCDTests.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// See LICENSE.txt for license details.

package examples

import chisel3.iotesters.{ChiselFlatSpec, Driver, PeekPokeTester}
Expand Down
1 change: 0 additions & 1 deletion src/test/scala/examples/HiLoMultiplierTests.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// See LICENSE.txt for license details.
package examples


import chisel3.iotesters.{PeekPokeTester, Driver, ChiselFlatSpec}

class HiLoMultiplierTests(c: HiLoMultiplier) extends PeekPokeTester(c) {
Expand Down
2 changes: 0 additions & 2 deletions src/test/scala/examples/Image.scala
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// See LICENSE.txt for license details.
package examples


import chisel3.iotesters.{PeekPokeTester, Driver, ChiselFlatSpec}
import scala.io.Source
import java.io.{File, FileOutputStream, InputStream}

Expand Down
1 change: 0 additions & 1 deletion src/test/scala/examples/LifeTests.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// See LICENSE.txt for license details.
package examples


import chisel3.iotesters.{Driver, PeekPokeTester}
import org.scalatest.FreeSpec

Expand Down
3 changes: 1 addition & 2 deletions src/test/scala/examples/LogShifterTests.scala
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// See LICENSE.txt for license details.
package examples


import chisel3.iotesters.{PeekPokeTester, Driver, ChiselFlatSpec}
import chisel3.iotesters.PeekPokeTester

class LogShifterTests(c: LogShifter) extends PeekPokeTester(c) {
}
Expand Down
1 change: 0 additions & 1 deletion src/test/scala/examples/ParityTests.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// See LICENSE.txt for license details.
package examples


import chisel3.iotesters.{PeekPokeTester, Driver, ChiselFlatSpec}

class ParityTests(c: Parity) extends PeekPokeTester(c) {
Expand Down
1 change: 0 additions & 1 deletion src/test/scala/examples/ResetShiftRegisterTests.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// See LICENSE.txt for license details.
package examples


import chisel3.iotesters.{PeekPokeTester, Driver, ChiselFlatSpec}

class ResetShiftRegisterTests(c: ResetShiftRegister) extends PeekPokeTester(c) {
Expand Down
1 change: 0 additions & 1 deletion src/test/scala/examples/RouterTests.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// See LICENSE for license details.

package examples

import chisel3._
Expand Down
1 change: 0 additions & 1 deletion src/test/scala/examples/ShiftRegisterTests.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// See LICENSE.txt for license details.
package examples


import chisel3.iotesters.{PeekPokeTester, Driver, ChiselFlatSpec}

class ShiftRegisterTests(c: ShiftRegister) extends PeekPokeTester(c) {
Expand Down
1 change: 0 additions & 1 deletion src/test/scala/examples/SimpleALUTests.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// See LICENSE.txt for license details.
package examples


import chisel3.iotesters.{PeekPokeTester, Driver, ChiselFlatSpec}

class SimpleALUTests(c: SimpleALU) extends PeekPokeTester(c) {
Expand Down
50 changes: 45 additions & 5 deletions src/test/scala/examples/StackTests.scala
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
// See LICENSE.txt for license details.
package examples


import chisel3.iotesters.{PeekPokeTester, Driver, ChiselFlatSpec}
import scala.collection.mutable.HashMap
import scala.collection.mutable.{Stack => ScalaStack}
import scala.util.Random
import scala.collection.mutable.{ArrayStack => ScalaStack}

class StackTests(c: Stack) extends PeekPokeTester(c) {
class StackTestsOrig(c: Stack) extends PeekPokeTester(c) {
var nxtDataOut = 0
var dataOut = 0
val stack = new ScalaStack[Int]()

for (t <- 0 until 16) {
println(s"Tick $t")
val enable = rnd.nextInt(2)
val push = rnd.nextInt(2)
val pop = rnd.nextInt(2)
Expand All @@ -38,6 +36,48 @@ class StackTests(c: Stack) extends PeekPokeTester(c) {
expect(c.io.dataOut, dataOut)
}
}
class StackTests(c: Stack) extends PeekPokeTester(c) {
var nxtDataOut = 0
var dataOut = 0
val stack = new ScalaStack[Int]()

poke(c.io.push, 0)
poke(c.io.pop, 1)
poke(c.io.dataIn, 232)
poke(c.io.en, 1)

step(1)

println(s"dataOut ${peek(c.io.dataOut)}")

poke(c.io.push, 1)
poke(c.io.pop, 1)
poke(c.io.dataIn, 90)
poke(c.io.en, 1)

step(1)
step(1)

println(s"dataOut ${peek(c.io.dataOut)}")

poke(c.io.push, 1)
poke(c.io.pop, 1)
poke(c.io.dataIn, 33)
poke(c.io.en, 1)

step(1)
step(1)

println(s"dataOut ${peek(c.io.dataOut)}")

poke(c.io.push, 0)
poke(c.io.pop, 1)
poke(c.io.dataIn, 22)
poke(c.io.en, 1)

println(s"dataOut ${peek(c.io.dataOut)}")
// expect(c.io.dataOut, dataOut)
}

class StackTester extends ChiselFlatSpec {
behavior of "Stack"
Expand Down
1 change: 0 additions & 1 deletion src/test/scala/examples/TblTests.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// See LICENSE.txt for license details.
package examples


import chisel3.iotesters.{PeekPokeTester, Driver, ChiselFlatSpec}

class TblTests(c: Tbl) extends PeekPokeTester(c) {
Expand Down
1 change: 0 additions & 1 deletion src/test/scala/examples/VecSearchTests.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// See LICENSE.txt for license details.
package examples


import chisel3.iotesters.{PeekPokeTester, Driver, ChiselFlatSpec}

class VecSearchTests(c: VecSearch) extends PeekPokeTester(c) {
Expand Down
1 change: 0 additions & 1 deletion src/test/scala/utils/TutorialRunner.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// See LICENSE.txt for license details.

package utils

import scala.collection.mutable.ArrayBuffer
Expand Down

0 comments on commit ebcced5

Please sign in to comment.