[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
相关推荐
XINVRY-FPGA7 小时前
XC95288XL-10TQG144I Xilinx AMD CPLD
arm开发·单片机·嵌入式硬件·mcu·fpga开发·硬件工程·fpga
i道i9 小时前
Verilog 利用伪随机,时序,按键消抖等,实现一个(打地鼠)游戏
游戏·fpga开发·verilog
奋斗的牛马11 小时前
OFDM理解
网络·数据库·单片机·嵌入式硬件·fpga开发·信息与通信
ThreeYear_s15 小时前
【FPGA+DSP系列】——PWM电平光耦转换电路实验分析----电路原理分析,器件选型
单片机·嵌入式硬件·fpga开发
FPGA_小田老师1 天前
FPGA语法基础(一):Verilog 数组清零方法详解
fpga开发·verilog语法·数组清零·verilog数组清零
奋斗的牛马1 天前
FPGA--zynq学习 PS与PL交互(二) HP接口
单片机·嵌入式硬件·学习·fpga开发·信息与通信
ThreeYear_s2 天前
【FPGA+DSP系列】——CCS联合proteus仿真DSP工程,以TMS320f28027芯片为例,LED闪烁仿真。
单片机·fpga开发·proteus
LCMICRO-133108477462 天前
长芯微LPS5820完全P2P替代NCP51820,LPS5820 是一款高速半桥驱动器,可用来驱动半 桥功率拓扑的 GaN 功率管。
stm32·单片机·嵌入式硬件·fpga开发·硬件工程
云雾J视界2 天前
预测电流控制在光伏逆变器中的低延迟实现:华为FPGA加速方案与并网稳定性验证
华为·fpga开发·dsp·光伏逆变器·mpcc
国科安芯2 天前
核电厂执行器控制系统中的抗辐照MCU选型:为什么需要150krad(Si) TID指标?
服务器·单片机·嵌入式硬件·fpga开发·架构