I am trying to create a synthesizable FIR filter using Chisel. I am reading signed integers from a csv file which I then pass to the FIR filter class as coefficients. Just to give you all a flavor - this is what the coefficient look like:
-152651856 1233223 ...
A for loop is used to then do the MAC operation across the coefficients of the filter. I can't find the reason why the for loop is not unrolling properly. It is only synthesizing the last coefficient as a constant.
class FIR (val coefficients:Array[Int], val count:Int ) extends Module {
val io = IO(new Bundle {
val X = Input(Vec(count,SInt(16.W)))
val Y_out = Output(SInt(64.W))
})
val sum = Reg(SInt(64.W))
sum := 0.S(64.W)
val temp = Reg(Vec(count,SInt(64.W)))
for(ct <- 0 until count ) {
temp(ct) := new fromIntToLiteral(coefficients(ct): Int).S
sum := sum + temp(ct) * io.X(ct)
}
io.Y_out := sum
}
Here array coefficients are the coefficients of the filter passed to the class and count is the number of coefficients.