题解 | #边沿检测#

边沿检测

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

`timescale 1ns/1ns
module edge_detect(
	input clk,
	input rst_n,
	input a,
	
	output reg rise,
	output reg down
);
reg pre,now;

	always @(posedge clk or negedge rst_n)
	begin
		if(!rst_n)
		begin
        now<=1'b0;
		pre<=1'b0;
		down<=1'b0;
		rise<=1'b0;
		end
			else
			begin
			now<=a;
			pre<=now;
			end
	end
always @(*)
begin
			case ({now,pre})
			2'b10:begin rise=1'b1;down=1'b0;end
			2'b01:begin rise=1'b0;down=1'b1;end
			default:begin rise=1'b0; down=1'b0;end
			endcase
end	
endmodule

全部评论

相关推荐

uu们,拒offer时hr很生气怎么办我哭死
爱睡觉的冰箱哥:人家回收你的offer,或者oc后没给你发offer的时候可不会愧疚你,所以你拒了也没必要愧疚他。
点赞 评论 收藏
分享
点赞 评论 收藏
分享
牛客83700679...:简历抄别人的,然后再投,有反馈就是简历不行,没反馈就是学历不行,多投多改只要技术不差机会总会有的
点赞 评论 收藏
分享
07-02 13:52
武汉大学 golang
骗你的不露头也秒
牛客87776816...:😃查看图片
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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