[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
相关推荐
jumu2021 小时前
CEEMDAN - SE:神奇的信号处理组合
fpga开发
坏孩子的诺亚方舟2 小时前
FPGA系统架构设计实践6_工程实现概述
fpga开发·xilinx·实现
坏孩子的诺亚方舟2 小时前
FPGA系统架构设计实践10_时钟网络
fpga·xilinx·时钟网络
FPGA小c鸡2 小时前
Verilog核心语法速查:可综合写法、运算符陷阱与SV增强(附模板)
fpga开发
步达硬件3 小时前
【FPGA】Verilog HDL编辑、RTL仿真、网表生成主流软件
fpga开发
太爱学习了12 小时前
XILINX SRIOIP核详解、FPGA实现及仿真全流程(Serial RapidIO Gen2 Endpoint v4.1)
fpga开发·srio·dsp
HIZYUAN21 小时前
嵌入式开发踩坑记: AG32硬件设计指南(一)
stm32·单片机·嵌入式硬件·fpga开发·硬件设计·最小系统·agm ag32
上海全爱科技1 天前
全爱科技推出 摩尔线程E300+FPGA开发板HOUYI-1000V
科技·fpga开发
扣脑壳的FPGAer1 天前
Xilinx远程更新之axi-quad-spi IP core
fpga开发
Troke1 天前
串行数据与并行数据转换(1)
fpga开发