[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
相关推荐
brave and determined2 小时前
可编程逻辑器件学习(day34):半导体编年史:从法拉第的意外发现到塑造现代文明的硅基浪潮
人工智能·深度学习·fpga开发·verilog·fpga·设计规范·嵌入式设计
FPGA_Linuxer3 小时前
RFSOC PCIE 4.0读写测试
fpga开发
坏孩子的诺亚方舟4 小时前
FPGA系统架构设计实践8_复位参考设计
fpga开发·系统架构·复位
li星野4 小时前
打工人日报#20251124
fpga开发
云雾J视界16 小时前
FPGA+RISC-V架构解析:构建高效传感器数据采集系统
fpga开发·架构·uart·risc-v·i2c·adxl345
步达硬件17 小时前
【FPGA】Intel/AMD FPGA型号参数对比,供选型参考
fpga开发
国科安芯18 小时前
Buck 电路调试避坑手册:国产电源芯片纹波超标、斩波不稳定解决方案
网络·单片机·嵌入式硬件·fpga开发·性能优化
stay_cloud19 小时前
《Verilog语言与FPGA实现》课程实验
verilog·fpga·数码管
贝塔实验室1 天前
Altium Designer 6.0 初学教程-如何生成一个集成库并且实现对库的管理
linux·服务器·前端·fpga开发·硬件架构·基带工程·pcb工艺
IC_Brother1 天前
数字IC经典电路(6)—Ring Oscillator(环形振荡器)与工艺角监控
verilog·数字ic·dc综合