[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
相关推荐
太空1号16 小时前
SystemVerilog小白入门3,UVM的uvm_object初体验
fpga开发
FakeOccupational20 小时前
【电路笔记 元器件】存储设备:RAM 静态随机存取存储器(SRAM)芯片+异步 SRAM 的特性+异步 SRAM读写测试(HDL)
笔记·fpga开发
嵌入式×边缘AI:打怪升级日志21 小时前
环境监测传感器从设备程序设计(ADC采集与输出控制)
单片机·嵌入式硬件·fpga开发
dadaobusi1 天前
verilog,generate语句
fpga开发
码不停蹄Zzz2 天前
GTX DRP动态重配置技术
fpga开发
LeoZY_2 天前
CH347/339W开源项目:集SPI、I2C、JTAG、SWD、UART、GPIO多功能为一体(5)
stm32·mcu·fpga开发·开源·硬件架构·硬件工程
博览鸿蒙2 天前
FPGA 工程师如何提升自己?
fpga开发
FPGA小c鸡2 天前
FPGA Transformer加速完全指南:从模型优化到硬件实现(附实战案例)
深度学习·fpga开发·transformer
Fpga_User2 天前
项目FPGA类型获取(以xilinx为例)
fpga开发
maverick_1112 天前
【Verilog】强基础,if else 语句,以及综合RTL
fpga开发