[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编程3 分钟前
【3.2】FFT/IFFT变换的数学原理概述与MATLAB仿真
算法·matlab·fpga·fft·ifft
北京青翼科技13 小时前
青翼科技PCIe总线架构的2路10G光纤通道适配器丨数据采集卡丨PCIe接口板卡 2 路 SFP+光纤收发器
fpga开发·采集卡·fpga板卡·pcie接口·多功能板卡
9527华安15 小时前
2026年FPGA就业培训,临时抱佛脚版本
fpga开发
水云桐程序员15 小时前
Quartus II集成开发环境 |FPGA
笔记·fpga开发·硬件工程·创业创新
XINVRY-FPGA2 天前
XC7VX690T-2FFG1157I Xilinx AMD Virtex-7 FPGA
arm开发·人工智能·嵌入式硬件·深度学习·fpga开发·硬件工程·fpga
R.X. NLOS2 天前
Zynq AXI DMA 环回测试调试指南:从 Cache 一致性到 Vitis 同步机制
fpga
Terasic友晶科技2 天前
【案例展示】友晶科技全息传感器桥接解决方案
科技·fpga开发·holoscan·agilex 5·terasic
学习永无止境@2 天前
Verilog中有符号数计算
图像处理·算法·fpga开发
FPGA-ADDA2 天前
第四篇:射频数据转换器(RF-DAC)——重构模拟信号的关键
ai·fpga·rfsoc·vu13p·xczu47dr
学习永无止境@2 天前
Sobel边缘检测的MATLAB实现
图像处理·opencv·算法·计算机视觉·fpga开发