valid, a boolean that says when the input is valid
consts, a vector for all the taps
and 1 output:
out, the filtered input
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
classMyManyDynamicElementVecFir(length: Int) extendsModule{ val io = IO(newBundle { val in = Input(UInt(8.W)) val valid = Input(Bool()) val out = Output(UInt(8.W)) val consts = Input(Vec(length, UInt(8.W))) })
// Such concision! You'll learn what all this means later. val taps = Seq(io.in) ++ Seq.fill(io.consts.length - 1)(RegInit(0.U(8.W))) taps.zip(taps.tail).foreach { case (a, b) => when (io.valid) { b := a } }
io.out := taps.zip(io.consts).map { case (a, b) => a * b }.reduce(_ + _) }