题解 | #流水线乘法器#

流水线乘法器

https://www.nowcoder.com/practice/be97f63817c543fe9260d46d971a7283

	reg[3:0] temp0,temp1,temp2,temp3;

	always@(posedge clk, negedge rst_n)begin
		if(!rst_n)begin
			mul_out	<='d0;
			temp0<='d0;
			temp1<='d0;
			temp2<='d0;
			temp3<='d0;
		end
		else begin
			temp0<=mul_b[0]?mul_a:'d0;
			temp1<=mul_b[1]?mul_a:'d0;
			temp2<=mul_b[2]?mul_a:'d0;
			temp3<=mul_b[3]?mul_a:'d0;
			mul_out	<=temp0+(temp1<<1)+(temp2<<2)+(temp3<<3);
		end
	end

全部评论

相关推荐

点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务