[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
相关推荐
hexiaoyan8274 小时前
信号处理卡 数据收发卡设计方案:428-基于XC7Z100+ADRV9009的双收双发无线电射频板卡 5G小基站 无线图传
fpga开发·无线图传·9009开发板·xc7z100板卡·视频数据收发卡
范纹杉想快点毕业4 小时前
AI助教初学者问答FPGA芯片基础概念100道问题,适用入门嵌入式软件初级工程师,筑牢基础,技术积累
fpga开发·架构
硅农深芯20 小时前
六大核心芯片:MCU/SOC/DSP/FPGA/NPU/GPU 的区别与应用解析
单片机·嵌入式硬件·fpga开发
9527华安20 小时前
FPGA纯verilog实现JESD204B协议,基于AD9081数据接收,提供2套工程源码和技术支持
fpga开发·jesd204b·ad9081
FPGA技术实战1 天前
基于XADC IP核的FPGA芯片温度读取设计
网络协议·tcp/ip·fpga开发
丸子的蓝口袋1 天前
FPGA DONE信号震荡
fpga开发
CinzWS1 天前
基于Cortex-M3 SoC的eFuse模块--实现与验证考量
fpga开发·架构·efuse
jumu2021 天前
CEEMDAN - SE:神奇的信号处理组合
fpga开发
坏孩子的诺亚方舟1 天前
FPGA系统架构设计实践6_工程实现概述
fpga开发·xilinx·实现
坏孩子的诺亚方舟1 天前
FPGA系统架构设计实践10_时钟网络
fpga·xilinx·时钟网络