[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
相关推荐
ChipCamp9 小时前
Chisel芯片开发入门系列 -- 14. CPU芯片开发和解释4(Load/Store指令再探)
arm开发·青少年编程·fpga开发·scala·dsp开发·risc-v·chisel
霖0011 小时前
深入讲讲异步FIFO
笔记·vscode·单片机·嵌入式硬件·学习·fpga开发
水果里面有苹果12 小时前
3-verilog的使用-1
fpga开发
嵌入式-老费13 小时前
再谈fpga开发(总结篇)
fpga开发
minglie115 小时前
基于 AXI-Lite 实现可扩展的硬件函数 RPC 框架(附完整源码)
fpga开发
朱古力(音视频开发)18 小时前
NDI开发指南
fpga开发·音视频·实时音视频·视频编解码·流媒体
9527华安1 天前
FPGA实现AD9361采集转SRIO与DSP交互,FPGA+DSP多核异构信号处理架构,提供2套工程源码和技术支持
fpga开发·架构·信号处理·dsp·ad9361·多核异构
小眼睛FPGA1 天前
【盘古100Pro+开发板实验例程】FPGA学习 | 基于紫光 FPGA 的键控 LED 流水灯
科技·学习·ai·fpga开发·fpga
最好有梦想~2 天前
分享一个FPGA寄存器接口自动化工具
fpga开发
hahaha60162 天前
FPGA(或者数字电路)中组合逻辑和时序逻辑是怎么划分的
fpga开发