summaryrefslogtreecommitdiff
path: root/src/main/scala/Chisel/testers/BasicTester.scala
blob: fecbe2a9a5b5a7a775f00e61cada0f2340e61664 (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
// See LICENSE for license details.

package Chisel.testers
import Chisel._

import internal._
import internal.Builder.pushCommand
import firrtl._

class BasicTester extends Module {
  val io = new Bundle {
    val done = Bool()
    val error = UInt(width = 4)
  }
  io.done := Bool(false)
  io.error := UInt(0)

  def popCount(n: Long): Int = n.toBinaryString.count(_=='1')

  /** Ends the test, reporting success.
    */
  def stop() {
    pushCommand(Stop(Node(clock), 0))
  }
}