Verilog 中与 1023 个 10 位向量的异或相关的延迟

Delay associated with xor of 1023 10 bit vectors in Verilog

我对 verilog 有点陌生,有一个问题让我很困惑。 我有许多常量参数,特别是 ci 其中将近 1023 个 c0、c1、c2 ..... c1022,每个都是 10 位长度。我还有一个向量 r[1022:0] ,长度为 1023 位。我的任务是计算 ci*r[i],其中 i 在 0 到 1022 之间变化,最后取 1023 个 10 位向量的异或,我 get.When 我在模拟中这样做,verilog 生成输出在 assign 语句的时间 0。 verilog 如何在时间 0 生成输出?这些1023异或运算不会有延迟吗?ci 另外,如果我需要这样做 succinctly ,有没有我可以使用的简短形式,或者我需要手动编写 c0 *r[0] ^ c1 *r[1] ..... .^ c[1022]*r[1022] 是可合成的 ?

Verilog 模拟器将执行您提供的任何合法语法——该工具对最终实现的样子一无所知。将时序约束提供给综合工具取决于您,它会告诉您它是否适合满足约束的逻辑(或者您可能需要 运行 另一个工具来查看它是否满足时序约束)。

既然您将参数命名为 c0, c1, c2, ...,您不妨将它们命名为 czero, cone, ctwo, ...,这样您就没有快捷方式选项了。

如果你的工具支持SystemVerilog,你可以将你的参数写成一个数组,然后使用数组异或归约运算符

parameter [9:0] C[1023] = {10'h123, 10'h234, ...};
assign out = C.xor() with (item*r[item.index]);

如果您的综合工具不支持这种 SystemVerilog 语法,您可以将参数值打包到单个向量中并在 Verilog 中使用索引部分 select。

   parameter [10220-1:0] C = {10'h123, 10'h234, ...};

   function [9:0] xor_reduction (input [1022:0] r);
     integer I;
     begin
       xor_reduction = 0;
       for(I=0;I<1023;I=I+1)
          xor_reduction = xor_refuction ^ (r[1022-I]*C[I-:10]);
     end
   endfunction
   assign out = xor_reduction(r);