I am trying to do a cummulative sum with a series of nested for loops and am having no luck. I think I need a better understanding of how Verilog unrolls the for loops before I can really visualize how to solve my problem.
Essentially I have a series of tap outputs (tap_output_i and tap_output_q) that are 3D arrays (src, dst, tap). I want to sum all the source and taps going to a particular destination each clock.
Here is what I have that does not work (out_sig is 0 every time):
//NODES = 2
wire signed [DAC_BUS_WIDTH-1:0] out_sig_i [NODES-1:0];
wire signed [DAC_BUS_WIDTH-1:0] out_sig_q [NODES-1:0];
reg signed [DAC_BUS_WIDTH-1:0] out_sig_i_reg[NODES-1:0];
reg signed [DAC_BUS_WIDTH-1:0] out_sig_q_reg[NODES-1:0];
integer dstVal,srcVal, tapVal;
//generate
always @(posedge clk) begin: AlwaysSummingForLoop
for (dstVal=0; dstVal<2; dstVal=dstVal+1) begin:SummingForLoop
out_sig_i_reg[dstVal] <= 0;
out_sig_q_reg[dstVal] <= 0;
for (srcVal=0; srcVal<2; srcVal=srcVal+1) begin:SrcForLoop
if(srcVal != dstVal) begin:innerIf
for (tapVal=0; tapVal<8; tapVal=tapVal+1) begin:tapSum
out_sig_i_reg[dstVal] <= out_sig_i_reg[dstVal] + tap_output_i[srcVal][dstVal][tapVal];
out_sig_q_reg[dstVal] <= out_sig_q_reg[dstVal] + tap_output_q[srcVal][dstVal][tapVal];
end
end
end
end
end
//endgenerate
assign out_sig_i[0] = out_sig_i_reg[0];
assign out_sig_q[0] = out_sig_q_reg[0];
assign out_sig_i[1] = out_sig_i_reg[1];
assign out_sig_q[1] = out_sig_q_reg[1];
Where I am running into issues is resetting the cumulative (out_sig_i_reg and out_sig_q_reg) sum every count...