Skip to content

Commit

Permalink
Support dumping Seqs of values
Browse files Browse the repository at this point in the history
I want to be able to dump a Seq of values that I can then process in the C test
harness.  This patch dumps each element of the array as a seperate #define,
along with a "__COUNT" at the end.  This format is amenable to processing with
C preprocessor repat macros.
  • Loading branch information
palmer-dabbelt committed Feb 17, 2016
1 parent 54a2b0a commit 8671317
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/main/scala/Dump.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import scala.collection.mutable
object Dump {
def apply[T](key:Any,value:T):T = ParameterDump.apply(key, value)
def apply[T](knob:Knob[T]):Knob[T] = ParameterDump.apply(knob)
def apply[T](key_base:String,values:Seq[T]):Seq[T] = {
values.zipWithIndex.foreach{ case(value, i) => Dump(key_base + "__" + i, value) }
Dump(key_base + "__COUNT", values.size)
values
}
}

object ParameterDump {
Expand Down

0 comments on commit 8671317

Please sign in to comment.