[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
相关推荐
FPGA小迷弟4 小时前
ModelSim操作教程 详细操作手册【一】
fpga开发·fpga·modelsim·fpga仿真·rtl仿真
minglie17 小时前
cocotb 配合 iverilog 搭建 Verilog 仿真工程
fpga开发
minglie17 小时前
常用Verilog模板
fpga开发
weixin_437497777 小时前
学习笔记:用于EDA的LLMs专题会议论文
人工智能·笔记·搜索引擎·fpga开发
浩子智控2 天前
电子设备DevOps
fpga开发
cycf3 天前
CRC校验
fpga开发
landyjzlai3 天前
AMBA总线(15)关于AXI-stream(sg模式)
arm开发·fpga开发·amba
白狐_7983 天前
Quartus Prime 新手完全使用指南
fpga开发
Aaron15883 天前
三种主流接收机架构(超外差、零中频、射频直采)对比及发展趋势浅析
c语言·人工智能·算法·fpga开发·架构·硬件架构·信号处理
博览鸿蒙3 天前
一颗数字系统是如何在 FPGA 上“跑起来”的?
fpga开发