[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
相关推荐
雨洛lhw15 小时前
24bit AD采样高效数据打包方案解析
fpga开发·数据打包方式·ddr突发读写注意事项
XiaoChaoZhiNeng18 小时前
Xilinx Vivado18.3 Modelsim 库编译与仿真
fpga开发
Flamingˢ21 小时前
FPGA 显示系统学习路线:从 VGA 到 RGB TFT
学习·fpga开发
tiantianuser1 天前
RDMA设计37:RoCE v2 子系统模型设计
fpga开发·rdma·高速传输·cmac·roce v2
8K超高清1 天前
博冠8K广播级讯道摄像机获国际设计大奖
网络·算法·fpga开发·接口隔离原则·智能硬件
ooo-p1 天前
FPGA学习篇——Verilog学习之“呼吸灯”
学习·fpga开发
雨洛lhw2 天前
STFT性能测试记录笔记(verilog )
fpga开发
runningshark2 天前
【FPGA】频率计(等精度测量法)
fpga开发
坏孩子的诺亚方舟2 天前
FPGA设计基于团队的最佳实践0
fpga开发·团队设计
FPGA_小田老师2 天前
FPGA例程(7):UART串口接收程序--状态机的编写
fpga开发·uart·状态机·串口接收·uart_rx·串口程序·115200bps