整数类型的测试台文件
Test bench file for integer types
我正在尝试在 XIlinx ISE 14.7 中模拟以下 VHDL 模块,但生成的 VHDL 测试台文件假定所有输入和输出端口都是 std_logic 和 std_logic_vector 类型。
package newtype is
type row_t is array(0 to 2) of integer;
end newtype;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use work.newtype.all;
entity mymodule is
port (indata : in row_t;
sum : out integer);
end mymodule;
architecture Behavioral of mymodule is
begin
process (indata)
begin
sum <= indata(0) + indata(1) + indata(2);
end process;
end Behavioral;
我修改了生成的代码,用我的类型替换了 std_logic_vector,但这次它给我语法错误。
您能告诉我在使用整数类型时编写文本工作台文件的正确方法是什么吗?
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
use work.newtype.all;
ENTITY mymodule_test IS
END mymodule_test;
ARCHITECTURE behavior OF mymodule_test IS
-- Component Declaration for the Unit Under Test (UUT)
COMPONENT mymodule
PORT(
indata : IN row_t;
sum : OUT integer
);
END COMPONENT;
--Inputs
signal indata : row_t := (0,0,0);
--Outputs
signal sum : integer;
-- No clocks detected in port list. Replace <clock> below with
-- appropriate port name
constant <clock>_period : time := 10 ns;
BEGIN
-- Instantiate the Unit Under Test (UUT)
uut: mymodule PORT MAP (
indata => indata,
sum => sum
);
-- Clock process definitions
<clock>_process :process
begin
<clock> <= '0';
wait for <clock>_period/2;
<clock> <= '1';
wait for <clock>_period/2;
end process;
-- Stimulus process
stim_proc: process
begin
-- hold reset state for 100 ns.
wait for 100 ns;
wait for <clock>_period*10;
-- insert stimulus here
wait;
end process;
END;
您还没有发布遇到的语法错误。但是,如果我在 Xilix ISE 14.7 中创建一个新项目并添加上面的代码,我会得到这些语法错误:
ERROR:HDLCompiler:806 -
"mymodule_test.vhdl"
Line 28: Syntax error near "<". ERROR:HDLCompiler:806 -
"mymodule_test.vhdl"
Line 39: Syntax error near "<". ERROR:HDLCompiler:806 -
"mymodule_test.vhdl"
Line 41: Syntax error near "<". ERROR:HDLCompiler:806 -
"mymodule_test.vhdl"
Line 54: Syntax error near "<".
所有这些行都包含标识符或前缀<clock>
,这是赛灵思测试平台生成器的模板参数。如果这样,生成器会在您在向导中选择的设计中检测到时钟(此处为 mymodule
),然后 <clock>
将替换为时钟信号的实际名称。测试台生成器没有在您的设计中找到时钟信号,所以它只是插入了普通模板代码。这些语法错误与测试台中 integer
类型的使用无关。
您的设计不依赖于时钟信号,因此您可以安全地删除所有与时钟信号关联的测试平台代码:
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
use work.newtype.all;
ENTITY mymodule_test IS
END mymodule_test;
ARCHITECTURE behavior OF mymodule_test IS
-- Component Declaration for the Unit Under Test (UUT)
COMPONENT mymodule
PORT(
indata : IN row_t;
sum : OUT integer
);
END COMPONENT;
--Inputs
signal indata : row_t := (0,0,0);
--Outputs
signal sum : integer;
BEGIN
-- Instantiate the Unit Under Test (UUT)
uut: mymodule PORT MAP (
indata => indata,
sum => sum
);
-- Stimulus process
stim_proc: process
begin
-- hold reset state for 100 ns.
wait for 100 ns;
-- insert stimulus here
wait;
end process;
END;
我正在尝试在 XIlinx ISE 14.7 中模拟以下 VHDL 模块,但生成的 VHDL 测试台文件假定所有输入和输出端口都是 std_logic 和 std_logic_vector 类型。
package newtype is
type row_t is array(0 to 2) of integer;
end newtype;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use work.newtype.all;
entity mymodule is
port (indata : in row_t;
sum : out integer);
end mymodule;
architecture Behavioral of mymodule is
begin
process (indata)
begin
sum <= indata(0) + indata(1) + indata(2);
end process;
end Behavioral;
我修改了生成的代码,用我的类型替换了 std_logic_vector,但这次它给我语法错误。 您能告诉我在使用整数类型时编写文本工作台文件的正确方法是什么吗?
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
use work.newtype.all;
ENTITY mymodule_test IS
END mymodule_test;
ARCHITECTURE behavior OF mymodule_test IS
-- Component Declaration for the Unit Under Test (UUT)
COMPONENT mymodule
PORT(
indata : IN row_t;
sum : OUT integer
);
END COMPONENT;
--Inputs
signal indata : row_t := (0,0,0);
--Outputs
signal sum : integer;
-- No clocks detected in port list. Replace <clock> below with
-- appropriate port name
constant <clock>_period : time := 10 ns;
BEGIN
-- Instantiate the Unit Under Test (UUT)
uut: mymodule PORT MAP (
indata => indata,
sum => sum
);
-- Clock process definitions
<clock>_process :process
begin
<clock> <= '0';
wait for <clock>_period/2;
<clock> <= '1';
wait for <clock>_period/2;
end process;
-- Stimulus process
stim_proc: process
begin
-- hold reset state for 100 ns.
wait for 100 ns;
wait for <clock>_period*10;
-- insert stimulus here
wait;
end process;
END;
您还没有发布遇到的语法错误。但是,如果我在 Xilix ISE 14.7 中创建一个新项目并添加上面的代码,我会得到这些语法错误:
ERROR:HDLCompiler:806 - "mymodule_test.vhdl" Line 28: Syntax error near "<". ERROR:HDLCompiler:806 - "mymodule_test.vhdl" Line 39: Syntax error near "<". ERROR:HDLCompiler:806 - "mymodule_test.vhdl" Line 41: Syntax error near "<". ERROR:HDLCompiler:806 - "mymodule_test.vhdl" Line 54: Syntax error near "<".
所有这些行都包含标识符或前缀<clock>
,这是赛灵思测试平台生成器的模板参数。如果这样,生成器会在您在向导中选择的设计中检测到时钟(此处为 mymodule
),然后 <clock>
将替换为时钟信号的实际名称。测试台生成器没有在您的设计中找到时钟信号,所以它只是插入了普通模板代码。这些语法错误与测试台中 integer
类型的使用无关。
您的设计不依赖于时钟信号,因此您可以安全地删除所有与时钟信号关联的测试平台代码:
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
use work.newtype.all;
ENTITY mymodule_test IS
END mymodule_test;
ARCHITECTURE behavior OF mymodule_test IS
-- Component Declaration for the Unit Under Test (UUT)
COMPONENT mymodule
PORT(
indata : IN row_t;
sum : OUT integer
);
END COMPONENT;
--Inputs
signal indata : row_t := (0,0,0);
--Outputs
signal sum : integer;
BEGIN
-- Instantiate the Unit Under Test (UUT)
uut: mymodule PORT MAP (
indata => indata,
sum => sum
);
-- Stimulus process
stim_proc: process
begin
-- hold reset state for 100 ns.
wait for 100 ns;
-- insert stimulus here
wait;
end process;
END;