[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
相关推荐
我爱C编程11 小时前
【仿真测试】基于FPGA的2ASK扩频通信链路实现,包含帧同步,定时点,扩频伪码同步,信道,误码统计
fpga开发·帧同步·定时点·ask·扩频通信·扩频伪码同步
minglie116 小时前
Wokwi组件
fpga开发
qq_3375994617 小时前
FPGA知识点
经验分享·fpga开发
s090713617 小时前
连通域标记:从原理到数学公式全解析
图像处理·算法·fpga开发·连通域标记
FPGA_小田老师18 小时前
FPGA例程(4):按键消抖实验
fpga开发·verilog·fpga demo·fpga例程
FPGA小c鸡18 小时前
FPGA摄像头采集处理显示完全指南:从OV5640到HDMI实时显示(附完整工程代码)
fpga开发
jz_ddk18 小时前
[学习] NCO原理与误差分析
fpga开发·gps·gnss·北斗
unicrom_深圳市由你创科技18 小时前
专业fpga定制开发解决方案
fpga开发·fpga
ALINX技术博客18 小时前
【ALINX 教程】FPGA 10G 以太网实现——基于 Zynq US+ Z7-P 开发板+FH1223 子卡
fpga开发
s090713619 小时前
FPGA加速:Harris角点检测全解析
图像处理·算法·fpga开发·角点检测