From 8974f749eea1a452ba732dd833376ef4283173a8 Mon Sep 17 00:00:00 2001 From: Jim Lawson Date: Fri, 3 Feb 2017 13:56:32 -0800 Subject: Added vec IO tests for #104 (#480) * Added vec IO tests for #104 * Added Vec test case for Reg of vecs * Change Vec creation to check if gen is lit (and hence needs to be declared) Fixes #104 * Fix tests (add IO())), Vec.fill() * Fix deprecated usage. * Add Binding IO() NPE fix so tests pass. * Fix style - use space consistently. * Fix style - use space consistently. --- .../src/main/scala/chisel3/core/Aggregate.scala | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'chiselFrontend/src/main') diff --git a/chiselFrontend/src/main/scala/chisel3/core/Aggregate.scala b/chiselFrontend/src/main/scala/chisel3/core/Aggregate.scala index efb30326..5f64b079 100644 --- a/chiselFrontend/src/main/scala/chisel3/core/Aggregate.scala +++ b/chiselFrontend/src/main/scala/chisel3/core/Aggregate.scala @@ -43,12 +43,19 @@ object Vec { * * @note elements are NOT assigned by default and have no value */ - def apply[T <: Data](n: Int, gen: T)(implicit compileOptions: CompileOptions): Vec[T] = - new Vec(gen.chiselCloneType, n) + def apply[T <: Data](n: Int, gen: T): Vec[T] = macro VecTransform.apply_ngen; + + def do_apply[T <: Data](n: Int, gen: T)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Vec[T] = { + if ( gen.isLit ) { + Vec(Seq.fill(n)(gen)) + } else { + new Vec(gen.chiselCloneType, n) + } + } @deprecated("Vec argument order should be size, t; this will be removed by the official release", "chisel3") - def apply[T <: Data](gen: T, n: Int)(implicit compileOptions: CompileOptions): Vec[T] = - apply(n, gen) + def apply[T <: Data](gen: T, n: Int)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Vec[T] = + do_apply(n, gen) /** Creates a new [[Vec]] composed of elements of the input Seq of [[Data]] * nodes. @@ -233,7 +240,7 @@ sealed class Vec[T <: Data] private (gen: => T, val length: Int) } override def cloneType: this.type = { - new Vec(gen, length).asInstanceOf[this.type] + new Vec(gen.cloneType, length).asInstanceOf[this.type] } private[chisel3] def toType: String = s"${sample_element.toType}[$length]" -- cgit v1.2.3