ucb-bar / chisel2-deprecated

chisel.eecs.berkeley.edu
387 stars 90 forks source link

Enable testing variable size modules #515

Open andreaTP opened 9 years ago

andreaTP commented 9 years ago

The problem to solve here is that if I've developed a module that depends on an input parameter and I want to test it against multiple inputs. an example could be this https://github.com/ucb-bar/chisel-tutorial/blob/master/problems/problems.scala#L35

how to test something like for (i <- 2 to 10) yield Module(new Adder(i)) ?

unfortunately the signature of chiseMain is [T <: Module] so I can test one predefined module at time and I cannot have a factory of tests.

kammoh commented 9 years ago

You can easily do that:

val mods = for (i <- 2 to 10) yield Module(new Adder(i))
mods.foreach(mod => chiselMain(args, ()=> mod ) )

or maybe generate modules on the go:

(2 to 10).foreach( i => chiselMain.run(args , () => new Adder(i)) )

On Tue, Aug 25, 2015 at 1:49 PM, Andrea notifications@github.com wrote:

The problem to solve here is that if I've developed a module that depends on an input parameter and I want to test it against multiple inputs. an example could be this https://github.com/ucb-bar/chisel-tutorial/blob/master/problems/problems.scala#L35

how to test something like for (i <- 2 to 10) yield Module(new Adder(i)) ?

unfortunately the signature of chiseMain is [T <: Module] so I can test one predefined module at time and I cannot have a factory of tests.

— Reply to this email directly or view it on GitHub https://github.com/ucb-bar/chisel/issues/515.

andreaTP commented 9 years ago

this drive me to spread around test related code, but if this is the only way to go ok thanks.