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

Subversion Repositories vhdl_wb_tb

[/] [vhdl_wb_tb/] [trunk/] [bench/] [vhdl/] [wishbone_bfm_pkg.vhd] - Diff between revs 14 and 20

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 14 Rev 20
Line 16... Line 16...
----                                                              ---- 
----                                                              ---- 
---------------------------------------------------------------------- 
---------------------------------------------------------------------- 
----    SVN information
----    SVN information
----
----
----      $URL: file:///svn/vhdl_wb_tb/vhdl_wb_tb/trunk/bench/vhdl/wishbone_bfm_pkg.vhd $
----      $URL: file:///svn/vhdl_wb_tb/vhdl_wb_tb/trunk/bench/vhdl/wishbone_bfm_pkg.vhd $
---- $Revision: 14 $
---- $Revision: 20 $
----     $Date: 2018-07-22 16:27:41 +0200 (Sun, 22 Jul 2018) $
----     $Date: 2018-08-01 11:58:41 +0200 (Wed, 01 Aug 2018) $
----   $Author: sinx $
----   $Author: sinx $
----       $Id: wishbone_bfm_pkg.vhd 14 2018-07-22 14:27:41Z sinx $
----       $Id: wishbone_bfm_pkg.vhd 20 2018-08-01 09:58:41Z sinx $
---------------------------------------------------------------------- 
---------------------------------------------------------------------- 
----                                                              ---- 
----                                                              ---- 
---- Copyright (C) 2018 Authors and OPENCORES.ORG                 ---- 
---- Copyright (C) 2018 Authors and OPENCORES.ORG                 ---- 
----                                                              ---- 
----                                                              ---- 
---- This source file may be used and distributed without         ---- 
---- This source file may be used and distributed without         ---- 
Line 114... Line 114...
  procedure wb_write(
  procedure wb_write(
    address_i                  : in  integer; -- address to write to
    address_i                  : in  integer; -- address to write to
    data_i                     : in  integer; -- data value to be written
    data_i                     : in  integer; -- data value to be written
    signal i                   : in  wishbone_bfm_master_in_t; -- incoming wb signals
    signal i                   : in  wishbone_bfm_master_in_t; -- incoming wb signals
    signal o                   : out wishbone_bfm_master_out_t; -- incoming wb signals
    signal o                   : out wishbone_bfm_master_out_t; -- incoming wb signals
    display_error_message_i    : in  integer range 0 to 2 := 1; -- verbose mode; 0=no output, 1=error only, 2= all
    display_error_message_i    : in  integer range 0 to 2 := 1; -- verbose mode; 2= print all activities; others: print nothing
    additional_error_message_i : in  string  := ""
    additional_error_message_i : in  string  := "" -- string to be added in front of generated message
    );
    );
 
 
  -- generate single read cycle and verify read word with expected_data_i
  -- generate single read cycle and verify read word with expected_data_i
  procedure wb_read(
  procedure wb_read(
    address_i                  : in  integer;
    address_i                  : in  integer; -- address to read from
    expected_data_i            : in  integer;
    expected_data_i            : in  integer; -- data to be compared to read data; if different an error message is generated
    signal i                   : in  wishbone_bfm_master_in_t;
    signal i                   : in  wishbone_bfm_master_in_t;  -- incoming wb signals
    signal o                   : out wishbone_bfm_master_out_t;
    signal o                   : out wishbone_bfm_master_out_t; -- outgoing wb signals
    display_error_message_i    : in  integer range 0 to 4 := 1; -- verbose mode; 0=no output, 1=error only, 2= all, 3=use expected_data_mask_i, 4=show difference read to exp.
    display_error_message_i    : in  integer range 0 to 4 := 1; -- verbose mode; 0=no output, 1=error only, 2= all, 3=use expected_data_mask_i, 4=show difference read to exp.
    additional_error_message_i : in  string  := "";
    additional_error_message_i : in  string  := ""; -- string to be added in front of generated message
    expected_data_mask_i       : in  integer := 0
    expected_data_mask_i       : in  integer := 0 -- bit mask for expected_data_i; 0: bis is not compared; 1: bit is compared
    );
    );
 
 
  -- generate single read cycle and return read data via read_data_o
  -- generate single read cycle and return read data via read_data_o
  procedure wb_read(
  procedure wb_read(
    address_i                  : in  integer;
    address_i                  : in  integer; -- address to read from
    read_data_o                : out std_logic_vector (wishbone_address_width_c-1 downto 0);
    read_data_o                : out std_logic_vector (wishbone_data_width_c-1 downto 0); -- read data output
    signal i                   : in  wishbone_bfm_master_in_t;
    signal i                   : in  wishbone_bfm_master_in_t; -- incoming wb signals
    signal o                   : out wishbone_bfm_master_out_t
    signal o                   : out wishbone_bfm_master_out_t -- outgoing wb signals
    );
    );
  ---------------------------------------------------------------------- 
  ---------------------------------------------------------------------- 
