OpenCores
URL https://opencores.org/ocsvn/wb_tk/wb_tk/trunk

Subversion Repositories wb_tk

[/] [wb_tk/] [tags/] [a01/] [TestBench/] [wb_arbiter_TB.vhd] - Diff between revs 3 and 7

Only display areas with differences | Details | Blame | View Log

Rev 3 Rev 7
library ieee;
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_1164.all;
 
 
library work;
library work;
use wb_tk.all;
use wb_tk.all;
 
 
entity wb_arbiter_tb is
entity wb_arbiter_tb is
end wb_arbiter_tb;
end wb_arbiter_tb;
 
 
architecture TB of wb_arbiter_tb is
architecture TB of wb_arbiter_tb is
        -- Component declaration of the tested unit
        -- Component declaration of the tested unit
        component wb_arbiter is
        component wb_arbiter is
                port (
                port (
        --              clk: in std_logic;
        --              clk: in std_logic;
                        rst_i: in std_logic := '0';
                        rst_i: in std_logic := '0';
 
 
                        -- interface to master device a
                        -- interface to master device a
                        a_we_i: in std_logic;
                        a_we_i: in std_logic;
                        a_stb_i: in std_logic;
                        a_stb_i: in std_logic;
                        a_cyc_i: in std_logic;
                        a_cyc_i: in std_logic;
                        a_ack_o: out std_logic;
                        a_ack_o: out std_logic;
                        a_ack_oi: in std_logic := '-';
                        a_ack_oi: in std_logic := '-';
                        a_err_o: out std_logic;
                        a_err_o: out std_logic;
                        a_err_oi: in std_logic := '-';
                        a_err_oi: in std_logic := '-';
                        a_rty_o: out std_logic;
                        a_rty_o: out std_logic;
                        a_rty_oi: in std_logic := '-';
                        a_rty_oi: in std_logic := '-';
 
 
                        -- interface to master device b
                        -- interface to master device b
                        b_we_i: in std_logic;
                        b_we_i: in std_logic;
                        b_stb_i: in std_logic;
                        b_stb_i: in std_logic;
                        b_cyc_i: in std_logic;
                        b_cyc_i: in std_logic;
                        b_ack_o: out std_logic;
                        b_ack_o: out std_logic;
                        b_ack_oi: in std_logic := '-';
                        b_ack_oi: in std_logic := '-';
                        b_err_o: out std_logic;
                        b_err_o: out std_logic;
                        b_err_oi: in std_logic := '-';
                        b_err_oi: in std_logic := '-';
                        b_rty_o: out std_logic;
                        b_rty_o: out std_logic;
                        b_rty_oi: in std_logic := '-';
                        b_rty_oi: in std_logic := '-';
 
 
                        -- interface to shared devices
                        -- interface to shared devices
                        s_we_o: out std_logic;
                        s_we_o: out std_logic;
                        s_stb_o: out std_logic;
                        s_stb_o: out std_logic;
                        s_cyc_o: out std_logic;
                        s_cyc_o: out std_logic;
                        s_ack_i: in std_logic;
                        s_ack_i: in std_logic;
                        s_err_i: in std_logic := '-';
                        s_err_i: in std_logic := '-';
                        s_rty_i: in std_logic := '-';
                        s_rty_i: in std_logic := '-';
 
 
                        mux_signal: out std_logic; -- 0: select A signals, 1: select B signals
                        mux_signal: out std_logic; -- 0: select A signals, 1: select B signals
 
 
                        -- misc control lines
                        -- misc control lines
                        priority: in std_logic -- 0: A have priority over B, 1: B have priority over A
                        priority: in std_logic -- 0: A have priority over B, 1: B have priority over A
                );
                );
        end component;
        end component;
 
 
        signal clk_i:  std_logic;
        signal clk_i:  std_logic;
        signal rst_i:  std_logic := '0';
        signal rst_i:  std_logic := '0';
 
 
        -- interface to master device a
        -- interface to master device a
        signal a_we_i:  std_logic;
        signal a_we_i:  std_logic;
        signal a_stb_i:  std_logic;
        signal a_stb_i:  std_logic;
        signal a_cyc_i:  std_logic;
        signal a_cyc_i:  std_logic;
        signal a_ack_o:  std_logic;
        signal a_ack_o:  std_logic;
        signal a_ack_oi:  std_logic := 'U';
        signal a_ack_oi:  std_logic := 'U';
        signal a_err_o:  std_logic;
        signal a_err_o:  std_logic;
        signal a_err_oi:  std_logic := 'U';
        signal a_err_oi:  std_logic := 'U';
        signal a_rty_o:  std_logic;
        signal a_rty_o:  std_logic;
        signal a_rty_oi:  std_logic := 'U';
        signal a_rty_oi:  std_logic := 'U';
 
 
        -- interface to master device b
        -- interface to master device b
        signal b_we_i:  std_logic;
        signal b_we_i:  std_logic;
        signal b_stb_i:  std_logic;
        signal b_stb_i:  std_logic;
        signal b_cyc_i:  std_logic;
        signal b_cyc_i:  std_logic;
        signal b_ack_o:  std_logic;
        signal b_ack_o:  std_logic;
        signal b_ack_oi:  std_logic := 'U';
        signal b_ack_oi:  std_logic := 'U';
        signal b_err_o:  std_logic;
        signal b_err_o:  std_logic;
        signal b_err_oi:  std_logic := 'U';
        signal b_err_oi:  std_logic := 'U';
        signal b_rty_o:  std_logic;
        signal b_rty_o:  std_logic;
        signal b_rty_oi:  std_logic := 'U';
        signal b_rty_oi:  std_logic := 'U';
 
 
        -- interface to shared devices
        -- interface to shared devices
        signal s_we_o:  std_logic;
        signal s_we_o:  std_logic;
        signal s_stb_o:  std_logic;
        signal s_stb_o:  std_logic;
        signal s_cyc_o:  std_logic;
        signal s_cyc_o:  std_logic;
        signal s_ack_i:  std_logic;
        signal s_ack_i:  std_logic;
        signal s_err_i:  std_logic := 'U';
        signal s_err_i:  std_logic := 'U';
        signal s_rty_i:  std_logic := 'U';
        signal s_rty_i:  std_logic := 'U';
 
 
        signal mux_signal:  std_logic; -- 0: select A signals, 1: select B signals
        signal mux_signal:  std_logic; -- 0: select A signals, 1: select B signals
 
 
        -- misc control lines
        -- misc control lines
        signal priority:  std_logic; -- 0: A have priority over B, 1: B have priority over A
        signal priority:  std_logic; -- 0: A have priority over B, 1: B have priority over A
 
 
        signal start: std_logic := '0';
        signal start: std_logic := '0';
 
 
