I'm writing a convolution neural network accelerator. In the conv unit, I choose to implement convolution with 3 1D FIRs. In the testing stage, I got UInt*SInt multiply results instead of SInt*SInt. Here is my 1D FIR implemented in Chisel
class OneDemConvGen(wgh_num:Int=3, ipt_wid:Int = 8, wgh_wid:Int=8, psum_wid:Int=32) extends Module{
val io = IO(new Bundle() {
val in = Input(SInt(ipt_wid.W))
val weights = Input(Vec(wgh_num, SInt(wgh_wid.W)))
val psum = Output(SInt(psum_wid.W))
})
val muls = Seq.fill(wgh_num)(Wire(SInt(psum_wid.W))).zip(io.weights).map({case (p, w) => p := io.in*w; p})
val sum = muls.fold(0.S)((a, b) => RegNext(a+b, 0.S))
io.psum := sum
}
I am testing the DLA, and the 1D fir is instanced as a submodule, I got a completely wrong result.
Wave of incorrect result
As you can see from the figure. the muls-0 =\= -29 * -58, the result -13166 = 227 * -58, its confusing. However, I got the correct result when I tested the fir independently.
Wave of incorrect result