end;
end;
 
 
-- package body ------------------------------------------------------
-- package body ------------------------------------------------------
package body wishbone_bfm_pkg is
package body wishbone_bfm_pkg is
  ---------------------------------------------------------------------- 
  ---------------------------------------------------------------------- 
  ---------------------------------------------------------------------- 
  ---------------------------------------------------------------------- 
  procedure wb_write(
  procedure wb_write(
    address_i                  : in  integer;
    address_i                  : in  integer; -- address to write to
    data_i                     : in  integer;
    data_i                     : in  integer; -- data value to be written
    signal i                   : in  wishbone_bfm_master_in_t;
    signal i                   : in  wishbone_bfm_master_in_t; -- incoming wb signals
    signal o                   : out wishbone_bfm_master_out_t;
    signal o                   : out wishbone_bfm_master_out_t; -- outgoing wb signals
    display_error_message_i    : in  integer range 0 to 2 := 1;
    display_error_message_i    : in  integer range 0 to 2 := 1; -- verbose mode; 0=no output, 1=error only, 2= all
    additional_error_message_i : in  string  := ""
    additional_error_message_i : in  string  := "" -- string to be added in front of generated message
    ) is
    ) is
    ---------------------------------------------------------------------- 
    ---------------------------------------------------------------------- 
  begin
  begin
    o.adr       <= to_std_logic_vector(address_i, wishbone_address_width_c);
    o.adr       <= to_std_logic_vector(address_i, wishbone_address_width_c);
    o.dat       <= to_std_logic_vector(data_i, wishbone_address_width_c);
    o.dat       <= to_std_logic_vector(data_i, wishbone_data_width_c);
    o.we        <= '1';
    o.we        <= '1';
    o.rst       <= '0';
    o.rst       <= '0';
    o.tgd       <= (others => '0');
    o.tgd       <= (others => '0');
    o.cyc       <= '1';
    o.cyc       <= '1';
    o.lock      <= '1';
    o.lock      <= '1';
    o.sel       <= (others => '1');
    o.sel       <= (others => '1');
    o.stb       <= '1';
    o.stb       <= '1';
    o.tga       <= (others => '0');
    o.tga       <= (others => '0');
    o.tgc       <= (others => '0');
    o.tgc       <= (others => '0');
    if (display_error_message_i = 2) then
    if (display_error_message_i = 2) then
      report "writing :" & to_string(data_i, 16, wishbone_address_width_c/4) & " to: " & to_string(address_i, 16, wishbone_address_width_c/4) &
      report additional_error_message_i & " writing :" & to_string(data_i, 16, wishbone_data_width_c/4) & " to: " & to_string(address_i, 16, wishbone_address_width_c/4);
        additional_error_message_i;
 
    end if;
    end if;
 
 
    wait until falling_edge(i.clk);
    -- ack handling
    -- wait for ack
    loop
    while i.ack = '0' loop
 
      wait until falling_edge(i.clk);
 
    end loop;
 
    wait until rising_edge(i.clk);
    wait until rising_edge(i.clk);
 
      if (i.ack = '1') then
 
        exit;
 
      end if;
 
    end loop;
    o           <= wb_bfm_master_out_idle_c; -- reset bus
    o           <= wb_bfm_master_out_idle_c; -- reset bus
  end wb_write;
  end wb_write;
  ----------------------------------------------------------------------
  ----------------------------------------------------------------------
  ----------------------------------------------------------------------
  ----------------------------------------------------------------------
  procedure wb_read(
  procedure wb_read(
    address_i   : in  integer;
    address_i   : in  integer;   -- address to read from
    read_data_o : out std_logic_vector (wishbone_address_width_c-1 downto 0);
    read_data_o : out std_logic_vector (wishbone_data_width_c-1 downto 0);-- read data output
    signal i    : in  wishbone_bfm_master_in_t;
    signal i    : in  wishbone_bfm_master_in_t;  -- incoming wb signals
    signal o    : out wishbone_bfm_master_out_t
    signal o    : out wishbone_bfm_master_out_t  -- outgoing wb signals
    ) is
    ) is
    ----------------------------------------------------------------------
    ----------------------------------------------------------------------
  begin
  begin
    o.adr       <= to_std_logic_vector(address_i, wishbone_address_width_c);
    o.adr       <= to_std_logic_vector(address_i, wishbone_address_width_c);
    o.dat       <= (others => 'U');
    o.dat       <= (others => 'U');
