我写了移位加法器单元的代码....但我没有得到正确的结果...这里我不能发布相同的ckt ...我认为那里的clk同步问题
module shift_adder_8a(clk,,j0,j7,s089,s075,s050,s018);
input clk;
input [2:0] j0,j7;
reg[3:0]z0;
output reg[10:0]s089,s075,s050,s018;
reg[6:0] o0,p0;
always@(posedge clk )
begin
z0 <= j0-j7;
o0 <= (z0<<3)+z0;
p0 <= (z0<<4)+o0;
s089 <= (z0<<6)+p0;
s075 <= (p0<<1)+p0;
s050 <= (p0<<1);
s018 <= (o0<<1);
end
endmodule
答案 0 :(得分:0)
如果没有“得到正确的结果”,我假设你的意思是结果会延迟。
尝试将z0
,o0
,p0
分配移动到组合块中:
always @* begin
z0 = j0-j7;
o0 = (z0<<3)+z0;
p0 = (z0<<4)+o0;
end
always@(posedge clk )
begin
s089 <= (z0<<6)+p0;
s075 <= (p0<<1)+p0;
s050 <= (p0<<1);
s018 <= (o0<<1);
end