[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
相关推荐
HIZYUAN1 天前
FPGA/CPLD漫谈:2K LUT的功能定位与典型方案(一)
stm32·单片机·嵌入式硬件·fpga开发·国产mcu+fpga
FPGA_Linuxer1 天前
FPGA开发板 KU5P开发板 图像处理,硬件加速 PCIE3.0 100G光口
fpga开发
szxinmai主板定制专家1 天前
基于ZYNQ MPSOC多通道声音振动采集方案,替代NI9234和B&K
arm开发·人工智能·嵌入式硬件·fpga开发
ZYNQRFSOC2 天前
基于安路PH2A系列FPGA的JESD204B接口测试
嵌入式硬件·fpga开发
szxinmai主板定制专家2 天前
基于RK3588超小体积,轻巧,长续航的无人机AI模块,支持视频跟踪
arm开发·人工智能·嵌入式硬件·fpga开发·无人机
unicrom_深圳市由你创科技3 天前
多 FPGA 之间如何同步与通信?
fpga开发
LCMICRO-133108477463 天前
长芯微LCMDC7616完全P2P替代AD7616,16通道16位模数转换器(ADC)
stm32·嵌入式硬件·fpga开发·硬件工程·模数转换器adc·电力线监测
又菜又爱玩的东哥3 天前
【Verilog 3-8译码器设计与仿真:深入理解case语句与组合逻辑】
fpga开发
Risehuxyc3 天前
<= 是Verilog中的非阻塞赋值操作符
fpga开发
扣脑壳的FPGAer3 天前
傅里叶级数、傅里叶变换、Z变换、数字滤波器
fpga开发·信号处理