summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/scala/chisel3/testers/BasicTester.scala2
-rw-r--r--src/main/scala/chisel3/util/Arbiter.scala14
-rw-r--r--src/main/scala/chisel3/util/Decoupled.scala113
-rw-r--r--src/main/scala/chisel3/util/Valid.scala30
-rw-r--r--src/test/scala/chiselTests/Assert.scala2
-rw-r--r--src/test/scala/chiselTests/BlackBox.scala32
-rw-r--r--src/test/scala/chiselTests/BundleWire.scala8
-rw-r--r--src/test/scala/chiselTests/ComplexAssign.scala10
-rw-r--r--src/test/scala/chiselTests/Decoder.scala8
-rw-r--r--src/test/scala/chiselTests/DeqIOSpec.scala11
-rw-r--r--src/test/scala/chiselTests/Direction.scala8
-rw-r--r--src/test/scala/chiselTests/EnableShiftRegister.scala10
-rw-r--r--src/test/scala/chiselTests/GCD.scala14
-rw-r--r--src/test/scala/chiselTests/LFSR16.scala8
-rw-r--r--src/test/scala/chiselTests/MemorySearch.scala12
-rw-r--r--src/test/scala/chiselTests/Module.scala22
-rw-r--r--src/test/scala/chiselTests/MulLookup.scala10
-rw-r--r--src/test/scala/chiselTests/OptionBundle.scala6
-rw-r--r--src/test/scala/chiselTests/Padding.scala10
-rw-r--r--src/test/scala/chiselTests/ParameterizedModule.scala8
-rw-r--r--src/test/scala/chiselTests/Risc.scala16
-rw-r--r--src/test/scala/chiselTests/SIntOps.scala36
-rw-r--r--src/test/scala/chiselTests/Stack.scala14
-rw-r--r--src/test/scala/chiselTests/Tbl.scala14
-rw-r--r--src/test/scala/chiselTests/UIntOps.scala50
-rw-r--r--src/test/scala/chiselTests/Vec.scala30
-rw-r--r--src/test/scala/chiselTests/VectorPacketIO.scala9
-rw-r--r--src/test/scala/chiselTests/VendingMachine.scala9
28 files changed, 239 insertions, 277 deletions
diff --git a/src/main/scala/chisel3/testers/BasicTester.scala b/src/main/scala/chisel3/testers/BasicTester.scala
index f91536d5..329237c6 100644
--- a/src/main/scala/chisel3/testers/BasicTester.scala
+++ b/src/main/scala/chisel3/testers/BasicTester.scala
@@ -12,7 +12,7 @@ import internal.sourceinfo.SourceInfo
class BasicTester extends Module {
// The testbench has no IOs, rather it should communicate using printf, assert, and stop.
- val io = new Bundle()
+ val io = IO(new Bundle())
def popCount(n: Long): Int = n.toBinaryString.count(_=='1')
diff --git a/src/main/scala/chisel3/util/Arbiter.scala b/src/main/scala/chisel3/util/Arbiter.scala
index eb541977..a5397682 100644
--- a/src/main/scala/chisel3/util/Arbiter.scala
+++ b/src/main/scala/chisel3/util/Arbiter.scala
@@ -9,9 +9,9 @@ import chisel3._
/** An I/O bundle for the Arbiter */
class ArbiterIO[T <: Data](gen: T, n: Int) extends Bundle {
- val in = Vec(n, Decoupled(gen)).flip
- val out = Decoupled(gen)
- val chosen = UInt(OUTPUT, log2Up(n))
+ val in = Flipped(Vec(n, DecoupledIO(gen)))
+ val out = DecoupledIO(gen)
+ val chosen = Output(UInt(log2Up(n)))
}
/** Arbiter Control determining which producer has access */
@@ -27,7 +27,7 @@ private object ArbiterCtrl
abstract class LockingArbiterLike[T <: Data](gen: T, n: Int, count: Int, needsLock: Option[T => Bool]) extends Module {
def grant: Seq[Bool]
def choice: UInt
- val io = new ArbiterIO(gen, n)
+ val io = IO(new ArbiterIO(gen, n))
io.chosen := choice
io.out.valid := io.in(io.chosen).valid
@@ -39,7 +39,7 @@ abstract class LockingArbiterLike[T <: Data](gen: T, n: Int, count: Int, needsLo
val locked = lockCount.value =/= UInt(0)
val wantsLock = needsLock.map(_(io.out.bits)).getOrElse(Bool(true))
- when (io.out.fire() && wantsLock) {
+ when (io.out.firing && wantsLock) {
lockIdx := io.chosen
lockCount.inc()
}
@@ -55,7 +55,7 @@ abstract class LockingArbiterLike[T <: Data](gen: T, n: Int, count: Int, needsLo
class LockingRRArbiter[T <: Data](gen: T, n: Int, count: Int, needsLock: Option[T => Bool] = None)
extends LockingArbiterLike[T](gen, n, count, needsLock) {
- lazy val lastGrant = RegEnable(io.chosen, io.out.fire())
+ lazy val lastGrant = RegEnable(io.chosen, io.out.firing)
lazy val grantMask = (0 until n).map(UInt(_) > lastGrant)
lazy val validMask = io.in zip grantMask map { case (in, g) => in.valid && g }
@@ -101,7 +101,7 @@ class RRArbiter[T <: Data](gen:T, n: Int) extends LockingRRArbiter[T](gen, n, 1)
consumer.io.in <> arb.io.out
*/
class Arbiter[T <: Data](gen: T, n: Int) extends Module {
- val io = new ArbiterIO(gen, n)
+ val io = IO(new ArbiterIO(gen, n))
io.chosen := UInt(n-1)
io.out.bits := io.in(n-1).bits
diff --git a/src/main/scala/chisel3/util/Decoupled.scala b/src/main/scala/chisel3/util/Decoupled.scala
index 339fde7c..73f58ed4 100644
--- a/src/main/scala/chisel3/util/Decoupled.scala
+++ b/src/main/scala/chisel3/util/Decoupled.scala
@@ -10,71 +10,62 @@ import chisel3._
/** An I/O Bundle with simple handshaking using valid and ready signals for data 'bits'*/
class DecoupledIO[+T <: Data](gen: T) extends Bundle
{
- val ready = Bool(INPUT)
- val valid = Bool(OUTPUT)
- val bits = gen.cloneType.asOutput
- def fire(dummy: Int = 0): Bool = ready && valid
- override def cloneType: this.type = new DecoupledIO(gen).asInstanceOf[this.type]
+ val ready = Input(Bool())
+ val valid = Output(Bool())
+ val bits = Output(gen.newType)
+ override protected def cloneType: this.type = DecoupledIO(gen).asInstanceOf[this.type]
}
-/** Adds a ready-valid handshaking protocol to any interface.
- * The standard used is that the consumer uses the flipped interface.
- */
-object Decoupled {
+object DecoupledIO {
+ /** Adds a ready-valid handshaking protocol to any interface.
+ * The standard used is that the consumer uses the flipped interface.
+ */
def apply[T <: Data](gen: T): DecoupledIO[T] = new DecoupledIO(gen)
-}
-/** An I/O bundle for enqueuing data with valid/ready handshaking
- * Initialization must be handled, if necessary, by the parent circuit
- */
-class EnqIO[T <: Data](gen: T) extends DecoupledIO(gen)
-{
- /** push dat onto the output bits of this interface to let the consumer know it has happened.
- * @param dat the values to assign to bits.
- * @return dat.
- */
- def enq(dat: T): T = { valid := Bool(true); bits := dat; dat }
+ implicit class AddMethodsToDecoupled[T<:Data](val target: DecoupledIO[T]) extends AnyVal {
+ def firing: Bool = target.ready && target.valid
+
+ /** push dat onto the output bits of this interface to let the consumer know it has happened.
+ * @param dat the values to assign to bits.
+ * @return dat.
+ */
+ def enq(dat: T): T = {
+ target.valid := true.asBool
+ target.bits := dat
+ dat
+ }
- /** Initialize this Bundle. Valid is set to false, and all bits are set to zero.
- * NOTE: This method of initialization is still being discussed and could change in the
- * future.
- */
- def init(): Unit = {
- valid := Bool(false)
- for (io <- bits.flatten)
- io := UInt(0)
- }
- override def cloneType: this.type = { new EnqIO(gen).asInstanceOf[this.type]; }
-}
+ /** Indicate no enqueue occurs. Valid is set to false, and all bits are set to zero.
+ */
+ def noenq(): Unit = {
+ target.valid := false.asBool
+ target.bits := target.bits.fromBits(0.asUInt)
+ }
-/** An I/O bundle for dequeuing data with valid/ready handshaking.
- * Initialization must be handled, if necessary, by the parent circuit
- */
-class DeqIO[T <: Data](gen: T) extends DecoupledIO(gen) with Flipped
-{
- /** Assert ready on this port and return the associated data bits.
- * This is typically used when valid has been asserted by the producer side.
- * @param b ignored
- * @return the data for this device,
- */
- def deq(b: Boolean = false): T = { ready := Bool(true); bits }
+ /** Assert ready on this port and return the associated data bits.
+ * This is typically used when valid has been asserted by the producer side.
+ * @param b ignored
+ * @return the data for this device,
+ */
+ def deq(): T = {
+ target.ready := true.asBool
+ target.bits
+ }
- /** Initialize this Bundle.
- * NOTE: This method of initialization is still being discussed and could change in the
- * future.
- */
- def init(): Unit = {
- ready := Bool(false)
+ /** Indicate no dequeue occurs. Ready is set to false
+ */
+ def nodeq(): Unit = {
+ target.ready := false.asBool
+ }
}
override def cloneType: this.type = { new DeqIO(gen).asInstanceOf[this.type]; }
}
-/** An I/O bundle for dequeuing data with valid/ready handshaking */
-class DecoupledIOC[+T <: Data](gen: T) extends Bundle
-{
- val ready = Bool(INPUT)
- val valid = Bool(OUTPUT)
- val bits = gen.cloneType.asOutput
+object EnqIO {
+ def apply[T<:Data](gen: T): DecoupledIO[T] = Flipped(DecoupledIO(gen))
+}
+object DeqIO {
+ def apply[T<:Data](gen: T): DecoupledIO[T] = DecoupledIO(gen)
}
/** An I/O Bundle for Queues
@@ -83,11 +74,11 @@ class DecoupledIOC[+T <: Data](gen: T) extends Bundle
class QueueIO[T <: Data](gen: T, entries: Int) extends Bundle
{
/** I/O to enqueue data, is [[Chisel.DecoupledIO]] flipped */
- val enq = Decoupled(gen.cloneType).flip()
+ val enq = EnqIO(gen)
/** I/O to enqueue data, is [[Chisel.DecoupledIO]]*/
- val deq = Decoupled(gen.cloneType)
+ val deq = DeqIO(gen)
/** The current amount of data in the queue */
- val count = UInt(OUTPUT, log2Up(entries + 1))
+ val count = Output(UInt(log2Up(entries + 1)))
}
/** A hardware module implementing a Queue
@@ -111,7 +102,7 @@ extends Module(override_reset=override_reset) {
def this(gen: T, entries: Int, pipe: Boolean, flow: Boolean, _reset: Bool) =
this(gen, entries, pipe, flow, Some(_reset))
- val io = new QueueIO(gen, entries)
+ val io = IO(new QueueIO(gen, entries))
val ram = Mem(entries, gen)
val enq_ptr = Counter(entries)
@@ -121,8 +112,8 @@ extends Module(override_reset=override_reset) {
val ptr_match = enq_ptr.value === deq_ptr.value
val empty = ptr_match && !maybe_full
val full = ptr_match && maybe_full
- val do_enq = Wire(init=io.enq.fire())
- val do_deq = Wire(init=io.deq.fire())
+ val do_enq = Wire(init=io.enq.firing)
+ val do_deq = Wire(init=io.deq.firing)
when (do_enq) {
ram(enq_ptr.value) := io.enq.bits
@@ -169,7 +160,7 @@ extends Module(override_reset=override_reset) {
from the inputs.
Example usage:
- {{{ val q = Queue(Decoupled(UInt()), 16)
+ {{{ val q = Queue(DecoupledIO(UInt()), 16)
q.io.enq <> producer.io.out
consumer.io.in <> q.io.deq }}}
*/
diff --git a/src/main/scala/chisel3/util/Valid.scala b/src/main/scala/chisel3/util/Valid.scala
index 78187ff6..4078a76a 100644
--- a/src/main/scala/chisel3/util/Valid.scala
+++ b/src/main/scala/chisel3/util/Valid.scala
@@ -7,20 +7,18 @@ package chisel3.util
import chisel3._
-/** An I/O Bundle containing data and a signal determining if it is valid */
-class ValidIO[+T <: Data](gen2: T) extends Bundle
+/** An Bundle containing data and a signal determining if it is valid */
+class Valid[+T <: Data](gen: T) extends Bundle
{
- val valid = Bool(OUTPUT)
- val bits = gen2.cloneType.asOutput
+ val valid = Output(Bool())
+ val bits = Output(gen.cloneType)
def fire(dummy: Int = 0): Bool = valid
- override def cloneType: this.type = new ValidIO(gen2).asInstanceOf[this.type]
+ override def cloneType: this.type = Valid(gen).asInstanceOf[this.type]
}
-/** Adds a valid protocol to any interface. The standard used is
- that the consumer uses the flipped interface.
-*/
+/** Adds a valid protocol to any interface */
object Valid {
- def apply[T <: Data](gen: T): ValidIO[T] = new ValidIO(gen)
+ def apply[T <: Data](gen: T): Valid[T] = new Valid(gen)
}
/** A hardware module that delays data coming down the pipeline
@@ -34,7 +32,7 @@ object Valid {
*/
object Pipe
{
- def apply[T <: Data](enqValid: Bool, enqBits: T, latency: Int): ValidIO[T] = {
+ def apply[T <: Data](enqValid: Bool, enqBits: T, latency: Int): Valid[T] = {
if (latency == 0) {
val out = Wire(Valid(enqBits))
out.valid <> enqValid
@@ -46,16 +44,16 @@ object Pipe
apply(v, b, latency-1)
}
}
- def apply[T <: Data](enqValid: Bool, enqBits: T): ValidIO[T] = apply(enqValid, enqBits, 1)
- def apply[T <: Data](enq: ValidIO[T], latency: Int = 1): ValidIO[T] = apply(enq.valid, enq.bits, latency)
+ def apply[T <: Data](enqValid: Bool, enqBits: T): Valid[T] = apply(enqValid, enqBits, 1)
+ def apply[T <: Data](enq: Valid[T], latency: Int = 1): Valid[T] = apply(enq.valid, enq.bits, latency)
}
class Pipe[T <: Data](gen: T, latency: Int = 1) extends Module
{
- val io = new Bundle {
- val enq = Valid(gen).flip
- val deq = Valid(gen)
- }
+ val io = IO(new Bundle {
+ val enq = Input(Valid(gen))
+ val deq = Output(Valid(gen))
+ })
io.deq <> Pipe(io.enq, latency)
}
diff --git a/src/test/scala/chiselTests/Assert.scala b/src/test/scala/chiselTests/Assert.scala
index 3fed2bd4..efc2e1e7 100644
--- a/src/test/scala/chiselTests/Assert.scala
+++ b/src/test/scala/chiselTests/Assert.scala
@@ -26,7 +26,7 @@ class SucceedingAssertTester() extends BasicTester {
}
class PipelinedResetModule extends Module {
- val io = new Bundle { }
+ val io = IO(new Bundle { })
val a = Reg(init = UInt(0xbeef))
val b = Reg(init = UInt(0xbeef))
assert(a === b)
diff --git a/src/test/scala/chiselTests/BlackBox.scala b/src/test/scala/chiselTests/BlackBox.scala
index fdc5970e..c1154883 100644
--- a/src/test/scala/chiselTests/BlackBox.scala
+++ b/src/test/scala/chiselTests/BlackBox.scala
@@ -10,25 +10,25 @@ import chisel3.testers.BasicTester
import chisel3.util._
class BlackBoxInverter extends BlackBox {
- val io = new Bundle() {
- val in = Bool(INPUT)
- val out = Bool(OUTPUT)
- }
+ val io = IO(new Bundle() {
+ val in = Input(Bool())
+ val out = Output(Bool())
+ })
}
class BlackBoxPassthrough extends BlackBox {
- val io = new Bundle() {
- val in = Bool(INPUT)
- val out = Bool(OUTPUT)
- }
+ val io = IO(new Bundle() {
+ val in = Input(Bool())
+ val out = Output(Bool())
+ })
}
class BlackBoxRegister extends BlackBox {
- val io = new Bundle() {
- val clock = Clock().asInput
- val in = Bool(INPUT)
- val out = Bool(OUTPUT)
- }
+ val io = IO(new Bundle() {
+ val clock = Input(Clock())
+ val in = Input(Bool())
+ val out = Output(Bool())
+ })
}
class BlackBoxTester extends BasicTester {
@@ -86,9 +86,9 @@ class BlackBoxWithClockTester extends BasicTester {
/*
// Must determine how to handle parameterized Verilog
class BlackBoxConstant(value: Int) extends BlackBox {
- val io = new Bundle() {
- val out = UInt(width=log2Up(value)).asOutput
- }
+ val io = IO(new Bundle() {
+ val out = Output(UInt(width=log2Up(value)))
+ })
override val name = s"#(WIDTH=${log2Up(value)},VALUE=$value) "
}
diff --git a/src/test/scala/chiselTests/BundleWire.scala b/src/test/scala/chiselTests/BundleWire.scala
index e5e9fb1a..029407dd 100644
--- a/src/test/scala/chiselTests/BundleWire.scala
+++ b/src/test/scala/chiselTests/BundleWire.scala
@@ -12,10 +12,10 @@ class Coord extends Bundle {
}
class BundleWire(n: Int) extends Module {
- val io = new Bundle {
- val in = (new Coord).asInput
- val outs = Vec(n, new Coord).asOutput
- }
+ val io = IO(new Bundle {
+ val in = Input(new Coord)
+ val outs = Output(Vec(n, new Coord))
+ })
val coords = Wire(Vec(n, new Coord))
for (i <- 0 until n) {
coords(i) := io.in
diff --git a/src/test/scala/chiselTests/ComplexAssign.scala b/src/test/scala/chiselTests/ComplexAssign.scala
index 304fbcf5..e5d1fbea 100644
--- a/src/test/scala/chiselTests/ComplexAssign.scala
+++ b/src/test/scala/chiselTests/ComplexAssign.scala
@@ -15,11 +15,11 @@ class Complex[T <: Data](val re: T, val im: T) extends Bundle {
}
class ComplexAssign(w: Int) extends Module {
- val io = new Bundle {
- val e = new Bool(INPUT)
- val in = new Complex(UInt(width = w), UInt(width = w)).asInput
- val out = new Complex(UInt(width = w), UInt(width = w)).asOutput
- }
+ val io = IO(new Bundle {
+ val e = Input(Bool())
+ val in = Input(new Complex(UInt(width = w), UInt(width = w)))
+ val out = Output(new Complex(UInt(width = w), UInt(width = w)))
+ })
when (io.e) {
val tmp = Wire(new Complex(UInt(width = w), UInt(width = w)))
tmp := io.in
diff --git a/src/test/scala/chiselTests/Decoder.scala b/src/test/scala/chiselTests/Decoder.scala
index 5586561b..4a872245 100644
--- a/src/test/scala/chiselTests/Decoder.scala
+++ b/src/test/scala/chiselTests/Decoder.scala
@@ -11,10 +11,10 @@ import chisel3.testers.BasicTester
import chisel3.util._
class Decoder(bitpats: List[String]) extends Module {
- val io = new Bundle {
- val inst = UInt(INPUT, 32)
- val matched = Bool(OUTPUT)
- }
+ val io = IO(new Bundle {
+ val inst = Input(UInt(32))
+ val matched = Output(Bool())
+ })
io.matched := Vec(bitpats.map(BitPat(_) === io.inst)).reduce(_||_)
}
diff --git a/src/test/scala/chiselTests/DeqIOSpec.scala b/src/test/scala/chiselTests/DeqIOSpec.scala
index 09891647..770d2e0e 100644
--- a/src/test/scala/chiselTests/DeqIOSpec.scala
+++ b/src/test/scala/chiselTests/DeqIOSpec.scala
@@ -16,17 +16,17 @@ class UsesDeqIOInfo extends Bundle {
}
class UsesDeqIO extends Module {
- val io = new Bundle {
- val in = new DeqIO(new UsesDeqIOInfo)
- val out = new EnqIO(new UsesDeqIOInfo)
- }
+ val io = IO(new Bundle {
+ val in = DeqIO(new UsesDeqIOInfo)
+ val out = EnqIO(new UsesDeqIOInfo)
+ })
}
class DeqIOSpec extends ChiselFlatSpec {
runTester {
new BasicTester {
val dut = new UsesDeqIO
-
+/*
"DeqIO" should "set the direction of it's parameter to INPUT" in {
assert(dut.io.in.bits.info_data.dir === INPUT)
}
@@ -56,6 +56,7 @@ class DeqIOSpec extends ChiselFlatSpec {
assert(dut.io.out.ready.dir == out_clone.ready.dir)
assert(dut.io.out.valid.dir == out_clone.valid.dir)
}
+ */
}
}
}
diff --git a/src/test/scala/chiselTests/Direction.scala b/src/test/scala/chiselTests/Direction.scala
index 8b84f844..682103f7 100644
--- a/src/test/scala/chiselTests/Direction.scala
+++ b/src/test/scala/chiselTests/Direction.scala
@@ -8,10 +8,10 @@ import org.scalatest.prop._
import chisel3.testers.BasicTester
class DirectionHaver extends Module {
- val io = new Bundle {
- val in = UInt(INPUT, 32)
- val out = UInt(OUTPUT, 32)
- }
+ val io = IO(new Bundle {
+ val in = Input(UInt(32))
+ val out = Output(UInt(32))
+ })
}
class GoodDirection extends DirectionHaver {
diff --git a/src/test/scala/chiselTests/EnableShiftRegister.scala b/src/test/scala/chiselTests/EnableShiftRegister.scala
index 7db20fc1..26af944f 100644
--- a/src/test/scala/chiselTests/EnableShiftRegister.scala
+++ b/src/test/scala/chiselTests/EnableShiftRegister.scala
@@ -5,11 +5,11 @@ import chisel3._
import chisel3.testers.BasicTester
class EnableShiftRegister extends Module {
- val io = new Bundle {
- val in = UInt(INPUT, 4)
- val shift = Bool(INPUT)
- val out = UInt(OUTPUT, 4)
- }
+ val io = IO(new Bundle {
+ val in = Input(UInt(4))
+ val shift = Input(Bool())
+ val out = Output(UInt(4))
+ })
val r0 = Reg(init = UInt(0, 4))
val r1 = Reg(init = UInt(0, 4))
val r2 = Reg(init = UInt(0, 4))
diff --git a/src/test/scala/chiselTests/GCD.scala b/src/test/scala/chiselTests/GCD.scala
index 60a70cc8..a8b907af 100644
--- a/src/test/scala/chiselTests/GCD.scala
+++ b/src/test/scala/chiselTests/GCD.scala
@@ -8,13 +8,13 @@ import org.scalatest._
import org.scalatest.prop._
class GCD extends Module {
- val io = new Bundle {
- val a = UInt(INPUT, 32)
- val b = UInt(INPUT, 32)
- val e = Bool(INPUT)
- val z = UInt(OUTPUT, 32)
- val v = Bool(OUTPUT)
- }
+ val io = IO(new Bundle {
+ val a = Input(UInt(32))
+ val b = Input(UInt(32))
+ val e = Input(Bool())
+ val z = Output(UInt(32))
+ val v = Output(Bool())
+ })
val x = Reg(UInt(width = 32))
val y = Reg(UInt(width = 32))
when (x > y) { x := x -% y }
diff --git a/src/test/scala/chiselTests/LFSR16.scala b/src/test/scala/chiselTests/LFSR16.scala
index a1699441..2d5e7f3e 100644
--- a/src/test/scala/chiselTests/LFSR16.scala
+++ b/src/test/scala/chiselTests/LFSR16.scala
@@ -7,10 +7,10 @@ import chisel3.testers.BasicTester
import chisel3.util._
class LFSR16 extends Module {
- val io = new Bundle {
- val inc = Bool(INPUT)
- val out = UInt(OUTPUT, 16)
- }
+ val io = IO(new Bundle {
+ val inc = Input(Bool())
+ val out = Output(UInt(16))
+ })
val res = Reg(init = UInt(1, 16))
when (io.inc) {
val nxt_res = Cat(res(0)^res(2)^res(3)^res(5), res(15,1))
diff --git a/src/test/scala/chiselTests/MemorySearch.scala b/src/test/scala/chiselTests/MemorySearch.scala
index 679b894c..770be326 100644
--- a/src/test/scala/chiselTests/MemorySearch.scala
+++ b/src/test/scala/chiselTests/MemorySearch.scala
@@ -6,12 +6,12 @@ import chisel3._
import chisel3.testers.BasicTester
class MemorySearch extends Module {
- val io = new Bundle {
- val target = UInt(INPUT, 4)
- val en = Bool(INPUT)
- val done = Bool(OUTPUT)
- val address = UInt(OUTPUT, 3)
- }
+ val io = IO(new Bundle {
+ val target = Input(UInt(4))
+ val en = Input(Bool())
+ val done = Output(Bool())
+ val address = Output(UInt(3))
+ })
val vals = Array(0, 4, 15, 14, 2, 5, 13)
val index = Reg(init = UInt(0, width = 3))
val elts = Vec(vals.map(UInt(_,4)))
diff --git a/src/test/scala/chiselTests/Module.scala b/src/test/scala/chiselTests/Module.scala
index 23788b72..7c0bc40e 100644
--- a/src/test/scala/chiselTests/Module.scala
+++ b/src/test/scala/chiselTests/Module.scala
@@ -5,20 +5,20 @@ package chiselTests
import chisel3._
class SimpleIO extends Bundle {
- val in = UInt(INPUT, 32)
- val out = UInt(OUTPUT, 32)
+ val in = Input(UInt(32))
+ val out = Output(UInt(32))
}
class PlusOne extends Module {
- val io = new SimpleIO
+ val io = IO(new SimpleIO)
io.out := io.in + UInt(1)
}
class ModuleVec(val n: Int) extends Module {
- val io = new Bundle {
- val ins = Vec(n, UInt(INPUT, 32))
- val outs = Vec(n, UInt(OUTPUT, 32))
- }
+ val io = IO(new Bundle {
+ val ins = Input(Vec(n, UInt(32)))
+ val outs = Output(Vec(n, UInt(32)))
+ })
val pluses = Vec.fill(n){ Module(new PlusOne).io }
for (i <- 0 until n) {
pluses(i).in := io.ins(i)
@@ -40,8 +40,8 @@ class ModuleVecTester(c: ModuleVec) extends Tester(c) {
*/
class ModuleWire extends Module {
- val io = new SimpleIO
- val inc = Wire(Module(new PlusOne).io)
+ val io = IO(new SimpleIO)
+ val inc = Wire(Module(new PlusOne).io.newType)
inc.in := io.in
io.out := inc.out
}
@@ -58,10 +58,10 @@ class ModuleWireTester(c: ModuleWire) extends Tester(c) {
*/
class ModuleWhen extends Module {
- val io = new Bundle {
+ val io = IO(new Bundle {
val s = new SimpleIO
val en = Bool()
- }
+ })
when(io.en) {
val inc = Module(new PlusOne).io
inc.in := io.s.in
diff --git a/src/test/scala/chiselTests/MulLookup.scala b/src/test/scala/chiselTests/MulLookup.scala
index 831e323f..b22b2820 100644
--- a/src/test/scala/chiselTests/MulLookup.scala
+++ b/src/test/scala/chiselTests/MulLookup.scala
@@ -8,11 +8,11 @@ import org.scalatest.prop._
import chisel3.testers.BasicTester
class MulLookup(val w: Int) extends Module {
- val io = new Bundle {
- val x = UInt(INPUT, w)
- val y = UInt(INPUT, w)
- val z = UInt(OUTPUT, 2 * w)
- }
+ val io = IO(new Bundle {
+ val x = Input(UInt(w))
+ val y = Input(UInt(w))
+ val z = Output(UInt(2 * w))
+ })
val tbl = Vec(
for {
i <- 0 until 1 << w
diff --git a/src/test/scala/chiselTests/OptionBundle.scala b/src/test/scala/chiselTests/OptionBundle.scala
index fa691b43..8e4c7579 100644
--- a/src/test/scala/chiselTests/OptionBundle.scala
+++ b/src/test/scala/chiselTests/OptionBundle.scala
@@ -8,15 +8,15 @@ import chisel3.testers.BasicTester
class OptionBundle(hasIn: Boolean) extends Bundle {
val in = if (hasIn) {
- Some(Bool(INPUT))
+ Some(Input(Bool()))
} else {
None
}
- val out = Bool(OUTPUT)
+ val out = Output(Bool())
}
class OptionBundleModule(hasIn: Boolean) extends Module {
- val io = new OptionBundle(hasIn)
+ val io = IO(new OptionBundle(hasIn))
if (hasIn) {
io.out := io.in.get
} else {
diff --git a/src/test/scala/chiselTests/Padding.scala b/src/test/scala/chiselTests/Padding.scala
index 3fb0f955..6c92e87b 100644
--- a/src/test/scala/chiselTests/Padding.scala
+++ b/src/test/scala/chiselTests/Padding.scala
@@ -5,11 +5,11 @@ package chiselTests
import chisel3._
class Padder extends Module {
- val io = new Bundle {
- val a = Bits(INPUT, 4)
- val asp = SInt(OUTPUT, 8)
- val aup = UInt(OUTPUT, 8)
- }
+ val io = IO(new Bundle {
+ val a = Input(UInt(4))
+ val asp = Output(SInt(8))
+ val aup = Output(UInt(8))
+ })
io.asp := io.a.asSInt
io.aup := io.a.asUInt
}
diff --git a/src/test/scala/chiselTests/ParameterizedModule.scala b/src/test/scala/chiselTests/ParameterizedModule.scala
index 4859759e..14b21631 100644
--- a/src/test/scala/chiselTests/ParameterizedModule.scala
+++ b/src/test/scala/chiselTests/ParameterizedModule.scala
@@ -7,10 +7,10 @@ import chisel3._
import chisel3.testers.BasicTester
class ParameterizedModule(invert: Boolean) extends Module {
- val io = new Bundle {
- val in = new Bool(INPUT)
- val out = new Bool(OUTPUT)
- }
+ val io = IO(new Bundle {
+ val in = Input(Bool())
+ val out = Output(Bool())
+ })
if (invert) {
io.out := !io.in
} else {
diff --git a/src/test/scala/chiselTests/Risc.scala b/src/test/scala/chiselTests/Risc.scala
index f5e61115..fafec95a 100644
--- a/src/test/scala/chiselTests/Risc.scala
+++ b/src/test/scala/chiselTests/Risc.scala
@@ -6,14 +6,14 @@ import chisel3._
import chisel3.util._
class Risc extends Module {
- val io = new Bundle {
- val isWr = Bool(INPUT)
- val wrAddr = UInt(INPUT, 8)
- val wrData = Bits(INPUT, 32)
- val boot = Bool(INPUT)
- val valid = Bool(OUTPUT)
- val out = Bits(OUTPUT, 32)
- }
+ val io = IO(new Bundle {
+ val isWr = Input(Bool())
+ val wrAddr = Input(UInt(8))
+ val wrData = Input(Bits(32))
+ val boot = Input(Bool())
+ val valid = Output(Bool())
+ val out = Output(Bits(32))
+ })
val memSize = 256
val file = Mem(memSize, Bits(width = 32))
val code = Mem(memSize, Bits(width = 32))
diff --git a/src/test/scala/chiselTests/SIntOps.scala b/src/test/scala/chiselTests/SIntOps.scala
index 6cd013f1..a98edf9b 100644
--- a/src/test/scala/chiselTests/SIntOps.scala
+++ b/src/test/scala/chiselTests/SIntOps.scala
@@ -6,24 +6,24 @@ import chisel3._
import chisel3.testers.BasicTester
class SIntOps extends Module {
- val io = new Bundle {
- val a = SInt(INPUT, 16)
- val b = SInt(INPUT, 16)
- val addout = SInt(OUTPUT, 16)
- val subout = SInt(OUTPUT, 16)
- val timesout = SInt(OUTPUT, 16)
- val divout = SInt(OUTPUT, 16)
- val modout = SInt(OUTPUT, 16)
- val lshiftout = SInt(OUTPUT, 16)
- val rshiftout = SInt(OUTPUT, 16)
- val lessout = Bool(OUTPUT)
- val greatout = Bool(OUTPUT)
- val eqout = Bool(OUTPUT)
- val noteqout = Bool(OUTPUT)
- val lesseqout = Bool(OUTPUT)
- val greateqout = Bool(OUTPUT)
- val negout = SInt(OUTPUT, 16)
- }
+ val io = IO(new Bundle {
+ val a = Input(SInt(16))
+ val b = Input(SInt(16))
+ val addout = Output(SInt(16))
+ val subout = Output(SInt(16))
+ val timesout = Output(SInt(16))
+ val divout = Output(SInt(16))
+ val modout = Output(SInt(16))
+ val lshiftout = Output(SInt(16))
+ val rshiftout = Output(SInt(16))
+ val lessout = Output(Bool())
+ val greatout = Output(Bool())
+ val eqout = Output(Bool())
+ val noteqout = Output(Bool())
+ val lesseqout = Output(Bool())
+ val greateqout = Output(Bool())
+ val negout = Output(SInt(16))
+ })
val a = io.a
val b = io.b
diff --git a/src/test/scala/chiselTests/Stack.scala b/src/test/scala/chiselTests/Stack.scala
index cbd9f3e3..683c5224 100644
--- a/src/test/scala/chiselTests/Stack.scala
+++ b/src/test/scala/chiselTests/Stack.scala
@@ -8,13 +8,13 @@ import chisel3._
import chisel3.util._
class ChiselStack(val depth: Int) extends Module {
- val io = new Bundle {
- val push = Bool(INPUT)
- val pop = Bool(INPUT)
- val en = Bool(INPUT)
- val dataIn = UInt(INPUT, 32)
- val dataOut = UInt(OUTPUT, 32)
- }
+ val io = IO(new Bundle {
+ val push = Input(Bool())
+ val pop = Input(Bool())
+ val en = Input(Bool())
+ val dataIn = Input(UInt(32))
+ val dataOut = Output(UInt(32))
+ })
val stack_mem = Mem(depth, UInt(width = 32))
val sp = Reg(init = UInt(0, width = log2Up(depth + 1)))
diff --git a/src/test/scala/chiselTests/Tbl.scala b/src/test/scala/chiselTests/Tbl.scala
index d84cd85e..6ebe0875 100644
--- a/src/test/scala/chiselTests/Tbl.scala
+++ b/src/test/scala/chiselTests/Tbl.scala
@@ -10,13 +10,13 @@ import chisel3.testers.BasicTester
import chisel3.util._
class Tbl(w: Int, n: Int) extends Module {
- val io = new Bundle {
- val wi = UInt(INPUT, log2Up(n))
- val ri = UInt(INPUT, log2Up(n))
- val we = Bool(INPUT)
- val d = UInt(INPUT, w)
- val o = UInt(OUTPUT, w)
- }
+ val io = IO(new Bundle {
+ val wi = Input(UInt(log2Up(n)))
+ val ri = Input(UInt(log2Up(n)))
+ val we = Input(Bool())
+ val d = Input(UInt(w))
+ val o = Output(UInt(w))
+ })
val m = Mem(n, UInt(width = w))
io.o := m(io.ri)
when (io.we) {
diff --git a/src/test/scala/chiselTests/UIntOps.scala b/src/test/scala/chiselTests/UIntOps.scala
index c5069fc4..ca83ee1d 100644
--- a/src/test/scala/chiselTests/UIntOps.scala
+++ b/src/test/scala/chiselTests/UIntOps.scala
@@ -7,23 +7,23 @@ import org.scalatest._
import chisel3.testers.BasicTester
class UIntOps extends Module {
- val io = new Bundle {
- val a = UInt(INPUT, 16)
- val b = UInt(INPUT, 16)
- val addout = UInt(OUTPUT, 16)
- val subout = UInt(OUTPUT, 16)
- val timesout = UInt(OUTPUT, 16)
- val divout = UInt(OUTPUT, 16)
- val modout = UInt(OUTPUT, 16)
- val lshiftout = UInt(OUTPUT, 16)
- val rshiftout = UInt(OUTPUT, 16)
- val lessout = Bool(OUTPUT)
- val greatout = Bool(OUTPUT)
- val eqout = Bool(OUTPUT)
- val noteqout = Bool(OUTPUT)
- val lesseqout = Bool(OUTPUT)
- val greateqout = Bool(OUTPUT)
- }
+ val io = IO(new Bundle {
+ val a = Input(UInt(16))
+ val b = Input(UInt(16))
+ val addout = Output(UInt(16))
+ val subout = Output(UInt(16))
+ val timesout = Output(UInt(16))
+ val divout = Output(UInt(16))
+ val modout = Output(UInt(16))
+ val lshiftout = Output(UInt(16))
+ val rshiftout = Output(UInt(16))
+ val lessout = Output(Bool())
+ val greatout = Output(Bool())
+ val eqout = Output(Bool())
+ val noteqout = Output(Bool())
+ val lesseqout = Output(Bool())
+ val greateqout = Output(Bool())
+ })
val a = io.a
val b = io.b
@@ -77,18 +77,18 @@ class UIntOpsTester(c: UIntOps) extends Tester(c) {
*/
class GoodBoolConversion extends Module {
- val io = new Bundle {
- val u = UInt(1, width = 1).asInput
- val b = Bool(OUTPUT)
- }
+ val io = IO(new Bundle {
+ val u = Input(UInt(1))
+ val b = Output(Bool())
+ })
io.b := io.u.toBool
}
class BadBoolConversion extends Module {
- val io = new Bundle {
- val u = UInt(1, width = 5).asInput
- val b = Bool(OUTPUT)
- }
+ val io = IO(new Bundle {
+ val u = Input(UInt(width = 5))
+ val b = Output(Bool())
+ })
io.b := io.u.toBool
}
diff --git a/src/test/scala/chiselTests/Vec.scala b/src/test/scala/chiselTests/Vec.scala
index 7dd80a13..b90c1f09 100644
--- a/src/test/scala/chiselTests/Vec.scala
+++ b/src/test/scala/chiselTests/Vec.scala
@@ -43,32 +43,6 @@ class ShiftRegisterTester(n: Int) extends BasicTester {
}
}
-class FunBundle extends Bundle {
- val stuff = UInt(width = 10)
-}
-
-class ZeroModule extends Module {
- val io = new Bundle {
- val mem = UInt(width = 10)
- val interrupts = Vec(2, Bool()).asInput
- val mmio_axi = Vec(0, new FunBundle)
- val mmio_ahb = Vec(0, new FunBundle).flip
- }
-
- io.mmio_axi <> io.mmio_ahb
-
- io.mem := UInt(0)
- when (io.interrupts(0)) { io.mem := UInt(1) }
- when (io.interrupts(1)) { io.mem := UInt(2) }
-}
-
-class ZeroTester extends BasicTester {
- val foo = Module(new ZeroModule)
- foo.io.interrupts := Vec.tabulate(2) { _ => Bool(true) }
- assert (foo.io.mem === UInt(2))
- stop()
-}
-
class VecSpec extends ChiselPropSpec {
property("Vecs should be assignable") {
forAll(safeUIntN(8)) { case(w: Int, v: List[Int]) =>
@@ -83,8 +57,4 @@ class VecSpec extends ChiselPropSpec {
property("Regs of vecs should be usable as shift registers") {
forAll(smallPosInts) { (n: Int) => assertTesterPasses{ new ShiftRegisterTester(n) } }
}
-
- property("Dual empty Vectors") {
- assertTesterPasses{ new ZeroTester }
- }
}
diff --git a/src/test/scala/chiselTests/VectorPacketIO.scala b/src/test/scala/chiselTests/VectorPacketIO.scala
index 07779faa..081990ad 100644
--- a/src/test/scala/chiselTests/VectorPacketIO.scala
+++ b/src/test/scala/chiselTests/VectorPacketIO.scala
@@ -28,8 +28,8 @@ class Packet extends Bundle {
* The problem does not occur if the Vec is taken out
*/
class VectorPacketIO(n: Int) extends Bundle {
- val ins = Vec(n, new DeqIO(new Packet()))
- val outs = Vec(n, new EnqIO(new Packet()))
+ val ins = Vec(n, DeqIO(new Packet()))
+ val outs = Vec(n, EnqIO(new Packet()))
}
/**
@@ -38,10 +38,11 @@ class VectorPacketIO(n: Int) extends Bundle {
*/
class BrokenVectorPacketModule extends Module {
val n = 4
- val io = new VectorPacketIO(n)
+ val io = IO(new VectorPacketIO(n))
/* the following method of initializing the circuit may change in the future */
- io.outs.foreach(_.init())
+ io.ins.foreach(_.noenq())
+ io.outs.foreach(_.nodeq())
}
class VectorPacketIOUnitTester extends BasicTester {
diff --git a/src/test/scala/chiselTests/VendingMachine.scala b/src/test/scala/chiselTests/VendingMachine.scala
index f03cb881..00b1e7de 100644
--- a/src/test/scala/chiselTests/VendingMachine.scala
+++ b/src/test/scala/chiselTests/VendingMachine.scala
@@ -6,10 +6,11 @@ import chisel3._
import chisel3.util._
class VendingMachine extends Module {
- val io = new Bundle {
- val nickel = Bool(dir = INPUT)
- val dime = Bool(dir = INPUT)
- val valid = Bool(dir = OUTPUT) }
+ val io = IO(new Bundle {
+ val nickel = Input(Bool())
+ val dime = Input(Bool())
+ val valid = Output(Bool())
+ })
val c = UInt(5, width = 3)
val sIdle :: s5 :: s10 :: s15 :: sOk :: Nil = Enum(UInt(), 5)
val state = Reg(init = sIdle)