[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小c鸡1 小时前
FPGA DSP与AI加速应用案例集合:从入门到精通的完整指南
人工智能·fpga开发
Fpga_User1 小时前
关于selectio IP的一些问题
fpga开发·ip
minglie16 小时前
AXI UART_LITE linux测试
fpga开发
Terasic友晶科技9 小时前
2-DE10-Nano的HDMI彩条显示案例(分辨率可切换)—— VGA显示控制器模块设计
fpga开发·de10-nano·hdmi彩条显示·vga显示控制·terasic开发板
kanhao1009 小时前
电平交叉采样 (Level-Crossing Sampling)
算法·fpga开发·fpga
忙什么果21 小时前
上位机、下位机、FPGA、算法放在哪层合适?
算法·fpga开发
环能jvav大师1 天前
在Proteus中仿真PLD元器件(WinCupl及WinSim基础使用)
硬件架构·proteus·fpga
博览鸿蒙1 天前
从迷茫自学到稳定入行:我的 FPGA 上岸全过程
fpga开发
芯门1 天前
FPGA商用级ISP(二):镜头阴影校正(LSC)的网格增益插值与并行硬件架构实现
图像处理·fpga开发·isp
Felven1 天前
corundum 40G开源网卡测试结果
fpga开发·性能测试·dds·开源网卡·mqnic