使用非静态信号名称的循环中过程调用 [英] Procedure call in loop with non-static signal name

查看:15
本文介绍了使用非静态信号名称的循环中过程调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一些测试台代码中,我使用一个过程来处理信号。然后,我在不同的信号上按顺序多次使用这个过程。只要我显式定义信号,这就可以很好地工作;只要我索引循环中的信号,它就会失败

(vcom-1450)形式"%s"的实际(索引名称)不是静态信号名称。

为什么这是不可能的,我如何解决它? 或许我可以将其移至for ... generate,但随后我希望do_something以定义良好的顺序被调用。

library ieee;
use ieee.std_logic_1164.all;

entity test is
end test;

architecture tb of test is
    signal foo : std_logic_vector(1 downto 0);
begin
    dummy: process is
        procedure do_something (
            signal s : out std_logic
        ) is begin
            s <= '1';
            report "tic";
            wait for 1 ns;
            -- actually we would do something more interesting here
            s <= '0';
            report "toc";
        end procedure;
    begin
        -- This works well, but requires manual loop-unrolling
        do_something(foo(0));
        do_something(foo(1));

        -- This should do the same 
        for i in foo'range loop
            -- This is the offending line:
            do_something(foo(i));
        end loop;
        wait; -- for ever
    end process dummy;
end architecture tb;

我正在使用ModelSim 10.4 PE。

推荐答案

有趣的是,如果foo是进程的局部变量(并且s被调整以适合),则ghdl编译该变量。这突出了原始版本中的问题。所有时间都需要"for"循环来驱动整个foo,因为您不能让信号驱动器随意出现或消失-它不能对它正在驱动哪些位感到矛盾(正如您所看到的,该过程试图在不同的时间驱动不同的位)。

因此,如果您可以重新调整您的应用程序以允许变量更新语义,并使foo成为流程的局部变量,这将会起作用。(如果您想要查看效果,则必须在每次"等待"之前将其值复制到信号中!)

或者,将整个foo信号和索引传递给子程序,以便后者始终按如下方式驱动所有... (我还添加了缺少的部分,并修复了虚假的并发"等待":以后,请在发帖之前检查您的代码示例是否实际编译!)

library ieee;
use ieee.std_logic_1164.all;

entity test is
end test;

architecture tb of test is
    signal foo : std_logic_vector(1 downto 0);
begin
    dummy: process is
        procedure do_something (
            signal s : out std_logic_vector(1 downto 0); 
            constant i : in natural
        ) is begin
            s <= (others => '0');
            s(i) <= '1';
            report "tic";
            wait for 1 ns;
            -- actually we would do something more interesting here
            s(i) <= '0';
            report "toc";
        end procedure;

    begin
        -- This works well, but requires manual loop-unrolling
        do_something(foo,0);
        do_something(foo,1);

        -- This should do the same 
        for i in foo'range loop
            -- This is the offending line:
            do_something(foo,i);
        end loop;
        wait; -- for ever
    end process dummy;

end architecture tb;

这篇关于使用非静态信号名称的循环中过程调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