[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
相关推荐
FPGA小迷弟2 小时前
高频时钟设计:FPGA 多时钟域同步与时序收敛实战方案
前端·学习·fpga开发·verilog·fpga
szxinmai主板定制专家3 小时前
基于ZYNQ MPSOC船舶数据采集仪器设计(三)振动,流量,功耗,EMC,可靠性测试
arm开发·人工智能·嵌入式硬件·fpga开发
hoiii1877 小时前
Vivado下Verilog交通灯控制器设计
fpga开发
嵌入式-老费8 小时前
vivado hls的应用(开篇)
fpga开发
ARM+FPGA+AI工业主板定制专家10 小时前
基于ARM+FPGA+AI的船舶状态智能监测系统(一)总体设计
网络·arm开发·人工智能·机器学习·fpga开发·自动驾驶
Eidolon_li10 小时前
ARINC429模块规格书(V1.1)
fpga开发
FPGA-ADDA1 天前
第四篇:嵌入式系统常用通信接口详解(I2C、SPI、UART、RS232/485、CAN、USB)
人工智能·单片机·嵌入式硬件·fpga开发·信息与通信
FPGA-ADDA1 天前
第三篇:Xilinx Zynq SoC系列——从Zynq-7000到RFSoC
5g·信号处理·fpga·通信系统·rfsoc
421!1 天前
ESP32学习笔记之GPIO
开发语言·笔记·单片机·嵌入式硬件·学习·算法·fpga开发
dMing`1 天前
基于FPGA的简易数据采集系统
fpga开发·fpga·adc·dac