📄 cpu_16_wave.vhw
字号:
-- C:\XILINX\BIN\MYCPU16
-- VHDL Test Bench created by
-- HDL Bencher 6.1i
-- Thu Nov 15 12:52:24 2007
--
-- Notes:
-- 1) This testbench has been automatically generated from
-- your Test Bench Waveform
-- 2) To use this as a user modifiable testbench do the following:
-- - Save it as a file with a .vhd extension (i.e. File->Save As...)
-- - Add it to your project as a testbench source (i.e. Project->Add Source...)
--
LIBRARY UNISIM;USE UNISIM.VCOMPONENTS.ALL;LIBRARY IEEE;USE IEEE.STD_LOGIC_1164.ALL;USE IEEE.STD_LOGIC_TEXTIO.ALL;
USE STD.TEXTIO.ALL;
ENTITY cpu_16_wave IS
END cpu_16_wave;
ARCHITECTURE testbench_arch OF cpu_16_wave IS
-- If you get a compiler error on the following line,
-- from the menu do Options->Configuration select VHDL 87
FILE RESULTS: TEXT OPEN WRITE_MODE IS "results.txt";
COMPONENT cpu_16
PORT (
clk : In std_logic;
RST : In std_logic;
Dbus : InOut std_logic_vector (15 DOWNTO 0);
Abus : Out std_logic_vector (15 DOWNTO 0);
nWR : Out std_logic;
nRD : Out std_logic;
nBLE : Out std_logic;
nBHE : Out std_logic;
nMREQ : Out std_logic
);
END COMPONENT;
SIGNAL clk : std_logic;
SIGNAL RST : std_logic;
SIGNAL Dbus : std_logic_vector (15 DOWNTO 0);
SIGNAL Abus : std_logic_vector (15 DOWNTO 0);
SIGNAL nWR : std_logic;
SIGNAL nRD : std_logic;
SIGNAL nBLE : std_logic;
SIGNAL nBHE : std_logic;
SIGNAL nMREQ : std_logic;
BEGIN
UUT : cpu_16
PORT MAP (
clk => clk,
RST => RST,
Dbus => Dbus,
Abus => Abus,
nWR => nWR,
nRD => nRD,
nBLE => nBLE,
nBHE => nBHE,
nMREQ => nMREQ
);
PROCESS -- clock process for clk,
BEGIN
CLOCK_LOOP : LOOP
clk <= transport '0';
WAIT FOR 10 ns;
clk <= transport '1';
WAIT FOR 10 ns;
WAIT FOR 40 ns;
clk <= transport '0';
WAIT FOR 40 ns;
END LOOP CLOCK_LOOP;
END PROCESS;
PROCESS -- Process for clk
VARIABLE TX_OUT : LINE;
VARIABLE TX_ERROR : INTEGER := 0;
PROCEDURE CHECK_Abus(
next_Abus : std_logic_vector (15 DOWNTO 0);
TX_TIME : INTEGER
) IS
VARIABLE TX_STR : String(1 to 4096);
VARIABLE TX_LOC : LINE;
BEGIN
-- If compiler error ("/=" is ambiguous) occurs in the next line of code
-- change compiler settings to use explicit declarations only
IF (Abus /= next_Abus) THEN
STD.TEXTIO.write(TX_LOC,string'("Error at time="));
STD.TEXTIO.write(TX_LOC, TX_TIME);
STD.TEXTIO.write(TX_LOC,string'("ns Abus="));
IEEE.STD_LOGIC_TEXTIO.write(TX_LOC, Abus);
STD.TEXTIO.write(TX_LOC, string'(", Expected = "));
IEEE.STD_LOGIC_TEXTIO.write(TX_LOC, next_Abus);
STD.TEXTIO.write(TX_LOC, string'(" "));
TX_STR(TX_LOC.all'range) := TX_LOC.all;
STD.TEXTIO.writeline(results, TX_LOC);
STD.TEXTIO.Deallocate(TX_LOC);
ASSERT (FALSE) REPORT TX_STR SEVERITY ERROR;
TX_ERROR := TX_ERROR + 1;
END IF;
END;
PROCEDURE CHECK_nWR(
next_nWR : std_logic;
TX_TIME : INTEGER
) IS
VARIABLE TX_STR : String(1 to 4096);
VARIABLE TX_LOC : LINE;
BEGIN
-- If compiler error ("/=" is ambiguous) occurs in the next line of code
-- change compiler settings to use explicit declarations only
IF (nWR /= next_nWR) THEN
STD.TEXTIO.write(TX_LOC,string'("Error at time="));
STD.TEXTIO.write(TX_LOC, TX_TIME);
STD.TEXTIO.write(TX_LOC,string'("ns nWR="));
IEEE.STD_LOGIC_TEXTIO.write(TX_LOC, nWR);
STD.TEXTIO.write(TX_LOC, string'(", Expected = "));
IEEE.STD_LOGIC_TEXTIO.write(TX_LOC, next_nWR);
STD.TEXTIO.write(TX_LOC, string'(" "));
TX_STR(TX_LOC.all'range) := TX_LOC.all;
STD.TEXTIO.writeline(results, TX_LOC);
STD.TEXTIO.Deallocate(TX_LOC);
ASSERT (FALSE) REPORT TX_STR SEVERITY ERROR;
TX_ERROR := TX_ERROR + 1;
END IF;
END;
PROCEDURE CHECK_nRD(
next_nRD : std_logic;
TX_TIME : INTEGER
) IS
VARIABLE TX_STR : String(1 to 4096);
VARIABLE TX_LOC : LINE;
BEGIN
-- If compiler error ("/=" is ambiguous) occurs in the next line of code
-- change compiler settings to use explicit declarations only
IF (nRD /= next_nRD) THEN
STD.TEXTIO.write(TX_LOC,string'("Error at time="));
STD.TEXTIO.write(TX_LOC, TX_TIME);
STD.TEXTIO.write(TX_LOC,string'("ns nRD="));
IEEE.STD_LOGIC_TEXTIO.write(TX_LOC, nRD);
STD.TEXTIO.write(TX_LOC, string'(", Expected = "));
IEEE.STD_LOGIC_TEXTIO.write(TX_LOC, next_nRD);
STD.TEXTIO.write(TX_LOC, string'(" "));
TX_STR(TX_LOC.all'range) := TX_LOC.all;
STD.TEXTIO.writeline(results, TX_LOC);
STD.TEXTIO.Deallocate(TX_LOC);
ASSERT (FALSE) REPORT TX_STR SEVERITY ERROR;
TX_ERROR := TX_ERROR + 1;
END IF;
END;
PROCEDURE CHECK_nBLE(
next_nBLE : std_logic;
TX_TIME : INTEGER
) IS
VARIABLE TX_STR : String(1 to 4096);
VARIABLE TX_LOC : LINE;
BEGIN
-- If compiler error ("/=" is ambiguous) occurs in the next line of code
-- change compiler settings to use explicit declarations only
IF (nBLE /= next_nBLE) THEN
STD.TEXTIO.write(TX_LOC,string'("Error at time="));
STD.TEXTIO.write(TX_LOC, TX_TIME);
STD.TEXTIO.write(TX_LOC,string'("ns nBLE="));
IEEE.STD_LOGIC_TEXTIO.write(TX_LOC, nBLE);
STD.TEXTIO.write(TX_LOC, string'(", Expected = "));
IEEE.STD_LOGIC_TEXTIO.write(TX_LOC, next_nBLE);
STD.TEXTIO.write(TX_LOC, string'(" "));
TX_STR(TX_LOC.all'range) := TX_LOC.all;
STD.TEXTIO.writeline(results, TX_LOC);
STD.TEXTIO.Deallocate(TX_LOC);
ASSERT (FALSE) REPORT TX_STR SEVERITY ERROR;
TX_ERROR := TX_ERROR + 1;
END IF;
END;
PROCEDURE CHECK_nBHE(
next_nBHE : std_logic;
TX_TIME : INTEGER
) IS
VARIABLE TX_STR : String(1 to 4096);
VARIABLE TX_LOC : LINE;
BEGIN
-- If compiler error ("/=" is ambiguous) occurs in the next line of code
-- change compiler settings to use explicit declarations only
IF (nBHE /= next_nBHE) THEN
STD.TEXTIO.write(TX_LOC,string'("Error at time="));
STD.TEXTIO.write(TX_LOC, TX_TIME);
STD.TEXTIO.write(TX_LOC,string'("ns nBHE="));
IEEE.STD_LOGIC_TEXTIO.write(TX_LOC, nBHE);
STD.TEXTIO.write(TX_LOC, string'(", Expected = "));
IEEE.STD_LOGIC_TEXTIO.write(TX_LOC, next_nBHE);
STD.TEXTIO.write(TX_LOC, string'(" "));
TX_STR(TX_LOC.all'range) := TX_LOC.all;
STD.TEXTIO.writeline(results, TX_LOC);
STD.TEXTIO.Deallocate(TX_LOC);
ASSERT (FALSE) REPORT TX_STR SEVERITY ERROR;
TX_ERROR := TX_ERROR + 1;
END IF;
END;
PROCEDURE CHECK_nMREQ(
next_nMREQ : std_logic;
TX_TIME : INTEGER
) IS
VARIABLE TX_STR : String(1 to 4096);
VARIABLE TX_LOC : LINE;
BEGIN
-- If compiler error ("/=" is ambiguous) occurs in the next line of code
-- change compiler settings to use explicit declarations only
IF (nMREQ /= next_nMREQ) THEN
STD.TEXTIO.write(TX_LOC,string'("Error at time="));
STD.TEXTIO.write(TX_LOC, TX_TIME);
STD.TEXTIO.write(TX_LOC,string'("ns nMREQ="));
IEEE.STD_LOGIC_TEXTIO.write(TX_LOC, nMREQ);
STD.TEXTIO.write(TX_LOC, string'(", Expected = "));
IEEE.STD_LOGIC_TEXTIO.write(TX_LOC, next_nMREQ);
STD.TEXTIO.write(TX_LOC, string'(" "));
TX_STR(TX_LOC.all'range) := TX_LOC.all;
STD.TEXTIO.writeline(results, TX_LOC);
STD.TEXTIO.Deallocate(TX_LOC);
ASSERT (FALSE) REPORT TX_STR SEVERITY ERROR;
TX_ERROR := TX_ERROR + 1;
END IF;
END;
PROCEDURE CHECK_Dbus(
next_Dbus : std_logic_vector (15 DOWNTO 0);
TX_TIME : INTEGER
) IS
VARIABLE TX_STR : String(1 to 4096);
VARIABLE TX_LOC : LINE;
BEGIN
-- If compiler error ("/=" is ambiguous) occurs in the next line of code
-- change compiler settings to use explicit declarations only
IF (Dbus /= next_Dbus) THEN
STD.TEXTIO.write(TX_LOC,string'("Error at time="));
STD.TEXTIO.write(TX_LOC, TX_TIME);
STD.TEXTIO.write(TX_LOC,string'("ns Dbus="));
IEEE.STD_LOGIC_TEXTIO.write(TX_LOC, Dbus);
STD.TEXTIO.write(TX_LOC, string'(", Expected = "));
IEEE.STD_LOGIC_TEXTIO.write(TX_LOC, next_Dbus);
STD.TEXTIO.write(TX_LOC, string'(" "));
TX_STR(TX_LOC.all'range) := TX_LOC.all;
STD.TEXTIO.writeline(results, TX_LOC);
STD.TEXTIO.Deallocate(TX_LOC);
ASSERT (FALSE) REPORT TX_STR SEVERITY ERROR;
TX_ERROR := TX_ERROR + 1;
END IF;
END;
BEGIN
-- --------------------
RST <= transport '0';
-- --------------------
WAIT FOR 100 ns; -- Time=100 ns
RST <= transport '1';
Dbus <= transport std_logic_vector'("0101000000000001"); --5001
-- --------------------
WAIT FOR 100 ns; -- Time=200 ns
Dbus <= transport std_logic_vector'("ZZZZZZZZZZZZZZZZ"); --Z
-- --------------------
WAIT FOR 400 ns; -- Time=600 ns
Dbus <= transport std_logic_vector'("0101000100000010"); --5102
-- --------------------
WAIT FOR 100 ns; -- Time=700 ns
Dbus <= transport std_logic_vector'("ZZZZZZZZZZZZZZZZ"); --Z
-- --------------------
WAIT FOR 400 ns; -- Time=1100 ns
Dbus <= transport std_logic_vector'("0100011100000000"); --4700
-- --------------------
WAIT FOR 100 ns; -- Time=1200 ns
Dbus <= transport std_logic_vector'("ZZZZZZZZZZZZZZZZ"); --Z
-- --------------------
WAIT FOR 400 ns; -- Time=1600 ns
Dbus <= transport std_logic_vector'("0000000000000001"); --1
-- --------------------
WAIT FOR 100 ns; -- Time=1700 ns
Dbus <= transport std_logic_vector'("ZZZZZZZZZZZZZZZZ"); --Z
-- --------------------
WAIT FOR 400 ns; -- Time=2100 ns
Dbus <= transport std_logic_vector'("0110000011111111"); --60FF
-- --------------------
WAIT FOR 100 ns; -- Time=2200 ns
Dbus <= transport std_logic_vector'("ZZZZZZZZZZZZZZZZ"); --Z
-- --------------------
WAIT FOR 400 ns; -- Time=2600 ns
Dbus <= transport std_logic_vector'("0101010000000000"); --5400
-- --------------------
WAIT FOR 100 ns; -- Time=2700 ns
Dbus <= transport std_logic_vector'("ZZZZZZZZZZZZZZZZ"); --Z
-- --------------------
WAIT FOR 400 ns; -- Time=3100 ns
Dbus <= transport std_logic_vector'("1000010010101011"); --84AB
-- --------------------
WAIT FOR 100 ns; -- Time=3200 ns
Dbus <= transport std_logic_vector'("ZZZZZZZZZZZZZZZZ"); --Z
-- --------------------
WAIT FOR 400 ns; -- Time=3600 ns
Dbus <= transport std_logic_vector'("0111010111001101"); --75CD
-- --------------------
WAIT FOR 100 ns; -- Time=3700 ns
Dbus <= transport std_logic_vector'("ZZZZZZZZZZZZZZZZ"); --Z
-- --------------------
WAIT FOR 300 ns; -- Time=4000 ns
Dbus <= transport std_logic_vector'("ZZZZZZZZ01000101"); --ZZ45
-- --------------------
WAIT FOR 100 ns; -- Time=4100 ns
Dbus <= transport std_logic_vector'("ZZZZZZZZZZZZZZZZ"); --Z
-- --------------------
WAIT FOR 860 ns; -- Time=4960 ns
-- --------------------
IF (TX_ERROR = 0) THEN
STD.TEXTIO.write(TX_OUT,string'("No errors or warnings"));
STD.TEXTIO.writeline(results, TX_OUT);
ASSERT (FALSE) REPORT
"Simulation successful (not a failure). No problems detected. "
SEVERITY FAILURE;
ELSE
STD.TEXTIO.write(TX_OUT, TX_ERROR);
STD.TEXTIO.write(TX_OUT, string'(
" errors found in simulation"));
STD.TEXTIO.writeline(results, TX_OUT);
ASSERT (FALSE) REPORT
"Errors found during simulation"
SEVERITY FAILURE;
END IF;
END PROCESS;
END testbench_arch;
CONFIGURATION cpu_16_cfg OF cpu_16_wave IS
FOR testbench_arch
END FOR;
END cpu_16_cfg;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -