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

📄 test_ae_edh.vhd

📁 XAPP299 version 1.0 reference design files
💻 VHD
📖 第 1 页 / 共 5 页
字号:
            for count in 1 to 5 loop
                wait until clk'event and clk = '0';
            end loop;
            rst <= '0';
            wait;
        end process;

    --
    -- This code keeps track of the number of EDH packets received. Packets received
    -- before the video decoder locks are not counted.
    --
    process
    begin
        packet <= 0;
        
        -- Wait for video decoder to lock to video  
        wait until rst = '0' and locked = '1';

        -- Increment the EDH packet number at each received packet
        loop
            wait until edh_packet'event and edh_packet = '1';
            packet <= packet + 1;
        end loop;
    end process;

    --
    -- This code generates the index into the memory array and the frame counter.
    -- The index begins at a negative number. When the index is negative, no video
    -- is generated. A few cycles with no video are used to make sure the modules
    -- come out of reset before the test set is sent. When the index reaches the
    -- maximum size of the memory array, it is reset to zero and the frame counter
    -- is incremented.
    --

    process(clk, rst)
    begin
        if (rst = '1') then
            i <= -5;
            frames <= 0;
        elsif (clk'event and clk = '1') then
            if (i = MAX_MEM - 1 and frames < 8) then
                i <= 0;
                frames <= frames + 1;
            else
                i <= i + 1;
            end if;
        end if; 
    end process;

    --
    -- Whenever the memory index changes, look up a new video data value from the
    -- memory array and assign that value to d.
    --
    process(i)
    begin
        if (i < 0 or i >= MAX_MEM or frames > 7) then
            d <= (others => '0');
        else
            d <= memory(i);
        end if;
    end process;

    --
    -- When the frame counter changes, this is executed to set up frame specific
    -- values. For the first four frames, all error counter enable flags are
    -- asserted. For the last four frames, only the AP and FF EDH and EDA flags
    -- will cause the error counter to increment. When the frame counter reaches 8,
    -- the test stops.
    -- 
    process(frames)
        variable l : line;
        variable success_string :       string (1 to 28) 
                                        := "Test completed successfully.";
        variable error_string :         string (1 to 40)
                                        := "Expected 7 fields with errors, received ";
    begin
        if (frames >= 4) then
            errcnt_flg_en <= "0000110001100000";    -- 0x0c60
        end if;

        if (frames = 8) then
            
            if (errcnt = 7 and not error_found) then
                write(l, success_string);
                writeline(output, l); 
            else
                write(l, error_string);
                write(l, errcnt);
                writeline(output, l);           
            end if;

            enclk <= '0';
        end if;
    end process;

    --
    -- This code generates the vid_in value that is fed into the modules. Normally,
    -- vid_in is given the value of the d variable, but in somes cases it is
    -- modified to create error conditions.
    --
    process(clk)
    begin
        if (clk'event and clk = '0') then
            vid_in <= d;

            --
            -- During the first EDH packet of frame 2, the AP CRC value is
            -- modified to create a CRC error.
            --
            if (frames = 2) then
                if (i = (FIRST_EDH + AP_CRC_WORD0)) then
                    vid_in <= "1011010100";     -- 0x2d4
                elsif (i = (FIRST_EDH + FF_FLAG_WORD)) then
                    vid_in <= "0100000100";     -- 0x104
                elsif (i = (FIRST_EDH + CS_WORD)) then
                    vid_in <= "1001001000";     -- 0x248
                end if;

            --
            -- During the second EDH packet of frame 3, the EDH packet's checksum
            -- value is modified to create a checksum error.
            --
            elsif (frames = 3) then
                if (i = (SECOND_EDH + CS_WORD)) then
                    vid_in <= "1000000000";     --0x200
                end if;

            --
            -- During the first EDH packet of frame 4, the EDH packet is removed
            -- from the video stream to create an EDH packet missing error.
            --
            elsif (frames = 4) then
                if (i >= FIRST_EDH and i <= (FIRST_EDH + CS_WORD)) then
                    if (i - ((i / 2) * 2) = 0) then
                        vid_in <= "1000000000"; -- 0x200
                    else
                        vid_in <= "0001000000"; -- 0x040
                    end if;
                end if;

            --
            -- During the second field of frame 5, introduce an EDH packet format
            -- error by changing the value of the DBN word.
            --
            elsif (frames = 5) then
                if (i = (SECOND_EDH + DBN_WORD)) then
                    vid_in <= "1000000100";     --0x204;
                elsif (i = (SECOND_EDH + CS_WORD)) then
                    vid_in <= "0101101100";     --0x16c; 
                end if;

            --
            -- During the first field of frame 6, one video data word in the
            -- inactive portion of the video is modified to create a FF CRC error.
            -- The corrupted word is part of an ANC packet. This also causes a
            -- ANC EDH error because the checksum for the ANC packet will be
            -- wrong.
            --
            -- During the second EDH packet of frame 6, the AP EDH bit is set in
            -- the EDH packet.
            --
            elsif (frames = 6) then
                if (i = 5156) then
                    vid_in <= d xor "0000000001";
                elsif (i = (SECOND_EDH + AP_FLAG_WORD)) then
                    vid_in <= "0100000100";     --0x104;
                elsif (i = (SECOND_EDH + CS_WORD)) then
                    vid_in <= "1001101100";     --0x26c;
                end if;

            --
            -- During the first EDH packet of frame 7, the ANC EDH bit is set in
            -- the EDH packet.
            --
            -- During the second EDH packet of frame 7, the parity bit of one of
            -- the words of the packet is forced to an incorrect value to generate
            -- a parity error.
            --
            elsif (frames = 7) then
                if (i = (FIRST_EDH + ANC_FLAG_WORD)) then
                    vid_in <= "0100000100";     --0x104;
                elsif (i = (FIRST_EDH + CS_WORD)) then
                    vid_in <= "0101000100";     --0x144;
                elsif (i = (SECOND_EDH + AP_CRC_WORD2)) then
                    vid_in <= "0110001000";     --0x188;
                elsif (i = (SECOND_EDH + CS_WORD)) then
                    vid_in <= "1001101000";     --0x268;
                end if;
            end if;
        end if;
    end process;

    --
    -- This code generates the local error flag inputs to the EDH processor.
    --      
    process(packet)
    begin
        anc_idh_local <= '0';
        anc_ues_local <= '0';
        ap_idh_local <= '0';
        ff_idh_local <= '0';
        
        case packet is
            when 2 =>   anc_idh_local <= '1';
            when 3 =>   anc_ues_local <= '1';
            when 5 =>   ap_idh_local  <= '1';
            when 6 =>   ff_idh_local  <= '1';
            when 9 => 
                        anc_idh_local <= '1';
                        anc_ues_local <= '1';
            when 10 =>
                        ap_idh_local  <= '1';
                        ff_idh_local  <= '1';

            when others =>
        end case;
    end process;

    --
    -- This code generates the expected values that will be compared with the
    -- actual values generated by the EDH processor.
    --
    process(edh_packet)
    begin
        if (edh_packet'event and edh_packet = '0') then
            if (packet = 0) then
                check_flags <= false;
            else
                check_flags <= true;
            end if;
            
            case packet is
                when 1 =>
                    expected_rx_ap_flags <=  "00000";
                    expected_rx_ff_flags <=  "00000";
                    expected_rx_anc_flags <= "00000";
                    expected_ap_flags <=  "00000";
                    expected_ff_flags <=  "00000";
                    expected_anc_flags <= "00000";
                    expected_chksum_err <= '0';
                    expected_edh_missing <= '0';
                    expected_parity_err <= '0';
                    expected_format_err <= '0';

                when 2 =>
                    expected_rx_ap_flags <=  "00000";
                    expected_rx_ff_flags <=  "00000";
                    expected_rx_anc_flags <= "00000";
                    expected_ap_flags <=  "00000";
                    expected_ff_flags <=  "00000";
                    expected_anc_flags <= "00100";      -- ANC IDH
                    expected_chksum_err <= '0';
                    expected_edh_missing <= '0';
                    expected_parity_err <= '0';
                    expected_format_err <= '0';

                when 3 =>
                    expected_rx_ap_flags <=  "00000";
                    expected_rx_ff_flags <=  "00000";
                    expected_rx_anc_flags <= "00000";
                    expected_ap_flags <=  "00000";
                    expected_ff_flags <=  "00000";
                    expected_anc_flags <= "10000";      -- ANC UES
                    expected_chksum_err <= '0';
                    expected_edh_missing <= '0';
                    expected_parity_err <= '0';
                    expected_format_err <= '0';

                when 4 =>
                    expected_rx_ap_flags <=  "00000";
                    expected_rx_ff_flags <=  "00001";   -- FF EDH
                    expected_rx_anc_flags <= "00000";
                    expected_ap_flags <=  "00001";      -- AP EDH
                    expected_ff_flags <=  "00010";      -- FF EDA
                    expected_anc_flags <= "00000";
                    expected_chksum_err <= '0';
                    expected_edh_missing <= '0';
                    expected_parity_err <= '0';
                    expected_format_err <= '0';

                when 5 =>
                    expected_rx_ap_flags <=  "00000";
                    expected_rx_ff_flags <=  "00000";
                    expected_rx_anc_flags <= "00000";
                    expected_ap_flags <=  "00100";      -- AP IDH
                    expected_ff_flags <=  "00000";

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -