⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 picunit3_tbw.vhw

📁 微波爐..........................
💻 VHW
字号:
--------------------------------------------------------------------------------
-- Copyright (c) 1995-2003 Xilinx, Inc.
-- All Right Reserved.
--------------------------------------------------------------------------------
--   ____  ____ 
--  /   /\/   / 
-- /___/  \  /    Vendor: Xilinx 
-- \   \   \/     Version : 7.1.04i
--  \   \         Application : ISE WebPACK
--  /   /         Filename : PICunit3_tbw.vhw
-- /___/   /\     Timestamp : Tue Mar 10 15:02:43 2009
-- \   \  /  \ 
--  \___\/\___\ 
--
--Command: 
--Design Name: PICunit3_tbw
--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 PICunit3_tbw IS
END PICunit3_tbw;

ARCHITECTURE testbench_arch OF PICunit3_tbw IS
    COMPONENT picunit
        PORT (
            PIC_clk : In std_logic;
            Key_num : In std_logic_vector (2 DownTo 0);
            Key_EN : Out std_logic;
            Set : In std_logic;
            Clear : In std_logic;
            Door : In std_logic;
            TC : In std_logic;
            Start : In std_logic;
            Counter_EN : Out std_logic;
            Counter_Reset : Out std_logic;
            LED : Out std_logic_vector (2 DownTo 0)
        );
    END COMPONENT;

    SIGNAL PIC_clk : std_logic := '0';
    SIGNAL Key_num : std_logic_vector (2 DownTo 0) := "000";
    SIGNAL Key_EN : std_logic := '0';
    SIGNAL Set : std_logic := '0';
    SIGNAL Clear : std_logic := '0';
    SIGNAL Door : std_logic := '0';
    SIGNAL TC : std_logic := '0';
    SIGNAL Start : std_logic := '0';
    SIGNAL Counter_EN : std_logic := '0';
    SIGNAL Counter_Reset : std_logic := '0';
    SIGNAL LED : std_logic_vector (2 DownTo 0) := "000";

    SHARED VARIABLE TX_ERROR : INTEGER := 0;
    SHARED VARIABLE TX_OUT : LINE;

    constant PERIOD : time := 100 ns;
    constant DUTY_CYCLE : real := 0.5;
    constant OFFSET : time := 0 ns;

    BEGIN
        UUT : picunit
        PORT MAP (
            PIC_clk => PIC_clk,
            Key_num => Key_num,
            Key_EN => Key_EN,
            Set => Set,
            Clear => Clear,
            Door => Door,
            TC => TC,
            Start => Start,
            Counter_EN => Counter_EN,
            Counter_Reset => Counter_Reset,
            LED => LED
        );

        PROCESS    -- clock process for PIC_clk
        BEGIN
            WAIT for OFFSET;
            CLOCK_LOOP : LOOP
                PIC_clk <= '0';
                WAIT FOR (PERIOD - (PERIOD * DUTY_CYCLE));
                PIC_clk <= '1';
                WAIT FOR (PERIOD * DUTY_CYCLE);
            END LOOP CLOCK_LOOP;
        END PROCESS;

        PROCESS
            PROCEDURE CHECK_Counter_EN(
                next_Counter_EN : std_logic;
                TX_TIME : INTEGER
            ) IS
                VARIABLE TX_STR : String(1 to 4096);
                VARIABLE TX_LOC : LINE;
                BEGIN
                IF (Counter_EN /= next_Counter_EN) THEN
                    STD.TEXTIO.write(TX_LOC, string'("Error at time="));
                    STD.TEXTIO.write(TX_LOC, TX_TIME);
                    STD.TEXTIO.write(TX_LOC, string'("ns Counter_EN="));
                    IEEE.STD_LOGIC_TEXTIO.write(TX_LOC, Counter_EN);
                    STD.TEXTIO.write(TX_LOC, string'(", Expected = "));
                    IEEE.STD_LOGIC_TEXTIO.write(TX_LOC, next_Counter_EN);
                    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_Counter_Reset(
                next_Counter_Reset : std_logic;
                TX_TIME : INTEGER
            ) IS
                VARIABLE TX_STR : String(1 to 4096);
                VARIABLE TX_LOC : LINE;
                BEGIN
                IF (Counter_Reset /= next_Counter_Reset) THEN
                    STD.TEXTIO.write(TX_LOC, string'("Error at time="));
                    STD.TEXTIO.write(TX_LOC, TX_TIME);
                    STD.TEXTIO.write(TX_LOC, string'("ns Counter_Reset="));
                    IEEE.STD_LOGIC_TEXTIO.write(TX_LOC, Counter_Reset);
                    STD.TEXTIO.write(TX_LOC, string'(", Expected = "));
                    IEEE.STD_LOGIC_TEXTIO.write(TX_LOC, next_Counter_Reset);
                    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_Key_EN(
                next_Key_EN : std_logic;
                TX_TIME : INTEGER
            ) IS
                VARIABLE TX_STR : String(1 to 4096);
                VARIABLE TX_LOC : LINE;
                BEGIN
                IF (Key_EN /= next_Key_EN) THEN
                    STD.TEXTIO.write(TX_LOC, string'("Error at time="));
                    STD.TEXTIO.write(TX_LOC, TX_TIME);
                    STD.TEXTIO.write(TX_LOC, string'("ns Key_EN="));
                    IEEE.STD_LOGIC_TEXTIO.write(TX_LOC, Key_EN);
                    STD.TEXTIO.write(TX_LOC, string'(", Expected = "));
                    IEEE.STD_LOGIC_TEXTIO.write(TX_LOC, next_Key_EN);
                    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_LED(
                next_LED : std_logic_vector (2 DownTo 0);
                TX_TIME : INTEGER
            ) IS
                VARIABLE TX_STR : String(1 to 4096);
                VARIABLE TX_LOC : LINE;
                BEGIN
                IF (LED /= next_LED) THEN
                    STD.TEXTIO.write(TX_LOC, string'("Error at time="));
                    STD.TEXTIO.write(TX_LOC, TX_TIME);
                    STD.TEXTIO.write(TX_LOC, string'("ns LED="));
                    IEEE.STD_LOGIC_TEXTIO.write(TX_LOC, LED);
                    STD.TEXTIO.write(TX_LOC, string'(", Expected = "));
                    IEEE.STD_LOGIC_TEXTIO.write(TX_LOC, next_LED);
                    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:  40ns
                WAIT FOR 40 ns;
                Clear <= '0';
                -- -------------------------------------
                -- -------------  Current Time:  140ns
                WAIT FOR 100 ns;
                Clear <= '1';
                -- -------------------------------------
                -- -------------  Current Time:  240ns
                WAIT FOR 100 ns;
                Set <= '0';
                Key_num <= "100";
                -- -------------------------------------
                -- -------------  Current Time:  340ns
                WAIT FOR 100 ns;
                Set <= '1';
                Key_num <= "000";
                -- -------------------------------------
                -- -------------  Current Time:  440ns
                WAIT FOR 100 ns;
                Start <= '0';
                -- -------------------------------------
                -- -------------  Current Time:  540ns
                WAIT FOR 100 ns;
                Door <= '0';
                Start <= '1';
                -- -------------------------------------
                -- -------------  Current Time:  640ns
                WAIT FOR 100 ns;
                Set <= '0';
                Start <= '0';
                Key_num <= "010";
                -- -------------------------------------
                -- -------------  Current Time:  740ns
                WAIT FOR 100 ns;
                Door <= '1';
                Set <= '1';
                Start <= '1';
                Key_num <= "000";
                -- -------------------------------------
                -- -------------  Current Time:  840ns
                WAIT FOR 100 ns;
                Start <= '0';
                -- -------------------------------------
                -- -------------  Current Time:  940ns
                WAIT FOR 100 ns;
                Start <= '1';
                -- -------------------------------------
                -- -------------  Current Time:  1340ns
                WAIT FOR 400 ns;
                TC <= '1';
                -- -------------------------------------
                -- -------------  Current Time:  1440ns
                WAIT FOR 100 ns;
                TC <= '0';
                -- -------------------------------------
                WAIT FOR 660 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 + -