[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
相关推荐
雨洛lhw1 小时前
STFT性能测试记录笔记(verilog )
fpga开发
runningshark4 小时前
【FPGA】频率计(等精度测量法)
fpga开发
坏孩子的诺亚方舟4 小时前
FPGA设计基于团队的最佳实践0
fpga开发·团队设计
FPGA_小田老师5 小时前
FPGA例程(7):UART串口接收程序--状态机的编写
fpga开发·uart·状态机·串口接收·uart_rx·串口程序·115200bps
FPGA小c鸡6 小时前
FPGA做AI:从入门到实战 | 边缘智能时代的硬件加速秘密
人工智能·fpga开发
思尔芯S2C7 小时前
思尔芯、MachineWare与Andes晶心科技联合推出RISC-V协同仿真方案,加速芯片开发
人工智能·科技·fpga开发·risc-v·prototyping
松涛和鸣9 小时前
63、IMX6ULL ADC驱动开发
c语言·arm开发·驱动开发·单片机·gpt·fpga开发
扣脑壳的FPGAer11 小时前
Xilinx Dual Quad Flash SPI加载方式下的文件处理
fpga开发
ShiMetaPi13 小时前
GM-3568JHF丨ARM+FPGA异构开发板应用开发教程:07 FPGA FSPI 通信案例
arm开发·fpga开发·rk3568
hoiii1871 天前
16APSK/32APSK调制解调MATLAB仿真实现
开发语言·matlab·fpga开发