1、资源共享
资源共享主要是指在互斥(Mutually-Exclusive) 条件下(即不能同时运行)共享算术逻辑单元(Arithmetic Logic Unit)。
module test(a, b, c, sel, result); //相同运算符没有资源共享
input [7:0) a, b, c;
input sel;
output [8:0] result;
reg [8:0] result;
always @ (a or b or sel)begin
if (sel)
result = a + b;
else
result = a + c;
end
endmodule
在没有使用资源共亨的情况下, 上面的代码综合出如下图所示的硬件结构,两条加法运算分别综合成两个独立的算术逻辑单元(加法器)。
modu1e test(a, b, c, sel, resu1c); //相同运算符使用资源共享
input [7:0] a, b, c;
input sel;
output [8:0) result;
reg [8:0] result;
reg (7:0] temp;
a1ways @(a or b or C or sel)begin
if (se1