[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, in1 and out1 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
相关推荐
Riwuarua10 小时前
从近似0基础开始FPGA开发 -- part.10 verilog-ethernet开源UDP协议栈工程学习
fpga开发·udp·开源
my_daling18 小时前
紫光FPGA远程升级注意事项(关于GTP_CFGCLK原语使用问题)
笔记·学习·fpga开发
Riwuarua1 天前
从近似0基础开始FPGA开发 -- part.11 AXI总线协议与工程应用
fpga开发
自小吃多2 天前
高云 FPGA 添加时序约束笔记
笔记·fpga开发
学习FPGA的电气小兴兴2 天前
基于FPGA的CORDIC旋转模式实现sin和cos运算
fpga开发·信号处理·数字信号处理·verilog·fpga·verilog hdl·cordic
blue_ice .2 天前
DDS原理及简易实现
开发语言·经验分享·笔记·嵌入式硬件·fpga开发
明德扬2 天前
AD9653采集模块怎样连接FPGA底板?从ADC采样到数据处理
学习·fpga开发·fpga
上海芯聚电子2 天前
ADC与FPGA之间,如何减少板级设计复杂度?
fpga开发·adc
自小吃多2 天前
高云FPGA ModelSim中的仿真
笔记·嵌入式硬件·fpga开发
通信王662 天前
适用于 FPGA 和 SoC 的UltraFast 设计方法指南(1)-UG949
fpga开发