我想描述一个可以正常运行或处于测试模式的实体。我的一般设计是一个顶级实体,它包装了“真实”实体和一个测试实体。
我试图找出用 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_1
到toplevelobject
I/Oin_1
?