[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
相关推荐
风_峰2 小时前
PuTTY软件访问ZYNQ板卡的Linux系统
linux·服务器·嵌入式硬件·fpga开发
电子凉冰14 小时前
FPGA入门-状态机
fpga开发
Aczone2815 小时前
硬件(十)IMX6ULL 中断与时钟配置
arm开发·单片机·嵌入式硬件·fpga开发
晓晓暮雨潇潇19 小时前
Serdes专题(1)Serdes综述
fpga开发·serdes·diamond·latticeecp3
XINVRY-FPGA19 小时前
XCKU15P-2FFVA1760I AMD 赛灵思 Xilinx Kintex UltraScale+ FPGA
arm开发·嵌入式硬件·阿里云·fpga开发·云计算·硬件工程·fpga
嵌入式-老费1 天前
Zynq开发实践(FPGA之第一个vivado工程)
fpga开发
贝塔实验室1 天前
两种常用的抗单粒子翻转动态刷新方法
论文阅读·经验分享·笔记·科技·学习·程序人生·fpga开发
minglie12 天前
zynq arm全局计时器和私有定时器
fpga开发
章咸鱼121382 天前
nios simple soket tcp在面对arp洪流时崩溃的处理
fpga开发·tcp
望获linux2 天前
望获实时Linux:亚微秒级时间控制
linux·运维·服务器·计算机·fpga开发·嵌入式软件·飞腾