begin
begin
 
 
        -- Unit Under Test port map
        -- Unit Under Test port map
        UUT : wb_arbiter
        UUT : wb_arbiter
                port map (
                port map (
                        rst_i => rst_i,
                        rst_i => rst_i,
 
 
                        -- interface to master device a
                        -- interface to master device a
                        a_we_i => a_we_i,
                        a_we_i => a_we_i,
                        a_stb_i => a_stb_i,
                        a_stb_i => a_stb_i,
                        a_cyc_i => a_cyc_i,
                        a_cyc_i => a_cyc_i,
                        a_ack_o => a_ack_o,
                        a_ack_o => a_ack_o,
                        a_ack_oi => a_ack_oi,
                        a_ack_oi => a_ack_oi,
                        a_err_o => a_err_o,
                        a_err_o => a_err_o,
                        a_err_oi => a_err_oi,
                        a_err_oi => a_err_oi,
                        a_rty_o => a_rty_o,
                        a_rty_o => a_rty_o,
                        a_rty_oi => a_rty_oi,
                        a_rty_oi => a_rty_oi,
 
 
                        -- interface to master device b
                        -- interface to master device b
                        b_we_i => b_we_i,
                        b_we_i => b_we_i,
                        b_stb_i => b_stb_i,
                        b_stb_i => b_stb_i,
                        b_cyc_i => b_cyc_i,
                        b_cyc_i => b_cyc_i,
                        b_ack_o => b_ack_o,
                        b_ack_o => b_ack_o,
                        b_ack_oi => b_ack_oi,
                        b_ack_oi => b_ack_oi,
                        b_err_o => b_err_o,
                        b_err_o => b_err_o,
                        b_err_oi => b_err_oi,
                        b_err_oi => b_err_oi,
                        b_rty_o => b_rty_o,
                        b_rty_o => b_rty_o,
                        b_rty_oi => b_rty_oi,
                        b_rty_oi => b_rty_oi,
 
 
                        -- interface to shared devices
                        -- interface to shared devices
                        s_we_o => s_we_o,
                        s_we_o => s_we_o,
                        s_stb_o => s_stb_o,
                        s_stb_o => s_stb_o,
                        s_cyc_o => s_cyc_o,
                        s_cyc_o => s_cyc_o,
                        s_ack_i => s_ack_i,
                        s_ack_i => s_ack_i,
                        s_err_i => s_err_i,
                        s_err_i => s_err_i,
                        s_rty_i => s_rty_i,
                        s_rty_i => s_rty_i,
 
 
                        mux_signal => mux_signal,
                        mux_signal => mux_signal,
 
 
                        -- misc control lines
                        -- misc control lines
                        priority => priority
                        priority => priority
                );
                );
 
 
        -- Reset the machine
        -- Reset the machine
        rst: process is
        rst: process is
        begin
        begin
                rst_i <= '1';
                rst_i <= '1';
                wait for 10ns;
                wait for 10ns;
                rst_i <= '0';
                rst_i <= '0';
                start <= '1';
                start <= '1';
                wait;
                wait;
        end process;
        end process;
 
 
        clock: process is
        clock: process is
        begin
        begin
                clk_i <= '0';
                clk_i <= '0';
                wait for 10ns;
                wait for 10ns;
                clk_i <= '1';
                clk_i <= '1';
                wait for 10ns;
                wait for 10ns;
        end process;
        end process;
 
 
        -- Simulate a 3WS access time memory
        -- Simulate a 3WS access time memory
        memory: process is
        memory: process is
        begin
        begin
                s_ack_i <= '0';
                s_ack_i <= '0';
                wait until (s_stb_o = '1' and clk_i'EVENT and clk_i = '1');
                wait until (s_stb_o = '1' and clk_i'EVENT and clk_i = '1');
                wait until (clk_i'EVENT and clk_i = '1');
                wait until (clk_i'EVENT and clk_i = '1');
                wait until (clk_i'EVENT and clk_i = '1');
                wait until (clk_i'EVENT and clk_i = '1');
                wait until (clk_i'EVENT and clk_i = '1');
                wait until (clk_i'EVENT and clk_i = '1');
                s_ack_i <= '1';
                s_ack_i <= '1';
                wait until (clk_i'EVENT and clk_i = '1');
                wait until (clk_i'EVENT and clk_i = '1');
        end process;
        end process;
 
 
        -- Generate requests
        -- Generate requests
        a_req: process is
        a_req: process is
        begin
        begin
                a_we_i <= '0';
                a_we_i <= '0';
                a_cyc_i <= '0';
                a_cyc_i <= '0';
                a_stb_i <= '0';
                a_stb_i <= '0';
                wait for 100ns;
                wait for 100ns;
                a_cyc_i <= '1';
                a_cyc_i <= '1';
                a_stb_i <= '1';
                a_stb_i <= '1';
                wait until clk_i'EVENT and clk_i = '1' and a_ack_o = '1';
                wait until clk_i'EVENT and clk_i = '1' and a_ack_o = '1';
                a_cyc_i <= '0';
                a_cyc_i <= '0';
                a_stb_i <= '0';
                a_stb_i <= '0';
                wait for 20ns;
                wait for 20ns;
                a_cyc_i <= '1';
                a_cyc_i <= '1';
                a_stb_i <= '1';
                a_stb_i <= '1';
                wait until clk_i'EVENT and clk_i = '1' and a_ack_o = '1';
                wait until clk_i'EVENT and clk_i = '1' and a_ack_o = '1';
                a_cyc_i <= '0';
                a_cyc_i <= '0';
                a_stb_i <= '0';
                a_stb_i <= '0';
                -- Request 4 burst reads
                -- Request 4 burst reads
                wait for 100ns;
                wait for 100ns;
                a_cyc_i <= '1';
                a_cyc_i <= '1';
                a_stb_i <= '1';
                a_stb_i <= '1';
                wait until clk_i'EVENT and clk_i = '1' and a_ack_o = '1';
                wait until clk_i'EVENT and clk_i = '1' and a_ack_o = '1';
                wait until clk_i'EVENT and clk_i = '1' and a_ack_o = '1';
                wait until clk_i'EVENT and clk_i = '1' and a_ack_o = '1';
                wait until clk_i'EVENT and clk_i = '1' and a_ack_o = '1';
                wait until clk_i'EVENT and clk_i = '1' and a_ack_o = '1';
                wait until clk_i'EVENT and clk_i = '1' and a_ack_o = '1';
                wait until clk_i'EVENT and clk_i = '1' and a_ack_o = '1';
                a_cyc_i <= '0';
                a_cyc_i <= '0';
                a_stb_i <= '0';
                a_stb_i <= '0';
        end process;
        end process;
 
 
        b_req: process is
        b_req: process is
        begin
        begin
                b_we_i <= '0';
                b_we_i <= '0';
                b_cyc_i <= '0';
                b_cyc_i <= '0';
                b_stb_i <= '0';
                b_stb_i <= '0';
                wait for 120ns;
                wait for 120ns;
                b_cyc_i <= '1';
                b_cyc_i <= '1';
                b_stb_i <= '1';
                b_stb_i <= '1';
                wait until clk_i'EVENT and clk_i = '1' and b_ack_o = '1';
                wait until clk_i'EVENT and clk_i = '1' and b_ack_o = '1';
                b_cyc_i <= '0';
                b_cyc_i <= '0';
                b_stb_i <= '0';
                b_stb_i <= '0';
                wait for 30ns;
                wait for 30ns;
                b_cyc_i <= '1';
                b_cyc_i <= '1';
                b_stb_i <= '1';
                b_stb_i <= '1';
                wait until clk_i'EVENT and clk_i = '1' and b_ack_o = '1';
                wait until clk_i'EVENT and clk_i = '1' and b_ack_o = '1';
                b_cyc_i <= '0';
                b_cyc_i <= '0';
                b_stb_i <= '0';
                b_stb_i <= '0';
                -- Request 4 burst reads
                -- Request 4 burst reads
                wait for 120ns;
                wait for 120ns;
                b_cyc_i <= '1';
                b_cyc_i <= '1';
                b_stb_i <= '1';
                b_stb_i <= '1';
                wait until clk_i'EVENT and clk_i = '1' and b_ack_o = '1';
                wait until clk_i'EVENT and clk_i = '1' and b_ack_o = '1';
                wait until clk_i'EVENT and clk_i = '1' and b_ack_o = '1';
                wait until clk_i'EVENT and clk_i = '1' and b_ack_o = '1';
                wait until clk_i'EVENT and clk_i = '1' and b_ack_o = '1';
                wait until clk_i'EVENT and clk_i = '1' and b_ack_o = '1';
                wait until clk_i'EVENT and clk_i = '1' and b_ack_o = '1';
                wait until clk_i'EVENT and clk_i = '1' and b_ack_o = '1';
                b_cyc_i <= '0';
                b_cyc_i <= '0';
                b_stb_i <= '0';
                b_stb_i <= '0';
        end process;
        end process;
 
 
        pri: process is
        pri: process is
        begin
        begin
                priority <= '0';
                priority <= '0';
                wait for 500ns;
                wait for 500ns;
                priority <= '1';
                priority <= '1';
                wait for 500ns;
                wait for 500ns;
        end process;
        end process;
 
 
end TB;
end TB;
 
 
configuration TB_wb_arbiter of wb_arbiter_tb is
configuration TB_wb_arbiter of wb_arbiter_tb is
        for TB
        for TB
                for UUT : wb_arbiter
                for UUT : wb_arbiter
                        use entity wb_arbiter(FPGA);
                        use entity wb_arbiter(FPGA);
                end for;
                end for;
        end for;
        end for;
end TB_wb_arbiter;
end TB_wb_arbiter;
 
 
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.