[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, in1 and out1 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
相关推荐
Szime7 小时前
AD9694 国产替代方案:四通道高速 ADC 在通信与雷达项目中的选型参考
单片机·嵌入式硬件·fpga开发
kaizq11 小时前
在线MakerChip虚拟FPGA设计动态仿真实践
fpga开发·mulerun·makerchip·virtualfpgalab·在线动态仿真·imacopilot
FPGA小徐11 小时前
OV5640 摄像头 DDR3 缓存 HDMI/VGA 显示系统详解与
fpga开发
Monkey of Semi12 小时前
ARTIX-7 FPGA 核心板学习之FPGA Xilinx 7 series 命名规则
fpga开发
ALINX技术博客12 小时前
【黑金云课堂】FPGA技术教程Vitis开发:TCP以太网通信
网络协议·tcp/ip·fpga开发
FPGA小徐14 小时前
FPGA 电赛信号叠加与分离项目 完整工程包
fpga开发
FPGA小徐15 小时前
FPGA在做信号处理相比cpu的优势对比
fpga开发
Szime15 小时前
AD9218国产替代方向:双通道10位105MSPS ADC深智微科技选型经验
fpga开发
江鸟的坚持15 小时前
xilinx xadc 例化
fpga开发·xadc·xilinx xadc
明德扬15 小时前
AD采集卡适配方案交流:模块、板卡与FPGA示例工程支持
fpga开发