summaryrefslogtreecommitdiff
path: root/src/test/scala/ChiselTests/Outer.scala
blob: 8e206f904a740c82bd5d1fd4a258a486efcd36a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package ChiselTests
import Chisel._

class Inner extends Module {
  val io = new Bundle {
    val in  = Bits(INPUT, 8)
    val out = Bits(OUTPUT, 8)
  }
  io.out := io.in +% Bits(1)
}

class Outer extends Module {
  val io = new Bundle { 
    val in  = Bits(INPUT, 8)
    val out = Bits(OUTPUT, 8)
  }
  // val c = Module(new Inner)
  val c = Array(Module(new Inner))
  // val w = Wire(Bits(NO_DIR, 8))
  // w := io.in
  c(0).io.in := io.in
  io.out  := (c(0).io.out * Bits(2))(7,0)
}

class OuterTester(c: Outer) extends Tester(c) {
  for (t <- 0 until 16) {
    val test_in = rnd.nextInt(256)
    poke(c.io.in, test_in)
    step(1)
    expect(c.io.out, ((test_in + 1) * 2)&255)
  }
}