You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

VHDL中检测rd信号下降沿延迟15ns后存储数据的实现方法

VHDL实现方案

VHDL中wait for属于仿真专用语法,无法用于实际硬件综合,因此分两种场景给出实现方案:

1. 仅用于仿真验证的实现

直接使用VHDL信号赋值的after延迟语义即可完成需求,修改后的完整代码如下:

library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;

entity ent1 is
    port
    (
        -- 输入端口
        rd              : in std_logic;
        db_input        : in std_logic_vector (7 downto 0);

        -- 输出端口
        db_output   : out std_logic_vector (7 downto 0) := (others => '0')
    );
end ent1;

architecture arch1 of ent1 is
begin

    process(rd)
    begin
        if (falling_edge(rd)) then
            -- transport为传输延迟模型,可严格匹配15ns延迟要求,不需要可省略
            db_output <= transport db_input after 15 ns;
        end if;
    end process;
    
end arch1;

2. 可用于实际硬件(FPGA/ASIC)的可综合实现

实际硬件没有绝对的15ns延迟单元,需要依托工作时钟计数实现近似的固定延迟,以下以100MHz工作时钟(周期10ns,2个周期即可实现接近15ns的20ns延迟)为例给出实现:
首先需要在端口列表中补充工作时钟输入clk : in std_logic,随后修改架构逻辑如下:

architecture arch1 of ent1 is
    -- 打拍寄存器用于检测rd下降沿
    signal rd_dly : std_logic_vector(1 downto 0) := "00";
    -- 延迟计数器
    signal delay_cnt : integer range 0 to 2 := 0;
begin
    process(clk)
    begin
        if rising_edge(clk) then
            -- 寄存器打拍
            rd_dly <= rd_dly(0) & rd;
            -- 检测到rd下降沿启动计数
            if rd_dly = "10" then
                delay_cnt <= 1;
            elsif delay_cnt /= 0 then
                delay_cnt <= delay_cnt + 1;
                -- 计数到设定值后更新输出
                if delay_cnt = 2 then
                    delay_cnt <= 0;
                    db_output <= db_input;
                end if;
            end if;
        end if;
    end process;
end arch1;

你可以根据实际使用的时钟频率调整计数上限,得到更接近15ns的延迟效果。

内容的提问来源于stack exchange,提问作者Alejandro Fernández Suárez

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.25 22:54:08