Line 198... Line 198...
    o.lock      <= '1';
    o.lock      <= '1';
    o.sel       <= (others => '1');
    o.sel       <= (others => '1');
    o.stb       <= '1';
    o.stb       <= '1';
    o.tga       <= (others => '0');
    o.tga       <= (others => '0');
    o.tgc       <= (others => '0');
    o.tgc       <= (others => '0');
    wait until falling_edge(i.clk);
 
    -- ack handling
    -- ack handling
    while (i.ack = '0') loop
    loop
      wait until falling_edge(i.clk);
 
    end loop;
 
    read_data_o := i.dat;
 
    wait until rising_edge(i.clk);
    wait until rising_edge(i.clk);
 
      read_data_o := i.dat;
 
      if (i.ack = '1') then
 
        exit;
 
      end if;
 
    end loop;
    o           <= wb_bfm_master_out_idle_c; -- reset bus
    o           <= wb_bfm_master_out_idle_c; -- reset bus
  end wb_read;
  end wb_read;
  ------------------------------------------------------------------------
  ------------------------------------------------------------------------
  ------------------------------------------------------------------------
  ------------------------------------------------------------------------
  procedure wb_read(
  procedure wb_read(
    address_i                  : in  integer;
    address_i                  : in  integer; -- address to read from
    expected_data_i            : in  integer;
    expected_data_i            : in  integer; -- data to be compared to read data; if different an error message is generated
    signal i                   : in  wishbone_bfm_master_in_t;
    signal i                   : in  wishbone_bfm_master_in_t; -- incoming wb signals
    signal o                   : out wishbone_bfm_master_out_t;
    signal o                   : out wishbone_bfm_master_out_t; -- outgoing wb signals
    display_error_message_i    : in  integer range 0 to 4 := 1;
    display_error_message_i    : in  integer range 0 to 4 := 1; -- verbose mode; 0=no output, 1=error only, 2= all, 3=use expected_data_mask_i, 4=show difference read to exp.
    additional_error_message_i : in  string  := "";
    additional_error_message_i : in  string  := ""; -- string to be added in front of generated message
    expected_data_mask_i       : in  integer := 0
    expected_data_mask_i       : in  integer := 0 -- bit mask for expected_data_i; 0: bis is not compared; 1: bit is compared
    ) is
    ) is
    ----------------------------------------------------------------------
    ----------------------------------------------------------------------
    variable readdata_v : std_logic_vector (31 downto 0);
    variable readdata_v : std_logic_vector (31 downto 0);
    variable diff_v     : integer;
    variable diff_v     : integer;
    ----------------------------------------------------------------------
    ----------------------------------------------------------------------
