所谓资源分配,是指在互斥条件下,共享ALU的过程。
通常利用多路选择器的引入,来减少ALU的个数,从而节省资源。
看下列实例:
if (!ishreg)
data_out = addr_load + chip_sel;
else if (rd_wr)
data_out = read + write;
else
data_out = addr_load + read;
改进后:
if (!shReg)
begin
temp1 = addr_load;
temp2 = chip_sel;
end
else if (rd_wr)
begin
temp1 = read;
temp2 = write;
end
else
begin
temp1 = addr_load;
temp2 = read;
end
data_out = temp1 + temp2;
改进后的代码多产生了一个多路选择器,但是只使用了一个加法器,而改进之前的代码使用了三个加法器。