[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_ADDA1 小时前
基于VU13P的6U VPX 载板
fpga开发·信号处理·xcvu13p
KOAN凯擎小妹18 小时前
晶振信号质量:上升下降时间与占空比
单片机·嵌入式硬件·fpga开发·信息与通信
cmc102819 小时前
148.PCIE参考时钟无法绑定
fpga开发
我爱C编程1 天前
【硬件片内测试】基于FPGA的完整BPSK链路测试,含频偏锁定,帧同步,定时点,Viterbi译码,信道,误码统计
fpga开发·定时·bpsk·帧同步·卷积编码·维特比译码·频偏估计
FPGA_小田老师1 天前
FPGA基础知识(十一):时序约束参数确定--从迷茫到精通
fpga开发·时序约束·建立时间·保持时间·约束参数计算
FPGA_小田老师1 天前
FPGA基础知识(十二):详解跨时钟域约束
fpga开发·时序约束·跨时钟域·约束完整性
第二层皮-合肥2 天前
基于FPGA的雷达信号处理设计工具包分享
fpga开发·信号处理
美好的事情总会发生2 天前
FPGA的LVDS接口电压
嵌入式硬件·fpga开发·硬件工程·智能硬件
卡奥斯开源社区官方2 天前
量子计算“平价革命”深度解析:AMD破局FPGA方案+中国千比特云服务,技术拐点已至?
fpga开发·量子计算
贝塔实验室2 天前
译码器的结构
驱动开发·算法·网络安全·fpga开发·硬件工程·信息与通信·信号处理