[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
相关推荐
Joshua-a1 小时前
FPGA基于计数器的分频器时序违例的解决方法
嵌入式硬件·fpga开发·fpga
尤老师FPGA2 小时前
LVDS系列38:Xilinx 7系 AD9253 LVDS接口设计仿真(五)
fpga开发
史蒂芬_丁2 小时前
PG分频_CLB
fpga开发
北方孤寂的灵魂4 小时前
systemverilog中随机std::randomize的用法
verilog·systemverilog·sv·数字验证
博览鸿蒙5 小时前
嵌入式是否如传说中那么简单?
fpga开发
Aaron15885 小时前
全频段SDR干扰源模块设计
人工智能·嵌入式硬件·算法·fpga开发·硬件架构·信息与通信·基带工程
洋洋Young19 小时前
【Xilinx FPGA】DDR3 SDRAM 控制器
fpga开发·xilinx
碎碎思20 小时前
在 FPGA 里跑 SDR 和 FT8:一个 32 MHz 全频谱无线电的硬核实现
fpga开发
EVERSPIN1 天前
USB3.0接口转换高性能图像传感和数据采集方案
fpga开发·usb3.0·接口转换·usb3.0接口转换
Macbethad1 天前
串口服务器技术报告:从RS232/485到MODBUS TCP的工业通信演进
fpga开发