[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
相关推荐
知识充实人生5 小时前
Xilinx 7系列器件特性对比
fpga·xilinx·赛灵思·7系列·器件资源对比
最遥远的瞬间18 小时前
四、Xilinux在线调试方法和XADC的使用
fpga开发
tobias.b1 天前
408真题解析-2010-12-计组-程序执行时间
单片机·嵌入式硬件·fpga开发·计算机考研·408真题解析
洋洋Young1 天前
【Xilinx FPGA】7 Series 收发器架构与时钟设计
fpga开发·xilinx
unicrom_深圳市由你创科技1 天前
XDMA 技术及在 Windows 平台的应用实践
fpga开发
s09071362 天前
【Agent】Claude code辅助verilog编程
fpga开发
3有青年2 天前
altera fpga agilex 5 连接到HVIO BANK上的参考时钟,是否可以作为HSIO BANK内部IOPLL的输入时钟
fpga开发
FPGA_ADDA2 天前
基于ZU47DR 的高性能射频卡
fpga开发
ooo-p2 天前
FPGA学习篇——Verilog学习之“流水灯”
学习·fpga开发
坏孩子的诺亚方舟2 天前
FPGA系统架构设计实践14_OTA升级
fpga·加载