[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
相关推荐
Saniffer_SH28 分钟前
【高清视频】如何针对电动汽车进行通信可靠性测试、故障注入与功率分析?
服务器·驱动开发·测试工具·fpga开发·计算机外设·硬件架构·压力测试
博览鸿蒙2 小时前
基于FPGA技术的数字存储示波器设计探讨
fpga开发
Saniffer_SH2 小时前
【高清视频】企业级NVMe SSD (E3.S, U.2)和消费类M.2 SSD拆解分析
服务器·网络·数据库·驱动开发·测试工具·fpga开发·压力测试
嵌入式-老费3 小时前
Linux camera驱动开发(ARM、FPGA、DDR共享总线)
图像处理·驱动开发·fpga开发
尤老师FPGA3 小时前
HDMI数据的接收发送实验(五)
fpga开发
范纹杉想快点毕业3 小时前
Zynq-7000 PS端开发深度技术指南:从硬件架构到实战应用
fpga开发·硬件架构
FPGA小迷弟4 小时前
FPGA工业常用接口:FPGA 的 SPI 总线多从机通信设计与时序优化
学习·fpga开发·verilog·fpga·modelsim
雨洛lhw13 小时前
基于 FPGA 的主机 IP 自动配置方案设计
udp·mac·ip·fpga·dhcp
Flamingˢ13 小时前
基于ARM的裸机程序设计和开发(一):Zynq SoC FPGA的诞生
arm开发·fpga开发