[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
相关推荐
云端码字人1 小时前
007、PCIE数据链路层:可靠传输的保障
fpga开发
nuoxin11418 小时前
CH6001FN/BW-富利威
网络·人工智能·嵌入式硬件·fpga开发·dsp开发
LCMICRO-133108477461 天前
长芯微LCMDC8685完全P2P替代ADS8685,16位模数转换器(ADC)
单片机·嵌入式硬件·fpga开发·硬件工程·dsp开发·模数转换器adc
szxinmai主板定制专家1 天前
基于ARM+FPGA高性能MPSOC 多轴伺服设计方案
arm开发·人工智能·嵌入式硬件·fpga开发·架构
nuoxin1141 天前
CYUSB4024-FCAXI 是一款USB 20Gbps 控制器-富利威
网络·人工智能·嵌入式硬件·fpga开发·dsp开发
LCMICRO-133108477461 天前
长芯微LCMDC8584完全P2P替代ADS8584,是一款16位、4通道同步采样的逐次逼近型(SAR)模数转换器(ADC)
stm32·单片机·嵌入式硬件·fpga开发·硬件工程·模数转换器adc
尤老师FPGA2 天前
Framebuffer的讲解
fpga开发
FPGA的花路2 天前
ZYNQ 程序固化与升级指南
fpga开发·vitis·一键烧录脚本·zynq程序构成
ALINX技术博客2 天前
【黑金云课堂】FPGA技术教程:PLL锁相环实验和MIO应用
fpga开发·fpga
Byron Loong2 天前
【常识】通俗易懂的讲CPU,GPU,MCU,FPGA,DSP的区别和特点
单片机·嵌入式硬件·fpga开发