如何在 SystemVerilog 约束中实现求和方程?

How to implement Summation equation in SystemVerilog constraints?

c=∑(a[i]*b[i]) 考虑两个数组a和b。对两个数组a和b进行MAC运算的结果c应小于1024。使用SystemVerilog约束来实现上述条件。两个数组的大小可以从 1 到 n,每个数组元素存储 1 个字节。我们必须随机化两个数组。

既然我在聊天中看到了你的解决方案,我会告诉你我的想法

constraint c_sum { c == a.sum() with (a[item.index] * b[item.index]); c < 1024;}