笔试知识点(一些逻辑)

1、对一个单bit的信号进行毛刺滤除,时间小于4bit即为毛刺,采用时序逻辑。

module filter(
	input clk,
  	input rst_n,
  	input data_in,
  	output data_out
);
reg [1:0]cnt;
reg data_in_reg;
always@(posedge clk)begin
	data_in_reg <= data_in;
end
assign data_edge = data_in^data_in_reg;
always@(posedge clk or negedge rst_n)begin
	if(!rst_n)
      cnt <= 0;
	else if(data_edge)
      cnt <= 0;
	else 
      cnt <= cnt + 1;

end
always@(posedge clk or negedge rst_n)begin
	if(!rst_n)
      dout <= 0;
	else if(&cnt)
      dout <= dout_in_r;

end
endmodule
全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

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