[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
相关推荐
技术性摸鱼11 小时前
FPGA选型参数
fpga开发
FPGA_小田老师13 小时前
ibert 7 Series GT:IBERT远近端(内外)环回测试
fpga开发·ibert·gt测试·近端pcs环回·近端pma环回·远端pcs环回·远端pma环回
尤老师FPGA14 小时前
【无标题】
fpga开发
才鲸嵌入式16 小时前
香山CPU(国产开源)的 SoC SDK底层程序编写,以及其它开源SoC芯片介绍
c语言·单片机·嵌入式·arm·cpu·verilog·fpga
1750633194518 小时前
VIVADO VLA VIO 硬件调试 降采样
fpga开发
FPGA小迷弟18 小时前
基于FPGA开发高速ADC/DAC芯片笔记
图像处理·fpga开发·数据采集·fpga·adc
ZYNQRFSOC1 天前
基于XCKU5P纯逻辑 NVME测试
fpga开发
FPGA小迷弟2 天前
使用FPGA开发高速AD/DA芯片的接口学习
fpga开发
stars-he2 天前
FPGA学习笔记(6)逻辑设计小结与以太网发送前置
笔记·学习·fpga开发
燎原星火*2 天前
FPGA 逻辑级数
fpga开发