欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

同步上升沿检测

程序员文章站 2022-04-30 11:32:52
...
module cy4(
       input clk,
       input rstb,
       input sig_a,
       output sig_a_risedge
          );
reg sig_a_d1;
always @(posedge clk or negedge rstb)
  if(!rstb) sig_a_d1 <= 1'b0;
  else sig_a_d1 <= sig_a;

assign sig_a_risedge = sig_a & !sig_a_d1;

endmodule

同步上升沿检测

测试脚本代码
`timescale 1 ns/ 1 ps
module cy4_vlg_tst();

reg clk;
reg rstb;
reg sig_a;
// wires
wire sig_a_risedge;

cy4 i1 (

.clk(clk),
.rstb(rstb),
.sig_a(sig_a),
.sig_a_risedge(sig_a_risedge)

);
initial
begin
sig_a = 0;
clk = 0;
rstb = 0;

100;

rstb = 1;
sig_a = 0;

100;

sig_a = 1;

100;

stop;display(“Running testbench”);
end
always #20 clk = ~clk ;
endmodule

相关标签: FPGA