我在 Virtex6 上有一段代码,可以一次汇总一堆东西。我继承了代码,它似乎比我想象的要困难一些,但有人告诉我这是快速总结事情的最佳方式。
基本上,如果我有一系列需要添加的值(比如其中 16 个),我们目前正在将它们添加为多个级别(summedOutput 和 addOverflow 是执行有符号加法和检测溢出的两个函数):
tmpSig_0_0 <= summedOutput(inSig_0, inSig_1);
tmpSig_0_1 <= summedOutput(inSig_2, inSig_3);
tmpSig_0_2 <= summedOutput(inSig_4, inSig_5);
tmpSig_0_3 <= summedOutput(inSig_6, inSig_7);
tmpSig_0_4 <= summedOutput(inSig_8, inSig_9);
tmpSig_0_5 <= summedOutput(inSig_10, inSig_11);
tmpSig_0_6 <= summedOutput(inSig_12, inSig_13);
tmpSig_0_7 <= summedOutput(inSig_14, inSig_15);
overflow_stage0 <= (| {overflow_input,additionOverflow(inSig_0,inSig_1,inSig_0+inSig_1),additionOverflow(inSig_2,inSig_3,inSig_2+inSig_3),additionOverflow(inSig_4,inSig_5,inSig_4+inSig_5),additionOverflow(inSig_6,inSig_7,inSig_6+inSig_7),additionOverflow(inSig_8,inSig_9,inSig_8+inSig_9),additionOverflow(inSig_10,inSig_11,inSig_10+inSig_11),additionOverflow(inSig_12,inSig_13,inSig_12+inSig_13),additionOverflow(inSig_14,inSig_15,inSig_14+inSig_15)});
tmpSig_1_0 <= summedOutput(tmpSig_0_0, tmpSig_0_1);
tmpSig_1_1 <= summedOutput(tmpSig_0_2, tmpSig_0_3);
tmpSig_1_2 <= summedOutput(tmpSig_0_4, tmpSig_0_5);
tmpSig_1_3 <= summedOutput(tmpSig_0_6, tmpSig_0_7);
overflow_stage1 <= (| {overflow_stage0, additionOverflow(tmpSig_0_0,tmpSig_0_1,tmpSig_0_0+tmpSig_0_1), additionOverflow(tmpSig_0_2,tmpSig_0_3,tmpSig_0_2+tmpSig_0_3), additionOverflow(tmpSig_0_4,tmpSig_0_5,tmpSig_0_4+tmpSig_0_5), additionOverflow(tmpSig_0_6,tmpSig_0_7,tmpSig_0_6+tmpSig_0_7)});
tmpSig_2_0 <= summedOutput(tmpSig_1_0, tmpSig_1_1);
tmpSig_2_1 <= summedOutput(tmpSig_1_2, tmpSig_1_3);
overflow_stage2 <= (| {overflow_stage1, additionOverflow(tmpSig_1_0,tmpSig_1_1,tmpSig_1_0+tmpSig_1_1), additionOverflow(tmpSig_1_2,tmpSig_1_3,tmpSig_1_2+tmpSig_1_3)});
outSig <= summedOutput(tmpSig_2_0, tmpSig_2_1);
overflow <= (| {overflow_stage2, additionOverflow(tmpSig_2_0, tmpSig_2_1, tmpSig_2_0+tmpSig_2_1)});
有人告诉我,这将导致 4 个级别的添加(这是有道理的),并且比 16 个级别要好得多,如果我刚刚这样做的话:
outSig <= inSig_0 + inSig_1 + inSig_2 + inSig_3 .... inSig_14 + inSig_15;
我的问题是,如果我想扩展东西,这是一个非常手动的过程,而且不是很适应。有没有比我更聪明的方法呢?最好的办法是一系列基于参数大小添加内容的 for 循环,但我基本上会以上面的第二个示例结束,这可能非常深。