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;
6 TEXTIO建立测试程序
在由仿真程序直接产生输入信号的方法中,测试矢量是仿真程序的一个部分,如果系统比较复杂,测试矢量的数目非常大,修改测试矢量时就必须修改程序,重新编译和仿真。工作量大。因此,在测试矢量非常大的时候可以用TEXTIO的方法来进行仿真。
TEXTIO仿真方法:测试矢量从仿真程序中分离出来,单独存于一个文件中(即TEXTIO文件),在仿真时,根据定时要求按行读出,并赋予相应的输入信号。这种方法允许采用同一个测试平台,通过不同的测试矢量文件进行不同的仿真。值得注意的是,测试矢量文件的读取,需要利用TEXTIO程序包的功能。在TEXTIO程序包中,包含有对文本文件进行读写的过程和函数。
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
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;
6 TEXTIO建立测试程序
在由仿真程序直接产生输入信号的方法中,测试矢量是仿真程序的一个部分,如果系统比较复杂,测试矢量的数目非常大,修改测试矢量时就必须修改程序,重新编译和仿真。工作量大。因此,在测试矢量非常大的时候可以用TEXTIO的方法来进行仿真。
TEXTIO仿真方法:测试矢量从仿真程序中分离出来,单独存于一个文件中(即TEXTIO文件),在仿真时,根据定时要求按行读出,并赋予相应的输入信号。这种方法允许采用同一个测试平台,通过不同的测试矢量文件进行不同的仿真。值得注意的是,测试矢量文件的读取,需要利用TEXTIO程序包的功能。在TEXTIO程序包中,包含有对文本文件进行读写的过程和函数。
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
举报