0

我想描述一个可以正常运行或处于测试模式的实体。我的一般设计是一个顶级实体,它包装了“真实”实体和一个测试实体。

我试图找出用 VHDL 表达这一点的最佳方式,但我觉得我把事情复杂化了。

考虑一个小的顶级实体(实际上,还有更多的 I/O):

entity toplevelobject is
    port (
        in1 : inout std_logic;
        in2 : inout std_logic;
        out1 : out std_logic;
        out2 : out std_logic;
        testline : in std_logic;
        testclk : in std_logic;
    );

end toplevelobject;

这应该根据“测试线”的状态在实际功能和测试模式之间切换(高意味着测试)。请注意,测试模块实际上使用除了clk作为输出之外的所有内容,甚至in_*.

architecture test_passthrough of toplevelobject is
    -- This is the actual module
    component real_module
    port (
        in1 : in std_logic;
        in2 : in std_logic;
        out1 : out std_logic;
        out2 : out std_logic;
        clk : in std_logic;
        -- Note absence of "testline"
    );
    end component;

    -- This is the test module, which will just put the clk
    -- signal out on all pins, or play a tune, or something
    component test_module
    port (
        in1 : out std_logic;
        in2 : out std_logic;
        out1 : out std_logic;
        out2 : out std_logic;
        testclk : in std_logic;
        -- Note absence of "testline"
    );
    end component;

    signal real_in1, real_in2 : std_logic;
    signal real_out1, real_out2 : std_logic;

    signal test_in1, test_in2 : std_logic;
    signal test_out1, test_out2 : std_logic;

begin

    real_0 : real_module port map (
        in1 => real_in1,
        in2 => real_in2,
        out1 => real_out1,
        out2 => real_out2,
        clk => clk,
    );

    test_0 : test_module port map (
        in1 => test_in1,
        in2 => test_in2,
        out1 => test_out1,
        out2 => test_out2,
        testclk => clk,
    );

    -- Ports that are outputs on both don't need
    -- much special attention

    out1 <= real_out1 when testline = '0' else test_out1;
    out2 <= real_out2 when testline = '0' else test_out2;

end test_passthrough;

所以我有几个问题:

  • 对于inout端口,我应该有一个带有case ... when打开声明的大进程testline吗?还是每个 I/O 的进程都带有一个if语句?从理论上讲,我认为许多较小的过程是同时执行的,而不是顺序执行的,但它实际上会对模拟或综合产生影响吗?例如:

    passthrough_in1 : process(testline, in1, test_in1) is
    begin
        if testline = '0' then
            real_in1 <= in1;
        else
            in1 <= test_in1;
        end if;
    end process passthrough_in1;
    

……对……

    passthrough_all : process(in1, test_in1, in2, test_in2, testline) is

        case testline is
            when '0' =>
                real_in1 <= in1;
                real_in2 <= in2;
            when '1' =>
                in1 <= test_in1;
                in2 <= test_in2;
        end case;

    end process passthrough_all;
  • 这是一种理智的方法还是有更简单的方法?
  • 我对敏感性感到困惑——我是否需要passthrough_in1(甚至passthrough_all对除testline.
  • 我需要real_in1/test_in1在两个包装实体之间进行选择吗?还是有另一种说法“如果testline高,将test_module输出连接in_1toplevelobjectI/O in_1
4

2 回答 2

1

如果我对您的理解正确,您的 testmodule 会驱动 1,2 端口中的(名称不好 - 我假设在实际代码中它们更有意义 :)?

如果是这样,您需要执行以下操作:

real_in1 <= in1;
in1 <= test_in1 when testline = '1' else 'Z';

这样在非测试模式下,in1 信号将由“Z”驱动,因此外部适当的 in1 信号可以覆盖它。

您可以用各种其他方式表示这一点(如您描述的过程),所有这些在模拟器中都应该是平等的。“多合一”选项的缺点是,您需要将最终可能成为庞大的敏感列表的内容保持最新。每个信号执行一个过程只是我上面所做的一种冗长的方式。

为了节省一些代码和复制/粘贴工作,您可能会将这两行代码推送到它们自己的实体中,然后多次实例化它 - 在这种情况下,我会将实例和端口映射全部放在一行上,但这会冒犯一些编码标准......

这一切都假设我已经正确理解了这个问题!

于 2010-09-17T12:18:23.933 回答
0

也许我不完全理解您要做什么,但是在典型的 VHDL 测试平台中:

  • 您的“real_module”代码保持原样。测试时不会对其进行任何更改。
  • 第二个模块,类似于您的“顶级对象”。这通常称为测试平台模块。
  • 顶层对象测试台实例化了 real_module。
  • 测试台通常没有输入,也不需要输出(取决于情况和使用的测试软件)。
  • 测试台具有驱动 real_module 输入的时序逻辑。
  • 如果您使用的是 ModelSim 等测试软件,real_module 的输入和输出可以随时间绘制,以观察 real_module 在您的测试台驱动时的行为。

你用的是什么软件?如果对您有任何帮助,我可以从几年前的大学项目中挖掘出一个旧的测试平台示例。

于 2010-09-17T04:47:25.353 回答