[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
相关推荐
qq_小单车3 小时前
xilinx-DNA
fpga开发·xilinx
Flamingˢ4 小时前
FPGA中的嵌入式块存储器RAM:从原理到实现的完整指南
fpga开发
Flamingˢ5 小时前
FPGA中的存储器模型:从IP核到ROM的深度解析与应用实例
网络协议·tcp/ip·fpga开发
FPGA小c鸡1 天前
【FPGA深度学习加速】RNN与LSTM硬件加速完全指南:从算法原理到硬件实现
rnn·深度学习·fpga开发
Aaron15881 天前
通信灵敏度计算与雷达灵敏度计算对比分析
网络·人工智能·深度学习·算法·fpga开发·信息与通信·信号处理
博览鸿蒙1 天前
IC 和 FPGA,到底区别在哪?
fpga开发
思尔芯S2C1 天前
FPGA原型验证实战:如何应对外设连接问题
fpga开发·risc-v·soc设计·prototyping·原型验证
Flamingˢ1 天前
FPGA实战:VGA成像原理、时序详解与Verilog控制器设计与验证
fpga开发
FPGA_小田老师1 天前
xilinx原语:OSERDES2(并串转换器)原语详解
fpga开发·lvds·xilinx原语·oserdese·并串转换
Blossom.1181 天前
从数字大脑到物理实体:具身智能时代的大模型微调与部署实战
人工智能·python·深度学习·fpga开发·自然语言处理·矩阵·django