[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
相关推荐
博览鸿蒙42 分钟前
FPGA 工程师如何提升自己?
fpga开发
FPGA小c鸡6 小时前
FPGA Transformer加速完全指南:从模型优化到硬件实现(附实战案例)
深度学习·fpga开发·transformer
Fpga_User6 小时前
项目FPGA类型获取(以xilinx为例)
fpga开发
maverick_1111 天前
【Verilog】强基础,if else 语句,以及综合RTL
fpga开发
FPGA小c鸡1 天前
FPGA DSP与AI加速应用案例集合:从入门到精通的完整指南
人工智能·fpga开发
Fpga_User1 天前
关于selectio IP的一些问题
fpga开发·ip
minglie11 天前
AXI UART_LITE linux测试
fpga开发
Terasic友晶科技1 天前
2-DE10-Nano的HDMI彩条显示案例(分辨率可切换)—— VGA显示控制器模块设计
fpga开发·de10-nano·hdmi彩条显示·vga显示控制·terasic开发板
kanhao1001 天前
电平交叉采样 (Level-Crossing Sampling)
算法·fpga开发·fpga
忙什么果2 天前
上位机、下位机、FPGA、算法放在哪层合适?
算法·fpga开发