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

移位运算与乘法

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***********//
integer i=1;
reg [7:0]d1;
always @(posedge clk or negedge rst) begin
if(rst==0)
 begin out<=0;input_grant<=0;end
 else begin

if(i==1) begin
d1<=d;out<=d*i;i<=3;input_grant<=1; end
else if(i==3)begin
out<=d1*i;i<=7;input_grant<=0;end
else if(i==7) begin
out<=d1*i;i<=8;input_grant<=0; end
else if(i==8) begin
out<=d1*i;i<=1;input_grant<=0; end
 end
end

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

全部评论

相关推荐

不愿透露姓名的神秘牛友
07-04 15:36
点赞 评论 收藏
分享
06-07 19:59
门头沟学院 C++
补药卡我啊😭:都快15年前的了还在11新特性
你的简历改到第几版了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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