[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
相关推荐
szxinmai主板定制专家3 小时前
【国产NI替代】基于全国产FPGA的16振动+2转速+8路IO口输入输出(24bits)256k采样率,高精度终端采集板卡
大数据·人工智能·fpga开发
高性能服务器3 小时前
《异构计算:多元算力聚变,点燃高性能计算新引擎 – CPU、GPU与FPGA算力融合》
深度学习·fpga开发·gpu算力·hpc·高性能计算·异构计算·通用计算
9527华安8 小时前
FPGA多路红外相机视频拼接输出,提供2套工程源码和技术支持
图像处理·fpga开发·视频拼接·红外相机
可知可知不可知10 小时前
详解VHDL如何编写Testbench
fpga开发
szxinmai主板定制专家1 天前
【国产NI替代】32振动/电压(配置复合型)高精度终端采集板卡,应用于复杂的大型测量场景
fpga开发
9527华安1 天前
FPGA实时红外相机采集输出系统,提供工程源码和技术支持
图像处理·fpga开发·红外相机
博览鸿蒙1 天前
FPGA自学之路:到底有多崎岖?
fpga开发
搬砖的小码农_Sky1 天前
硬件设计:RS485电平标准
单片机·嵌入式硬件·fpga开发
搬砖的小码农_Sky1 天前
硬件设计:LVDS电平标准
嵌入式硬件·fpga开发
∑狸猫不是猫1 天前
(15)CT137A- 按键消抖设计
fpga开发