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

Verilog $setup时序检查的原生VHDL等效实现方法

结论

完全可以在不使用VHDL-Verilog混合仿真的前提下,通过VHDL原生语法实现与Verilog $setup 建立时间检查完全一致的功能,不需要依赖任何非标准库或仿真器扩展。

实现原理

Verilog $setup(data_event, posedge ref_event, tSU, notifier) 的核心逻辑是:

  • 检测ref_event上升沿到来前的tSU时间窗口内,data_event是否发生任何跳变
  • 若窗口内出现跳变,则报建立时间违例,同时翻转notifier信号供其他仿真逻辑触发后续行为(如输出不定态)
  • 该检查仅用于仿真验证,不会被综合工具映射为实际电路

VHDL原生提供的信号属性'last_event可以直接获取信号距离上一次跳变的时间间隔,配合标准仿真流程即可实现完全一致的检查逻辑,所有兼容IEEE 1076标准的VHDL仿真器(GHDL、ModelSim/Questa、VCS、Xcelium等)均支持该属性。

补全后的完整VHDL代码
library ieee;
use ieee.std_logic_1164.all;

entity sim_check_setup_posedge is
   port(
       data_event :in std_logic;
       ref_event  :in std_logic
    );
end entity;

architecture beh of sim_check_setup_posedge is
    -- 建立时间参数,和Verilog specparam tSU=1ns完全对应
    constant tSU : time := 1 ns;
    -- 违例通知信号,和Verilog中的notifier寄存器行为一致
    signal notifier : std_logic := '0';
begin

setup_check : process(ref_event)
begin
    if rising_edge(ref_event) then
        -- 检查ref上升沿前tSU窗口内data是否发生跳变
        if data_event'last_event < tSU then
            -- 输出违例报错,和仿真器内置$setup报错行为对齐
            report "Setup violation: data_event toggled within " & time'image(tSU) & " before posedge of ref_event"
            severity error;
            -- 翻转通知信号
            notifier <= not notifier;
        end if;
    end if;
end process;

end architecture beh;
行为一致性说明
  • 时间精度完全跟随VHDL仿真器设置,和原Verilog指定1ns/10ps精度的仿真行为无差异
  • 无论data_event跳变到0、1、X、Z任意电平,只要在建立时间窗口内发生跳变都会触发违例,和Verilog $setup 检测逻辑一致
  • notifier信号在违例时翻转的行为和Verilog完全对齐,可直接接入其他仿真逻辑做不定态传播等处理
  • 检查逻辑仅在仿真时生效,综合工具会自动忽略该进程,和Verilog specify块的综合行为完全一致

内容的提问来源于stack exchange,提问作者Bimo

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.29 20:16:04