[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
相关推荐
zlinear数据采集卡5 小时前
硅片里的“自动纠错“:硬核拆解LHAMP188自动归零技术原理与三种封装的PCB布局实战
arm开发·单片机·嵌入式硬件·fpga开发·开源
Mr-pn-junction17 小时前
clk_gate
单片机·嵌入式硬件·fpga开发
知行合一←_←1 天前
误码仪与时钟极性
fpga开发
upper20201 天前
vivado使用那些事之综合策略
fpga开发·vivado·vivado综合策略
2CM_Embed1 天前
Quartus II 工程编译与 FPGA 下载流程记录
嵌入式硬件·fpga开发
千寻xun1 天前
视频图像学习笔记
fpga开发
国科安芯2 天前
航天电子模拟前端三大支柱:精密运放、高速运放与电压监控的协同设计方法——ASL8522S/ASL622S/ASL706S技术解析
前端·单片机·嵌入式硬件·fpga开发·架构·安全性测试
謓泽2 天前
【6.26】芯片测试入门 从零搭自动化测试框架|PyVISA+OOP 保姆级教程
stm32·单片机·fpga开发·雷达·tr
乌恩大侠2 天前
【AI-RAN】面向电信行业的 NVIDIA DGX BasePOD
人工智能·fpga开发·o-ru
传感器与混合集成电路3 天前
伺服数据采集控制模块系统集成实战手册:接口设计要点、上电顺序与开发环境配置全解析
fpga开发