[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
相关推荐
扮作大侠27 分钟前
vitis板级支持包的.c文件位置
fpga开发
FPGA_小田老师36 分钟前
FPGA例程(2):LED流水灯--vivado FPGA程序固化下载
fpga开发·fpga程序固化·flash烧写·mcs文件生成
Hqst_xiangxuajun37 分钟前
万兆SFP光纤笼子交换机和PCIE网卡主板上起到什么作用
网络·fpga开发·oracle·sqlite·json·信息与通信
雨洛lhw37 分钟前
vivado码流压缩
fpga开发·码流压缩
minglie139 分钟前
Tang-Nano-1K移植vio_uart
fpga开发
国科安芯41 分钟前
商业卫星载荷FPGA转RISC-V架构MCU方案经济性评估
单片机·嵌入式硬件·fpga开发·架构·安全威胁分析·risc-v
ehiway10 小时前
中科亿海微牵头构建国产化FPGA/EDA生态 以协同创新破解“卡脖子”难题
fpga开发
华舞灵瞳10 小时前
学习FPGA(六)锁相环
学习·fpga开发
FPGA小迷弟12 小时前
Modelsim仿真软件的,安装/破解/使用教程大全
fpga开发·fpga·modelsim·fpga仿真·rtl仿真
DTI070113 小时前
xilinx的vivado工具综合一直转圈圈,卡死后如何解决?
嵌入式硬件·fpga开发