Line 228... Line 229...
    wb_read(address_i,readdata_v,i,o); -- read from bus
    wb_read(address_i,readdata_v,i,o); -- read from bus
 
 
    diff_v     := to_integer(readdata_v) - expected_data_i;
    diff_v     := to_integer(readdata_v) - expected_data_i;
 
 
    if (display_error_message_i = 1) then -- output errors only
    if (display_error_message_i = 1) then -- output errors only
      if (readdata_v /= to_std_logic_vector(expected_data_i, wishbone_address_width_c)) then
      if (readdata_v /= to_std_logic_vector(expected_data_i, wishbone_data_width_c)) then
        report "error" & additional_error_message_i & ": expected data at address 0x" & to_string(address_i, 16, wishbone_address_width_c/4) &
        report "error" & additional_error_message_i & ": expected data at address 0x" & to_string(address_i, 16, wishbone_address_width_c/4) &
          " was: 0x" & to_string(expected_data_i, 16, wishbone_address_width_c/4) & " but read: 0x" & to_string(readdata_v,16,wishbone_address_width_c/4)
          " was: 0x" & to_string(expected_data_i, 16, wishbone_data_width_c/4) & " but read: 0x" & to_string(readdata_v,16,wishbone_data_width_c/4)
          severity error;
          severity error;
      end if;
      end if;
    elsif (display_error_message_i = 2) then  -- output all
    elsif (display_error_message_i = 2) then  -- output all
      report additional_error_message_i & ": read data at address 0x" & to_string(address_i, 16, wishbone_address_width_c/4) &
      report additional_error_message_i & ": read data at address 0x" & to_string(address_i, 16, wishbone_address_width_c/4) &
        " was: 0x" & to_string(readdata_v, 16, wishbone_address_width_c/4)
        " was: 0x" & to_string(readdata_v, 16, wishbone_data_width_c/4)
        severity note;
        severity note;
    elsif (display_error_message_i = 3) then  -- output filter
    elsif (display_error_message_i = 3) then  -- output filter
      if ((readdata_v and to_std_logic_vector(expected_data_mask_i, wishbone_address_width_c)) /=
      if ((readdata_v and to_std_logic_vector(expected_data_mask_i, wishbone_data_width_c)) /=
          to_std_logic_vector(expected_data_i, wishbone_address_width_c)) then
          to_std_logic_vector(expected_data_i, wishbone_data_width_c)) then
        report additional_error_message_i & ": read data at address 0x" & to_string(address_i, 16, wishbone_address_width_c/4) &
        report additional_error_message_i & ": read data at address 0x" & to_string(address_i, 16, wishbone_address_width_c/4) &
          " was: 0x" & to_string(readdata_v, 16, wishbone_address_width_c/4)
          " was: 0x" & to_string(readdata_v, 16, wishbone_data_width_c/4)
          severity note;
          severity note;
      end if;
      end if;
    elsif display_error_message_i = 4 then
    elsif display_error_message_i = 4 then
      if (readdata_v /= to_std_logic_vector(expected_data_i, wishbone_address_width_c)) then
      if (readdata_v /= to_std_logic_vector(expected_data_i, wishbone_data_width_c)) then
        report "error" & additional_error_message_i & ": expected data at address 0x" & to_string(address_i, 16, wishbone_address_width_c/4) &
        report "error" & additional_error_message_i & ": expected data at address 0x" & to_string(address_i, 16, wishbone_address_width_c/4) &
          " was: 0x" & to_string(expected_data_i, 16, wishbone_address_width_c/4) & " but read: 0x" & to_string(readdata_v,16,wishbone_address_width_c/4) & " diff: " & to_string(readdata_v,16,wishbone_address_width_c/4)
          " was: 0x" & to_string(expected_data_i, 16, wishbone_data_width_c/4) & " but read: 0x" & to_string(readdata_v,16,wishbone_data_width_c/4) & " diff: " & to_string(readdata_v,16,wishbone_address_width_c/4)
          severity error;
          severity error;
      end if;
      end if;
    end if;
    end if;
  end wb_read;
  end wb_read;
  --------------------------------------------------------------------
  --------------------------------------------------------------------

powered by: WebSVN 2.1.0

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