[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
相关推荐
Saniffer_SH5 小时前
【每日一题】一台可编程的PCIe 6.0主机 + 一套自动化CTS验证平台 + 一个轻量级链路分析系统
运维·服务器·测试工具·fpga开发·自动化·计算机外设·硬件架构
952369 小时前
计算机组成原理 - 主存储器
单片机·嵌入式硬件·学习·fpga开发
简简单单做算法10 小时前
【第2章>第1节】基于FPGA的图像放大和插值处理概述
计算机视觉·fpga开发·双线性插值·线性插值·图像放大·均值插值·最邻近插值
木心术111 小时前
OpenClaw FPGA资源利用率优化深度指南
人工智能·fpga开发
发光的沙子11 小时前
FPGA----zynq 7000与zynqMP内存区域保留方法
fpga开发
minglie112 小时前
c和hdl对偶关系
fpga开发
verse_armour14 小时前
【FPGA】在PYNQ开发板上搭建卷积神经网络实现交通标志识别
fpga开发
Aaron15881 天前
RFSOC+VU13P/VU9P+GPU通用一体化硬件平台
人工智能·算法·fpga开发·硬件架构·硬件工程·信息与通信·基带工程
XINVRY-FPGA1 天前
XC7VX485T-2FFG1157I Xilinx Virtex-7 FPGA
arm开发·嵌入式硬件·fpga开发·硬件工程·fpga
鄙人菜鸡2 天前
Xilinx IP Aurora 8B/10B 多级光纤串联复位时序
fpga开发