[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
相关推荐
乌恩大侠8 小时前
【AI-RAN 调研】软银株式会社通过全新 Transformer AI 将 5G AI-RAN 吞吐量提升 30%
人工智能·深度学习·5g·fpga开发·transformer·usrp·mimo
Terasic友晶科技1 天前
DE25-Nano开发板在Programmer的 Auto Detect 下检测出来的器件和友晶官方提供的工程里器件不一样有没有关系?
fpga开发·auto detect·de25-nano·jtag id
ShiMetaPi1 天前
GM-3568JHF丨ARM+FPGA异构开发板应用开发教程:04 MIPI屏幕检测案例
arm开发·fpga开发·rk3568
最遥远的瞬间1 天前
四、呼吸灯实战
fpga开发
FPGA小c鸡1 天前
FPGA高速收发器GTH完全指南:从零基础到10Gbps高速设计实战
fpga开发
乌恩大侠1 天前
【AI-RAN 调研】软银株式会社的 “AITRAS” 基于 Arm 架构的 NVIDIA 平台 实现 集中式与分布式 AI-RAN 架构
人工智能·分布式·fpga开发·架构·usrp·mimo
Saniffer_SH2 天前
【高清视频】笔记本电脑出现蓝屏、死机、慢、不稳定是这样连接分析M.2 SSD的
运维·服务器·网络·人工智能·驱动开发·嵌入式硬件·fpga开发
Z22ZHaoGGGG2 天前
Verilog实现对采样信号有效值(RMS)的计算
fpga开发
简简单单做算法2 天前
基于FPGA的图像形态学腐蚀处理Verilog开发与开发板硬件测试
fpga开发·腐蚀·形态学处理·硬件调试
hong_fpgaer2 天前
XILINX ZYNQ FPGA PS端DMA握手流程
fpga开发·vivado