CONFIGURATION 测试平台名 OF 被测实体名 IS
FOR 被测实体的A的结构体名
END FOR;
END 测试平台名;
同样,若选用结构体B,则配置语句可写为:
CONFIGURATION 测试平台名 OF 被测实体名 IS
FOR 被测实体的B的结构体名
END FOR;
END 测试平台名;
MainStimulus: process begin
Reset <= ’1’;
Load <= ’0’;
Count_UpDn <= ’0’;
wait for 100 ns;
Reset <= ’0’;
wait for 20 ns;
Load <= ’1’;
wait for 20 ns;
Count_UpDn <= ’1’;
end process;
相对时间仿真:
Process (Clock)
Begin
If rising_edge(Clock) then
TB_Count <= TB_Count + 1;
end if;
end process;
SecondStimulus: process begin
if (TB_Count <= 5) then
Reset <= ’1’;
Load <= ’0’;
Count_UpDn <= ’0’;
Else
Reset <= ’0’;
Load <= ‘1’;
Count_UpDn <= ‘1’;
end process;
FinalStimulus: process begin
if (Count = "1100") then
Count_UpDn <= '0';
report "Terminal Count
Reached, now counting down."
end if;
end process;
(3)显示结果
VHDL提供标准的std_textio函数包把输入输出结果显示在终端上。
5 简单的仿真程序
library IEEE;
use IEEE.std_logic_1164.all;
entity testbench is
end entity testbench;
architecture test_reg of testbench
component shift_reg is
port (clock : in std_logic;
reset : in std_logic;
load : in std_logic;
sel : in std_logic_vector(1 downto 0);
data : in std_logic_vector(4 downto 0);
shiftreg : out std_logic_vector(4 downto 0));
end component;
signal clock, reset, load: std_logic;
signal shiftreg, data: std_logic_vector(4 downto 0);
signal sel: std_logic_vector(1 downto 0);
constant ClockPeriod : TIME := 50 ns;
begin
UUT : shift_reg port map (clock => clock, reset => reset,
load => load, data => data,
shiftreg => shiftreg);
process begin
clock <= not clock after (ClockPeriod / 2);
end process;
process begin
reset <= ’1’;
data <= "00000";
load <= ’0’;
set <= "00";
wait for 200 ns;
reset <= ’0’;
load <= ’1’;
wait for 200 ns;
data <= "00001";
wait for 100 ns;
sel <= "01";
load <= ’0’;
wait for 200 ns;
sel <= "10";
wait for 1000 ns;
end process;
end architecture test_reg;
LIBRARY IEEE;
USE IEEE.std_logic_1164.all;
LIBRARY ieee;
USE IEEE.STD_LOGIC_TEXTIO.ALL;
USE STD.TEXTIO.ALL;
ENTITY testbench IS
END testbench;
ARCHITECTURE testbench_arch OF testbench IS
COMPONENT stopwatch