[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
相关推荐
良许Linux4 小时前
FPGA的选型和应用
数据库·图像处理·计算机视觉·fpga开发
上班最快乐4 小时前
基于FPGA的APS6404L-3SQR QSPI PSRAM驱动设计(3)
fpga开发
CoderIsArt4 小时前
FPGA实现量子计算机仿真器重要论文
fpga开发·量子计算
上班最快乐6 小时前
基于FPGA的APS6404L-3SQR QSPI PSRAM驱动设计(4)
fpga开发
LCMICRO-133108477461 天前
长芯微LDC64115完全P2P替代AD4115,是一款低功耗、低噪声、24位、Σ-Δ(Σ-Δ)模数转换器(ADC)
stm32·单片机·嵌入式硬件·fpga开发·硬件工程·模数转换器
inquisiter1 天前
plic中断级联设计和使用
fpga开发·riscv
JSMSEMI111 天前
JSM3488E RS‑485/RS‑422 收发器芯片
fpga开发
学习永无止境@2 天前
Vivado FPGA程序压缩
fpga开发
daxi1502 天前
Verilog入门实战——第2讲:核心语法基础(数据类型+赋值语句)
fpga开发·fpga
嵌入式-老费2 天前
Linux camera驱动开发(vivado hls不能导出ip的问题)
图像处理·fpga开发