📄 delay_tbw3.vhw
字号:
--------------------------------------------------------------------------------
-- Copyright (c) 1995-2003 Xilinx, Inc.
-- All Right Reserved.
--------------------------------------------------------------------------------
-- ____ ____
-- / /\/ /
-- /___/ \ / Vendor: Xilinx
-- \ \ \/ Version : 8.2i
-- \ \ Application : ISE
-- / / Filename : DELAY_tbw3.vhw
-- /___/ /\ Timestamp : Sat May 12 08:48:36 2007
-- \ \ / \
-- \___\/\___\
--
--Command:
--Design Name: DELAY_tbw3
--Device: Xilinx
--
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
USE IEEE.STD_LOGIC_TEXTIO.ALL;
USE STD.TEXTIO.ALL;
ENTITY DELAY_tbw3 IS
END DELAY_tbw3;
ARCHITECTURE testbench_arch OF DELAY_tbw3 IS
COMPONENT DELAY_VHD
PORT (
TRIG : In std_logic;
CLK : In std_logic;
DATA8 : In std_logic_vector (7 DownTo 0);
LATCH : In std_logic;
OUTPUT : Out std_logic;
output1 : Out std_logic
);
END COMPONENT;
SIGNAL TRIG : std_logic := '0';
SIGNAL CLK : std_logic := '0';
SIGNAL DATA8 : std_logic_vector (7 DownTo 0) := "00000000";
SIGNAL LATCH : std_logic := '0';
SIGNAL OUTPUT : std_logic := 'U';
SIGNAL output1 : std_logic := 'U';
SHARED VARIABLE TX_ERROR : INTEGER := 0;
SHARED VARIABLE TX_OUT : LINE;
constant PERIOD : time := 40 ns;
constant DUTY_CYCLE : real := 0.5;
constant OFFSET : time := 0 ns;
BEGIN
UUT : DELAY_VHD
PORT MAP (
TRIG => TRIG,
CLK => CLK,
DATA8 => DATA8,
LATCH => LATCH,
OUTPUT => OUTPUT,
output1 => output1
);
PROCESS -- clock process for CLK
BEGIN
WAIT for OFFSET;
CLOCK_LOOP : LOOP
CLK <= '0';
WAIT FOR (PERIOD - (PERIOD * DUTY_CYCLE));
CLK <= '1';
WAIT FOR (PERIOD * DUTY_CYCLE);
END LOOP CLOCK_LOOP;
END PROCESS;
PROCESS
PROCEDURE CHECK_OUTPUT(
next_OUTPUT : std_logic;
TX_TIME : INTEGER
) IS
VARIABLE TX_STR : String(1 to 4096);
VARIABLE TX_LOC : LINE;
BEGIN
IF (OUTPUT /= next_OUTPUT) THEN
STD.TEXTIO.write(TX_LOC, string'("Error at time="));
STD.TEXTIO.write(TX_LOC, TX_TIME);
STD.TEXTIO.write(TX_LOC, string'("ns OUTPUT="));
IEEE.STD_LOGIC_TEXTIO.write(TX_LOC, OUTPUT);
STD.TEXTIO.write(TX_LOC, string'(", Expected = "));
IEEE.STD_LOGIC_TEXTIO.write(TX_LOC, next_OUTPUT);
STD.TEXTIO.write(TX_LOC, string'(" "));
TX_STR(TX_LOC.all'range) := TX_LOC.all;
STD.TEXTIO.Deallocate(TX_LOC);
ASSERT (FALSE) REPORT TX_STR SEVERITY ERROR;
TX_ERROR := TX_ERROR + 1;
END IF;
END;
PROCEDURE CHECK_output1(
next_output1 : std_logic;
TX_TIME : INTEGER
) IS
VARIABLE TX_STR : String(1 to 4096);
VARIABLE TX_LOC : LINE;
BEGIN
IF (output1 /= next_output1) THEN
STD.TEXTIO.write(TX_LOC, string'("Error at time="));
STD.TEXTIO.write(TX_LOC, TX_TIME);
STD.TEXTIO.write(TX_LOC, string'("ns output1="));
IEEE.STD_LOGIC_TEXTIO.write(TX_LOC, output1);
STD.TEXTIO.write(TX_LOC, string'(", Expected = "));
IEEE.STD_LOGIC_TEXTIO.write(TX_LOC, next_output1);
STD.TEXTIO.write(TX_LOC, string'(" "));
TX_STR(TX_LOC.all'range) := TX_LOC.all;
STD.TEXTIO.Deallocate(TX_LOC);
ASSERT (FALSE) REPORT TX_STR SEVERITY ERROR;
TX_ERROR := TX_ERROR + 1;
END IF;
END;
BEGIN
-- ------------- Current Time: 55ns
WAIT FOR 55 ns;
TRIG <= '1';
LATCH <= '1';
DATA8 <= "00000011";
-- -------------------------------------
-- ------------- Current Time: 95ns
WAIT FOR 40 ns;
LATCH <= '0';
DATA8 <= "00000000";
-- -------------------------------------
-- ------------- Current Time: 135ns
WAIT FOR 40 ns;
TRIG <= '0';
-- -------------------------------------
-- ------------- Current Time: 225ns
WAIT FOR 90 ns;
CHECK_output1('1', 225);
-- -------------------------------------
-- ------------- Current Time: 305ns
WAIT FOR 80 ns;
CHECK_OUTPUT('1', 305);
CHECK_output1('0', 305);
-- -------------------------------------
-- ------------- Current Time: 385ns
WAIT FOR 80 ns;
CHECK_OUTPUT('0', 385);
-- -------------------------------------
-- ------------- Current Time: 535ns
WAIT FOR 150 ns;
TRIG <= '1';
LATCH <= '1';
DATA8 <= "00000011";
-- -------------------------------------
-- ------------- Current Time: 575ns
WAIT FOR 40 ns;
LATCH <= '0';
DATA8 <= "00000000";
-- -------------------------------------
-- ------------- Current Time: 615ns
WAIT FOR 40 ns;
TRIG <= '0';
-- -------------------------------------
-- ------------- Current Time: 705ns
WAIT FOR 90 ns;
CHECK_output1('1', 705);
-- -------------------------------------
-- ------------- Current Time: 785ns
WAIT FOR 80 ns;
CHECK_OUTPUT('1', 785);
CHECK_output1('0', 785);
-- -------------------------------------
-- ------------- Current Time: 865ns
WAIT FOR 80 ns;
CHECK_OUTPUT('0', 865);
-- -------------------------------------
-- ------------- Current Time: 1015ns
WAIT FOR 150 ns;
TRIG <= '1';
LATCH <= '1';
DATA8 <= "00000100";
-- -------------------------------------
-- ------------- Current Time: 1055ns
WAIT FOR 40 ns;
LATCH <= '0';
DATA8 <= "00000000";
-- -------------------------------------
-- ------------- Current Time: 1095ns
WAIT FOR 40 ns;
TRIG <= '0';
-- -------------------------------------
-- ------------- Current Time: 1225ns
WAIT FOR 130 ns;
CHECK_output1('1', 1225);
-- -------------------------------------
-- ------------- Current Time: 1265ns
WAIT FOR 40 ns;
CHECK_OUTPUT('1', 1265);
-- -------------------------------------
-- ------------- Current Time: 1305ns
WAIT FOR 40 ns;
CHECK_output1('0', 1305);
-- -------------------------------------
-- ------------- Current Time: 1345ns
WAIT FOR 40 ns;
CHECK_OUTPUT('0', 1345);
-- -------------------------------------
-- ------------- Current Time: 1695ns
WAIT FOR 350 ns;
TRIG <= '1';
LATCH <= '1';
DATA8 <= "00000100";
-- -------------------------------------
-- ------------- Current Time: 1735ns
WAIT FOR 40 ns;
LATCH <= '0';
DATA8 <= "00000000";
-- -------------------------------------
-- ------------- Current Time: 1775ns
WAIT FOR 40 ns;
TRIG <= '0';
-- -------------------------------------
-- ------------- Current Time: 1905ns
WAIT FOR 130 ns;
CHECK_output1('1', 1905);
-- -------------------------------------
-- ------------- Current Time: 1945ns
WAIT FOR 40 ns;
CHECK_OUTPUT('1', 1945);
-- -------------------------------------
-- ------------- Current Time: 1985ns
WAIT FOR 40 ns;
CHECK_output1('0', 1985);
-- -------------------------------------
-- ------------- Current Time: 2025ns
WAIT FOR 40 ns;
CHECK_OUTPUT('0', 2025);
-- -------------------------------------
-- ------------- Current Time: 2535ns
WAIT FOR 510 ns;
TRIG <= '1';
LATCH <= '1';
DATA8 <= "00000110";
-- -------------------------------------
-- ------------- Current Time: 2575ns
WAIT FOR 40 ns;
LATCH <= '0';
-- -------------------------------------
-- ------------- Current Time: 2615ns
WAIT FOR 40 ns;
TRIG <= '0';
DATA8 <= "00000000";
-- -------------------------------------
-- ------------- Current Time: 2785ns
WAIT FOR 170 ns;
CHECK_OUTPUT('1', 2785);
-- -------------------------------------
-- ------------- Current Time: 2825ns
WAIT FOR 40 ns;
CHECK_output1('1', 2825);
-- -------------------------------------
-- ------------- Current Time: 2865ns
WAIT FOR 40 ns;
CHECK_OUTPUT('0', 2865);
-- -------------------------------------
-- ------------- Current Time: 2905ns
WAIT FOR 40 ns;
CHECK_output1('0', 2905);
-- -------------------------------------
-- ------------- Current Time: 3135ns
WAIT FOR 230 ns;
TRIG <= '1';
LATCH <= '1';
DATA8 <= "00000101";
-- -------------------------------------
-- ------------- Current Time: 3175ns
WAIT FOR 40 ns;
LATCH <= '0';
-- -------------------------------------
-- ------------- Current Time: 3215ns
WAIT FOR 40 ns;
TRIG <= '0';
DATA8 <= "00000000";
-- -------------------------------------
-- ------------- Current Time: 3385ns
WAIT FOR 170 ns;
CHECK_OUTPUT('1', 3385);
CHECK_output1('1', 3385);
-- -------------------------------------
-- ------------- Current Time: 3465ns
WAIT FOR 80 ns;
CHECK_OUTPUT('0', 3465);
CHECK_output1('0', 3465);
-- -------------------------------------
-- ------------- Current Time: 3535ns
WAIT FOR 70 ns;
TRIG <= '1';
LATCH <= '1';
DATA8 <= "00000101";
-- -------------------------------------
-- ------------- Current Time: 3575ns
WAIT FOR 40 ns;
LATCH <= '0';
DATA8 <= "00000000";
-- -------------------------------------
-- ------------- Current Time: 3615ns
WAIT FOR 40 ns;
TRIG <= '0';
-- -------------------------------------
-- ------------- Current Time: 3785ns
WAIT FOR 170 ns;
CHECK_OUTPUT('1', 3785);
CHECK_output1('1', 3785);
-- -------------------------------------
-- ------------- Current Time: 3865ns
WAIT FOR 80 ns;
CHECK_OUTPUT('0', 3865);
CHECK_output1('0', 3865);
-- -------------------------------------
-- ------------- Current Time: 4175ns
WAIT FOR 310 ns;
TRIG <= '1';
LATCH <= '1';
DATA8 <= "00000101";
-- -------------------------------------
-- ------------- Current Time: 4215ns
WAIT FOR 40 ns;
LATCH <= '0';
-- -------------------------------------
-- ------------- Current Time: 4375ns
WAIT FOR 160 ns;
TRIG <= '0';
-- -------------------------------------
-- ------------- Current Time: 4425ns
WAIT FOR 50 ns;
CHECK_OUTPUT('1', 4425);
CHECK_output1('1', 4425);
-- -------------------------------------
-- ------------- Current Time: 4505ns
WAIT FOR 80 ns;
CHECK_OUTPUT('0', 4505);
CHECK_output1('0', 4505);
-- -------------------------------------
WAIT FOR 535 ns;
IF (TX_ERROR = 0) THEN
STD.TEXTIO.write(TX_OUT, string'("No errors or warnings"));
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"));
ASSERT (FALSE) REPORT "Errors found during simulation"
SEVERITY FAILURE;
END IF;
END PROCESS;
END testbench_arch;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -