[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
相关推荐
晓晓暮雨潇潇15 小时前
Diamond基础6:LatticeFPGA配置流程
fpga开发·diamond·lattice·latticeecp3
江蘇的蘇16 小时前
基于7系列FPGA实现万兆网通信
fpga开发
GateWorld19 小时前
FPGA实战:一段让我重新认识时序收敛的FPGA迁移之旅
fpga开发·实战经验·fpga时序收敛·建立保持时间
GateWorld20 小时前
性能飞跃:DDR4特性解析与FPGA实战指南
fpga开发·信号完整性·ddr3·ddr4
AllenGates20 小时前
Pynq中SD卡写入image - Writing an SD Card Image
fpga·pynq
第二层皮-合肥21 小时前
50天学习FPGA第21天-verilog的时序与延迟
学习·fpga开发
范纹杉想快点毕业21 小时前
FPGA实现同步RS422转UART方案
数据库·单片机·嵌入式硬件·fpga开发·架构
s09071361 天前
Xilinx FPGA使用 FIR IP 核做匹配滤波时如何减少DSP使用量
算法·fpga开发·xilinx·ip core·fir滤波
XINVRY-FPGA1 天前
XC7Z030-2SBG485I Xilinx Zynq-7000 系列 SoC FPGA
嵌入式硬件·fpga开发·硬件工程·fpga
崇子嵘2 天前
Hdlbits
fpga开发