最近需要写一个测试激励,因为输入信号比较多,所以每个都poke会很麻烦,那么怎么办呢,可以通过把输入转换成Seq的方法再使用collection的方法进行赋值,会简单许多。下面看一个例子
// Max3 returns the max of its 3 arguments
class a extends Bundle {
val a = Input(UInt(16.W))
val b =Input(UInt(16.W))
val c = Input(UInt(16.W))
def y = Seq(a,b,c)
}
class Max3 extends Module {
val io = IO(new Bundle {
val in = new a
val out = Output(UInt(16.W))
})
val inputBundle = Seq(io.in.a,io.in.b,io.in.c)
when(io.in.a > io.in.b && io.in.a > io.in.c) {
io.out := io.in.a
}.elsewhen(io.in.b > io.in.a && io.in.b > io.in.c) {
io.out := io.in.b
}.otherwise {
io.out := io.in.c
}
}
// verify that the max of the three inputs is correct
class Max3Tester(c: Max3) extends PeekPokeTester(c) {
val x = Seq(6,4,2)
//val inputBundle = Seq(c.io.in.a,c.io.in.b,c.io.in.c)
val test &#