一、源程序:
module usemultiplier(CLK,multiplimcand,multiplier,cout,RST);
input CLK,RST;
input [7:0] multiplimcand;
input [7:0] multiplier;
output [15:0] cout;
reg [7:0] mcandtmp ,ertmp;
reg [15:0] out,cout;
reg [2:0] x;
always @ (posedge CLK , negedge RST)
begin
if(RST==0)
begin
mcandtmp<=0;
ertmp<=0;
out<=0;
x=0;
end
case (x)
0: begin
mcandtmp<=multiplimcand[7]?(~multiplimcand+1):multiplimcand;
ertmp<=multiplier[7]?(~multiplier+1):multiplier;
out<=0;
x=x+1;
end
1:if(ertmp==0) x=x+1;
else begin
ertmp<=ertmp-1;
out<=out+mcandtmp;
end
2:begin
cout<=(multiplimcand[7]^multiplier[7])?~out+1:out;
x=0;
end
default:;
endcase
end
endmodule
二、仿真结果:
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。