[HDLBits] Edgecapture

For each bit in a 32-bit vector, capture when the input signal changes from 1 in one clock cycle to 0 the next. "Capture" means that the output will remain 1 until the register is reset (synchronous reset).

Each output bit behaves like a SR flip-flop: The output bit should be set (to 1) the cycle after a 1 to 0 transition occurs. The output bit should be reset (to 0) at the positive clock edge when reset is high. If both of the above events occur at the same time, reset has precedence. In the last 4 cycles of the example waveform below, the 'reset' event occurs one cycle earlier than the 'set' event, so there is no conflict here.

In the example waveform below, reset, in[1] and out[1] are shown again separately for clarity.

复制代码
module top_module (
    input clk,
    input reset,
    input [31:0] in,
    output [31:0] out
);
    reg [31:0] old;
    always@(posedge clk) old<=in;
    always@(posedge clk) begin
        if(reset)
            out<=32'b0;
        else
            out<=old&(~in)|out;
        //这里需要或上一个out才能保持
    end
endmodule
相关推荐
FPGA小c鸡20 小时前
异步FIFO设计与验证完全指南:从格雷码到CDC同步的深度解析(附SystemVerilog实战代码)
fpga开发
春风细雨无声1 天前
基于FPGA实现PAL视频接口(附代码)
图像处理·fpga开发·视频
算法笑匠1 天前
FPGA驱动AD9226实现65MSPS高速数据采集
fpga·adc·高速数据采集·ad9226
国科安芯1 天前
多相交错并联系统的时钟同步精度与输入纹波抵消效应研究
网络·单片机·嵌入式硬件·fpga开发·性能优化
科恒盛远2 天前
KH919-基于FPGA实现的线性调频卡
fpga开发
FPGA小c鸡3 天前
PCIe接口详解:从协议原理到FPGA实现的完整指南
fpga开发
良许Linux3 天前
FPGA原理和应用
stm32·单片机·fpga开发·程序员·嵌入式·编程
Hello.Reader3 天前
Flink External Resource Framework让作业“原生”申请 GPU/FPGA 等外部资源
大数据·fpga开发·flink
嵌入式-老费3 天前
Linux Camera驱动开发(fpga vs soc)
驱动开发·fpga开发
太空1号4 天前
SystemVerilog小白入门3,UVM的uvm_object初体验
fpga开发