1.如果一个信号是由多个信号经过复杂的组合逻辑和时序逻辑产生的,那么应该将组合逻辑比较均匀的分布在各个reg变量前。不应当造成某些reg前面LUT里面没有组合逻辑,而另外一些reg前面的LUT里面组合逻辑过于复杂的情形。均匀分布不仅有利于时序,也能提高SLICE的资源利用率。例如:
第一种:原始编码
always @(posedge Clk or posedge Reset)
begin
if (Reset == 1'b1)
X <= 1'b0;
else
X<= (A & B & C & D & E & F & H & I);
end
always @(posedge Clk or posedge Reset)
begin
if (Reset == 1'b1)
Y <= 1'b0;
else
Y<= (J & K );
end
always @(posedge Clk or posedge Reset)
begin
if (Reset == 1'b1)
Z<= 1'b0;
else
Z<= (X & Y );
end
可优化为
第二种:优化后编码
always @(posedge Clk or posedge Reset)
begin
if (Reset == 1'b1)
X <= 1'b0;
else
X<= (A & B & C & D & E );
end
always @(posedge Clk or posedge Reset)
begin
if (Reset == 1'b1)
Y <= 1'b0;
else
Y<= (J & K & F & H & I );
end
always @(posedge Clk or posedge Reset)
begin
if (Reset == 1'b1)
Z<= 1'b0;
else
Z<= (X & Y );
end |