[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
相关推荐
tiantianuser1 分钟前
NVMe高速传输之摆脱XDMA设计52: 上板资源占用率分析
fpga开发·nvme·pcie·xdma·高性能nvme
我爱C编程1 小时前
【仿真测试】基于FPGA的完整DQPSK通信链路实现,含频偏锁定,帧同步,定时点,Viterbi译码,信道,误码统计
fpga开发·帧同步·viterbi译码·dqpsk·频偏锁定·定时点
nnerddboy2 小时前
FPGA自学笔记(正点原子ZYNQ7020):2.IP核与组成
fpga开发
碰大点4 小时前
第8章 zynq uboot更新系统镜像并引导启动和个人心得
驱动开发·fpga开发·uboot·zynq
szxinmai主板定制专家4 小时前
基于ARM+FPGA的无人机数据采集卡,6通道24bit采集
arm开发·嵌入式硬件·fpga开发·无人机·能源
贝塔实验室6 小时前
QPSK信号载波同步技术---四相Costas 环法
数学建模·fpga开发·硬件工程·动态规划·信息与通信·信号处理·傅立叶分析
bnsarocket12 小时前
Verilog和FPGA的自学笔记2——点亮LED
笔记·fpga开发·verilog·自学
易享电子17 小时前
基于单片机智能台灯(调光,时钟)系统Proteus仿真(含全部资料)
单片机·嵌入式硬件·fpga开发·51单片机·proteus
电子凉冰19 小时前
FPGA强化-串口RS485
fpga开发
ShiMetaPi19 小时前
操作【GM3568JHF】FPGA+ARM异构开发板 使用指南:音频接口
arm开发·嵌入式硬件·fpga开发·rk3568