题解 | #移位运算与乘法#

移位运算与乘法

https://www.nowcoder.com/practice/1dd22852bcac42ce8f781737f84a3272

`timescale 1ns/1ns
module multi_sel(
input [7:0]d ,
input clk,
input rst,
output reg input_grant,
output reg [10:0]out
);
//*************code***********//
reg [1:0] cnt;
reg [10:0] din;

always @ (posedge clk or negedge rst)
begin
if (!rst) begin
cnt<=0;
out<=0;
input_grant<=0;
din<=0;end
else begin
cnt<=cnt+1;
case(cnt)
2'd0:begin out<=d; input_grant <= 1 ;din <=d; end
2'd1:begin out<=(din<<2)-din; input_grant <= 0 ; end
2'd2:begin out<=(din<<3)-din; input_grant <= 0 ; end
2'd3:begin out<=din<<3; input_grant <= 0 ; end
endcase
end

end


//*************code***********//
endmodule

全部评论

相关推荐

想按时下班的我在等offer:我投测试也是这个情况,不知道咋办了
点赞 评论 收藏
分享
06-17 21:57
门头沟学院 Java
白友:噗嗤,我发现有些人事就爱发这些,明明已读不回就行了,就是要恶心人
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务