[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
相关推荐
FPGA-ADDA4 小时前
第五篇(下):智能无线电与6G候选技术——从机器学习到通感一体化
人工智能·机器学习·信号处理·fpga·通信系统
maverick_1114 小时前
【FPGA】关于两个数相加的“坑”
c语言·matlab·fpga开发
碎碎思5 小时前
经典复活:3dfx Voodoo 显卡,正在被 FPGA“重做一遍”
fpga开发
listhi5206 小时前
基于FPGA的电压表与串口通信系统设计
fpga开发
rit84324997 小时前
基于FPGA的数字秒表设计(Verilog实现)
fpga开发
tiantianuser9 小时前
RDMA设计64:数据吞吐量性能测试分析
网络·fpga开发·rdma·fpga设计·高速传输·roce v2
木心术19 小时前
OpenClaw FPGA工程开发全流程指南
fpga开发
dadaobusi1 天前
ZeBu的runClk原理
fpga开发
第二层皮-合肥1 天前
50天学习FPGA第32天-添加HDL属性调试
学习·fpga开发
minglie11 天前
MAC,PHY,变压器,RJ45
fpga开发