[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
相关推荐
ALINX技术博客1 小时前
【黑金云课堂笔记】第一~二期FPGA知识点总结
笔记·fpga开发
240291003371 小时前
modelsim入门--从安装到第一个程序
fpga开发
我爱C编程1 小时前
【3.1】基于FPGA的FFT/IFFT模块开发——前言/目录
fpga开发·教程·通信·fft·傅里叶变换
ZPC82102 小时前
RDMA 与RoCE v2
fpga开发
Terasic友晶科技3 小时前
2-DE10-Nano的HDMI音频传输案例——基于FPGA的I2S控制模块设计
fpga开发·音视频·i2s·de10-nano·hdmi音频传输
ZPC82103 小时前
x86 + FPGA 网卡通信实时性能优化清单
fpga开发·性能优化
学习永无止境@5 小时前
DMA/Bridge Subsystem for PCI Express V4.2
fpga开发·xdma
ZPC82105 小时前
x86 与 FPGA 网卡通信实时性
arm开发·fpga开发
XMAIPC_Robot5 小时前
基于ARM+FPGA的电火花数控硬件平台总体设计(一)
运维·服务器·人工智能·fpga开发·边缘计算
慕云山里被狗追5 小时前
rv1126bp lvds调试
fpga开发