[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
相关推荐
anhuihbo15 小时前
FPGA实现VESA DSC编码功能
fpga开发·vesa dsc
ThreeYear_s16 小时前
基于fpga的疲劳驾驶检测
fpga开发
岁月磨吾少年志1 天前
【FPGA开发】DDS信号发生器设计
fpga开发
DQI-king1 天前
ZYNQ学习记录FPGA(三)状态机
学习·fpga开发
ThreeYear_s1 天前
基于FPGA的PID算法学习———实现PI比例控制算法
学习·算法·fpga开发
ThreeYear_s2 天前
基于FPGA的PID算法学习———实现PID比例控制算法
学习·算法·fpga开发
第二层皮-合肥2 天前
实战案例-FPGA如何实现JESD204B可重复的延迟
fpga开发
9527华安2 天前
国产安路FPGA实现图像视频采集转HDMI输出,提供5套TD工程源码和技术支持
fpga开发·音视频·安路·安路fpga·tangdynasty
DQI-king3 天前
ZYNQ学习记录FPGA(二)Verilog语言
学习·fpga开发·zynq
9527华安3 天前
国产安路FPGA纯verilog图像缩放,工程项目解决方案,提供5套TD工程源码和技术支持
fpga开发·verilog·图像缩放·双线性插值·安路fpga