题解 | #边沿检测#

边沿检测

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 ar ;
always @(posedge clk or negedge rst_n)
	if(!rst_n)
		ar <= 0 ;
	else
		ar <= a ;

always @(posedge clk or negedge rst_n)
	if(!rst_n)
		rise <= 0;
	else if (a && ~ar)
		rise <= 1;
	else if (rise)
		rise <= 0;

always @(posedge clk or negedge rst_n)
	if(!rst_n)
		down <= 0;
	else if (~a && ar)
		down <= 1;
	else if (down)
		down <= 0;

endmodule

边沿检测 将原信号打一拍再进行对比 画出波形图一目了然

全部评论

相关推荐

07-03 11:02
中山大学 C++
字节刚oc,但距离九月秋招很近了有两段互联网实习,非腾讯字节。不敢赌转正,现在在纠结去还是不去如果实习俩月离职会有什么后果吗
阿城我会做到的:不去后悔一辈子,能否转正取决于ld的态度,只要他不卡,答辩就是走流程,个人觉得可以冲一把
投递字节跳动等公司10个岗位
点赞 评论 收藏
分享
仁者伍敌:服务员还要脱颖而出,这是五星级酒店吗
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
06-30 18:19
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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