[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
相关推荐
0基础学习者1 天前
跨时钟域处理
fpga开发·verilog·数字ic
FPGA_小田老师1 天前
Xilinx FIFO Generate IP核(8):FIFO设计常见问题与解决方案
fpga开发·fifo generate·fifo常见问题·fifo异常定位·fifo丢数·fifo读数重复
范纹杉想快点毕业1 天前
100道关于STM32的问题解答共十万字回答,适用入门嵌入式软件初级工程师,筑牢基础,技术积累,校招面试。
驱动开发·单片机·嵌入式硬件·fpga开发·硬件工程
知识充实人生2 天前
时序收敛方法二:Fanout优化
fpga开发·fanout·高扇出·时序收敛
Js_cold2 天前
(* MARK_DEBUG=“true“ *)
开发语言·fpga开发·debug·verilog·vivado
Js_cold2 天前
(* clock_buffer_type=“NONE“ *)
开发语言·fpga开发·verilog·vivado·buffer·clock
深圳光特通信豆子2 天前
TTL光模块:短距离传输场景的优选方案
fpga开发
Js_cold2 天前
Verilog运算符
开发语言·fpga开发·verilog
Js_cold3 天前
Verilog函数function
开发语言·fpga开发·verilog
Js_cold4 天前
Verilog任务task
开发语言·fpga开发·verilog