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

Subversion Repositories pltbutils

[/] [pltbutils/] [trunk/] [src/] [vhdl/] [pltbutils_func_pkg.vhd] - Diff between revs 18 and 24

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

Rev 18 Rev 24
Line 19... Line 19...
---- Author(s):                                                   ----
---- Author(s):                                                   ----
---- - Per Larsson, pela@opencores.org                            ----
---- - Per Larsson, pela@opencores.org                            ----
----                                                              ----
----                                                              ----
----------------------------------------------------------------------
----------------------------------------------------------------------
----                                                              ----
----                                                              ----
---- Copyright (C) 2013 Authors and OPENCORES.ORG                 ----
---- Copyright (C) 2013-2014 Authors and OPENCORES.ORG            ----
----                                                              ----
----                                                              ----
---- This source file may be used and distributed without         ----
---- This source file may be used and distributed without         ----
---- restriction provided that this copyright statement is not    ----
---- restriction provided that this copyright statement is not    ----
---- removed from the file and that any derivative work contains  ----
---- removed from the file and that any derivative work contains  ----
---- the original copyright notice and the associated disclaimer. ----
---- the original copyright notice and the associated disclaimer. ----
Line 47... Line 47...
----------------------------------------------------------------------
----------------------------------------------------------------------
library ieee;
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use ieee.numeric_std.all;
use std.textio.all;
use std.textio.all;
use std.env.all; -- VHDL-2008
 
use work.txt_util.all;
use work.txt_util.all;
use work.pltbutils_type_pkg.all; -- Use for VHDL-2002, comment out for VHDL-93
use work.pltbutils_type_pkg.all; -- Use for VHDL-2002, comment out for VHDL-93
 
use work.pltbutils_user_cfg_pkg.all;
 
 
package pltbutils_func_pkg is
package pltbutils_func_pkg is
 
 
  -- See the package body for a description of the functions and procedures.
  -- See the package body for a description of the functions and procedures.
  constant C_PLTBUTILS_STRLEN  : natural := 80;
  constant C_PLTBUTILS_STRLEN  : natural := 80;
  constant C_PLTBUTILS_TIMEOUT : time    := 10 sec;
  constant C_PLTBUTILS_TIMEOUT : time    := 10 sec;
  constant C_WAIT_BEFORE_STOP_TIME : time := 1 us;
  constant C_WAIT_BEFORE_STOP_TIME : time := 1 us;
 
 
  -- Counters for number of checks and number of errors
  -- Counters for number of checks and number of errors
  -- VHDL-2002:
  -- VHDL-2002:
 
  shared variable v_pltbutils_testcase_name : pltbutils_p_string_t;
 
  shared variable v_pltbutils_testcase_name_len : pltbutils_p_integer_t;
  shared variable v_pltbutils_test_num  : pltbutils_p_integer_t;
  shared variable v_pltbutils_test_num  : pltbutils_p_integer_t;
  shared variable v_pltbutils_test_name : pltbutils_p_string_t;
  shared variable v_pltbutils_test_name : pltbutils_p_string_t;
 
  shared variable v_pltbutils_test_name_len : pltbutils_p_integer_t;
  shared variable v_pltbutils_info      : pltbutils_p_string_t;
  shared variable v_pltbutils_info      : pltbutils_p_string_t;
 
  shared variable v_pltbutils_info_len  : pltbutils_p_integer_t;
 
  shared variable v_pltbutils_test_cnt  : pltbutils_p_integer_t;
  shared variable v_pltbutils_chk_cnt   : pltbutils_p_integer_t;
  shared variable v_pltbutils_chk_cnt   : pltbutils_p_integer_t;
  shared variable v_pltbutils_err_cnt   : pltbutils_p_integer_t;
  shared variable v_pltbutils_err_cnt   : pltbutils_p_integer_t;
 
  shared variable v_pltbutils_chk_cnt_in_test : pltbutils_p_integer_t;
 
  shared variable v_pltbutils_err_cnt_in_test : pltbutils_p_integer_t;
  shared variable v_pltbutils_stop_sim  : pltbutils_p_std_logic_t;
  shared variable v_pltbutils_stop_sim  : pltbutils_p_std_logic_t;
  -- VHDL-1993:
  -- VHDL-1993:
 
  --shared variable v_pltbutils_testcase_name : string(1 to C_PLTBUTILS_STRLEN) := (others => ' ');
 
  --shared variable v_pltbutils_testcase_name_len : integer := 1;
  --shared variable v_pltbutils_test_num  : natural := 0;
  --shared variable v_pltbutils_test_num  : natural := 0;
  --shared variable v_pltbutils_test_name : string(1 to C_PLTBUTILS_STRLEN) := (others => ' ');
  --shared variable v_pltbutils_test_name : string(1 to C_PLTBUTILS_STRLEN) := (others => ' ');
 
  --shared variable v_pltbutils_test_name_len : integer := 1;
  --shared variable v_pltbutils_info      : string(1 to C_PLTBUTILS_STRLEN) := (others => ' ');
  --shared variable v_pltbutils_info      : string(1 to C_PLTBUTILS_STRLEN) := (others => ' ');
 
  --shared variable v_pltbutils_info_len  : integer := 1;
 
  --shared variable v_pltbutils_test_cnt  : natural := 0;
  --shared variable v_pltbutils_chk_cnt   : natural := 0;
  --shared variable v_pltbutils_chk_cnt   : natural := 0;
  --shared variable v_pltbutils_err_cnt   : natural := 0;
  --shared variable v_pltbutils_err_cnt   : natural := 0;
 
  --shared variable v_pltbutils_chk_cnt_in_test : natural := 0;
 
  --shared variable v_pltbutils_err_cnt_in_test : natural := 0;
  --shared variable v_pltbutils_stop_sim  : std_logic := '0';
  --shared variable v_pltbutils_stop_sim  : std_logic := '0';
 
 
  -- Global status- and control signal
  -- Global status- and control signal
  type pltbutils_sc_t is
  type pltbutils_sc_t is
    record
    record
Line 99... Line 113...
    signal   pltbutils_sc        : out pltbutils_sc_t;
    signal   pltbutils_sc        : out pltbutils_sc_t;
    constant show_success_fail   : in   boolean := false;
    constant show_success_fail   : in   boolean := false;
    constant force               : in boolean := false
    constant force               : in boolean := false
  );
  );
 
 
  -- testname
  -- starttest
 
  procedure starttest(
 
    constant num                : in    integer := -1;
 
    constant name               : in    string;
 
    signal   pltbutils_sc       : out   pltbutils_sc_t
 
  );
 
  procedure starttest(
 
    constant name               : in    string;
 
    signal   pltbutils_sc       : out   pltbutils_sc_t
 
  );
 
 
 
  -- testname (depricated)
  procedure testname(
  procedure testname(
    constant num                : in    integer := -1;
    constant num                : in    integer := -1;
    constant name               : in    string;
    constant name               : in    string;
    signal   pltbutils_sc       : out   pltbutils_sc_t
    signal   pltbutils_sc       : out   pltbutils_sc_t
  );
  );
  procedure testname(
  procedure testname(
    constant name               : in    string;
    constant name               : in    string;
    signal   pltbutils_sc       : out   pltbutils_sc_t
    signal   pltbutils_sc       : out   pltbutils_sc_t
  );
  );
 
 
 
  -- endtest
 
  procedure endtest(
 
    signal   pltbutils_sc       : out   pltbutils_sc_t
 
  );
 
 
  -- print, printv, print2
  -- print, printv, print2
  procedure print(
  procedure print(
    constant active             : in    boolean;
    constant active             : in    boolean;
    signal   s                  : out   string;
    signal   s                  : out   string;
    constant txt                : in    string
    constant txt                : in    string
Line 252... Line 282...
  );
  );
 
 
  -- check
  -- check
  procedure check(
  procedure check(
    constant rpt                : in    string;
    constant rpt                : in    string;
    constant data               : in    integer;
    constant actual             : in    integer;
    constant expected           : in    integer;
    constant expected           : in    integer;
    signal   pltbutils_sc       : out   pltbutils_sc_t
    signal   pltbutils_sc       : out   pltbutils_sc_t
  );
  );
  procedure check(
  procedure check(
    constant rpt                : in    string;
    constant rpt                : in    string;
    constant data               : in    std_logic;
    constant actual             : in    std_logic;
    constant expected           : in    std_logic;
    constant expected           : in    std_logic;
    signal   pltbutils_sc       : out   pltbutils_sc_t
    signal   pltbutils_sc       : out   pltbutils_sc_t
  );
  );
  procedure check(
  procedure check(
    constant rpt                : in    string;
    constant rpt                : in    string;
    constant data               : in    std_logic;
    constant actual             : in    std_logic;
    constant expected           : in    integer;
    constant expected           : in    integer;
    signal   pltbutils_sc       : out   pltbutils_sc_t
    signal   pltbutils_sc       : out   pltbutils_sc_t
  );
  );
  procedure check(
  procedure check(
    constant rpt                : in    string;
    constant rpt                : in    string;
    constant data               : in    std_logic_vector;
    constant actual             : in    std_logic_vector;
    constant expected           : in    std_logic_vector;
    constant expected           : in    std_logic_vector;
    signal   pltbutils_sc       : out   pltbutils_sc_t
    signal   pltbutils_sc       : out   pltbutils_sc_t
  );
  );
  procedure check(
  procedure check(
    constant rpt                : in    string;
    constant rpt                : in    string;
    constant data               : in    std_logic_vector;
    constant actual             : in    std_logic_vector;
    constant expected           : in    std_logic_vector;
    constant expected           : in    std_logic_vector;
    constant mask               : in    std_logic_vector;
    constant mask               : in    std_logic_vector;
    signal   pltbutils_sc       : out   pltbutils_sc_t
    signal   pltbutils_sc       : out   pltbutils_sc_t
  );
  );
  procedure check(
  procedure check(
    constant rpt                : in    string;
    constant rpt                : in    string;
    constant data               : in    std_logic_vector;
    constant actual             : in    std_logic_vector;
    constant expected           : in    integer;
    constant expected           : in    integer;
    signal   pltbutils_sc       : out   pltbutils_sc_t
    signal   pltbutils_sc       : out   pltbutils_sc_t
  );
  );
  procedure check(
  procedure check(
    constant rpt                : in    string;
    constant rpt                : in    string;
    constant data               : in    std_logic_vector;
    constant actual             : in    std_logic_vector;
    constant expected           : in    integer;
    constant expected           : in    integer;
    constant mask               : in    std_logic_vector;
    constant mask               : in    std_logic_vector;
    signal   pltbutils_sc       : out   pltbutils_sc_t
    signal   pltbutils_sc       : out   pltbutils_sc_t
  );
  );
  procedure check(
  procedure check(
    constant rpt                : in    string;
    constant rpt                : in    string;
    constant data               : in    unsigned;
    constant actual             : in    unsigned;
    constant expected           : in    unsigned;
    constant expected           : in    unsigned;
    signal   pltbutils_sc       : out   pltbutils_sc_t
    signal   pltbutils_sc       : out   pltbutils_sc_t
  );
  );
  procedure check(
  procedure check(
    constant rpt                : in    string;
    constant rpt                : in    string;
    constant data               : in    unsigned;
    constant actual             : in    unsigned;
    constant expected           : in    integer;
    constant expected           : in    integer;
    signal   pltbutils_sc       : out   pltbutils_sc_t
    signal   pltbutils_sc       : out   pltbutils_sc_t
  );
  );
  procedure check(
  procedure check(
    constant rpt                : in    string;
    constant rpt                : in    string;
    constant data               : in    signed;
    constant actual             : in    signed;
    constant expected           : in    signed;
    constant expected           : in    signed;
    signal   pltbutils_sc       : out   pltbutils_sc_t
    signal   pltbutils_sc       : out   pltbutils_sc_t
  );
  );
  procedure check(
  procedure check(
    constant rpt                : in    string;
    constant rpt                : in    string;
    constant data               : in    signed;
    constant actual             : in    signed;
    constant expected           : in    integer;
    constant expected           : in    integer;
    signal   pltbutils_sc       : out   pltbutils_sc_t
    signal   pltbutils_sc       : out   pltbutils_sc_t
  );
  );
  procedure check(
  procedure check(
    constant rpt                : in    string;
    constant rpt                : in    string;
    constant expr               : in    boolean;
    constant expr               : in    boolean;
    signal   pltbutils_sc       : out   pltbutils_sc_t
    signal   pltbutils_sc       : out   pltbutils_sc_t
  );
  );
 
   procedure check(
 
    constant rpt                : in    string;
 
    constant expr               : in    boolean;
 
    constant actual             : in    string;
 
    constant expected           : in    string;
 
    constant mask               : in    string;
 
    signal   pltbutils_sc       : out   pltbutils_sc_t
 
  );
 
 
  -- to_ascending
  -- to_ascending
  function to_ascending(
  function to_ascending(
    constant s                  : std_logic_vector
    constant s                  : std_logic_vector
  ) return std_logic_vector;
  ) return std_logic_vector;
Line 349... Line 387...
  ) return signed;
  ) return signed;
 
 
  -- hxstr
  -- hxstr
  function hxstr(
  function hxstr(
    constant s                  : std_logic_vector;
    constant s                  : std_logic_vector;
    constant prefix             : string := ""
    constant prefix             : string := "";
 
    constant postfix            : string := ""
  ) return string;
  ) return string;
  function hxstr(
  function hxstr(
    constant s                  : unsigned;
    constant s                  : unsigned;
    constant prefix             : string := ""
    constant prefix             : string := "";
 
    constant postfix            : string := ""
  ) return string;
  ) return string;
  function hxstr(
  function hxstr(
    constant s                  : signed;
    constant s                  : signed;
    constant prefix             : string := ""
    constant prefix             : string := "";
 
    constant postfix            : string := ""
  ) return string;
  ) return string;
 
 
  -- pltbutils internal procedure(s), do not call from user's code
  -- pltbutils internal procedure(s), do not call from user's code
  procedure pltbutils_sc_update(
  procedure pltbutils_sc_update(
    signal pltbutils_sc : out pltbutils_sc_t
    signal pltbutils_sc : out pltbutils_sc_t
  );
  );
 
 
 
  procedure startsim_msg(
 
    constant testcase_name      : in string;
 
    constant timestamp          : in time
 
  );
 
 
 
  procedure endsim_msg(
 
    constant testcase_name      : in string;
 
    constant timestamp          : in time;
 
    constant num_tests          : in integer;
 
    constant num_checks         : in integer;
 
    constant num_errors         : in integer;
 
    constant show_success_fail  : in boolean
 
  );
 
 
 
  procedure starttest_msg(
 
    constant test_num           : in integer;
 
    constant test_name          : in string;
 
    constant timestamp          : in time
 
  );
 
 
 
  procedure endtest_msg(
 
    constant test_num           : in integer;
 
    constant test_name          : in string;
 
    constant timestamp          : in time;
 
    constant num_checks_in_test : in integer;
 
    constant num_errors_in_test : in integer
 
  );
 
 
 
  procedure check_msg(
 
    constant rpt                : in string;
 
    constant expr               : in boolean;
 
    constant actual             : in string;
 
    constant expected           : in string;
 
    constant mask               : in string;
 
    constant test_num           : in integer;
 
    constant test_name          : in string;
 
    constant check_num          : in integer;
 
    constant err_cnt_in_test    : in integer
 
  );
 
 
 
  procedure pltbutils_error(
 
    constant rpt                : in string;
 
    signal   pltbutils_sc       : out   pltbutils_sc_t
 
  );
 
 
 
  procedure error_msg(
 
    constant rpt                : in string;
 
    constant timestamp          : in time;
 
    constant test_num           : in integer;
 
    constant test_name          : in string;
 
    constant err_cnt_in_test    : in integer
 
  );
 
 
 
  procedure stopsim(
 
    constant timestamp          : in time
 
  );
 
 
end package pltbutils_func_pkg;
end package pltbutils_func_pkg;
 
 
package body pltbutils_func_pkg is
package body pltbutils_func_pkg is
 
 
  ----------------------------------------------------------------------------
  ----------------------------------------------------------------------------
Line 404... Line 502...
  procedure startsim(
  procedure startsim(
    constant testcase_name      : in    string;
    constant testcase_name      : in    string;
    signal   pltbutils_sc       : out   pltbutils_sc_t
    signal   pltbutils_sc       : out   pltbutils_sc_t
  ) is
  ) is
    variable dummy : integer;
    variable dummy : integer;
 
    variable timestamp : time;
  begin
  begin
 
    timestamp := now;
 
    if C_PLTBUTILS_USE_STD_STARTSIM_MSG then
 
      startsim_msg(testcase_name, timestamp);
 
    end if;
 
    if C_PLTBUTILS_USE_CUSTOM_STARTSIM_MSG then
 
      custom_startsim_msg(testcase_name, timestamp);
 
    end if;
    printv(v_pltbutils_info, testcase_name);
    printv(v_pltbutils_info, testcase_name);
    print(lf & "--- START OF SIMULATION ---");
 
    print("Testcase: " & testcase_name);
 
    print(time'image(now));
 
    -- VHDL-2002:
    -- VHDL-2002:
 
    v_pltbutils_testcase_name.set(testcase_name);
 
    v_pltbutils_testcase_name_len.set(testcase_name'length);
    v_pltbutils_stop_sim.clr;
    v_pltbutils_stop_sim.clr;
    v_pltbutils_test_num.clr;
    v_pltbutils_test_num.clr;
    v_pltbutils_test_name.set("START OF SIMULATION");
    v_pltbutils_test_name.set("START OF SIMULATION");
 
    v_pltbutils_test_name_len.set(19);
    v_pltbutils_chk_cnt.clr;
    v_pltbutils_chk_cnt.clr;
    v_pltbutils_err_cnt.clr;
    v_pltbutils_err_cnt.clr;
 
    v_pltbutils_chk_cnt_in_test.clr;
 
    v_pltbutils_err_cnt_in_test.clr;
    pltbutils_sc_update(pltbutils_sc);
    pltbutils_sc_update(pltbutils_sc);
    -- VHDL-1993:
    -- VHDL-1993:
    --v_pltbutils_stop_sim := '0';
    --v_pltbutils_stop_sim := '0';
    --v_pltbutils_test_num := 0;
    --v_pltbutils_test_num := 0;
    --printv(v_pltbutils_test_name, "START OF SIMULATION");
    --printv(v_pltbutils_test_name, "START OF SIMULATION");
 
    --v_pltbutils_test_name_len := 19;
    --v_pltbutils_chk_cnt := 0;
    --v_pltbutils_chk_cnt := 0;
    --v_pltbutils_err_cnt := 0;
    --v_pltbutils_err_cnt := 0;
 
    --v_pltbutils_chk_cnt_in_test := 0;
 
    --v_pltbutils_err_cnt_in_test := 0;
    --pltbutils_sc_update(pltbutils_sc);
    --pltbutils_sc_update(pltbutils_sc);
  end procedure startsim;
  end procedure startsim;
 
 
  ----------------------------------------------------------------------------
  ----------------------------------------------------------------------------
  -- endsim
  -- endsim
Line 480... Line 591...
  procedure endsim(
  procedure endsim(
    signal   pltbutils_sc       : out pltbutils_sc_t;
    signal   pltbutils_sc       : out pltbutils_sc_t;
    constant show_success_fail  : in  boolean := false;
    constant show_success_fail  : in  boolean := false;
    constant force              : in  boolean := false
    constant force              : in  boolean := false
  ) is
  ) is
    variable l : line;
    variable timestamp : time;
 
    variable name_len  : integer;
  begin
  begin
    printv(v_pltbutils_info, "");
    timestamp := now;
    print(lf & "--- END OF SIMULATION ---");
    name_len := v_pltbutils_testcase_name_len.value; -- VHDL-2002
    print("Note: the results presented below are based on the PlTbUtil's check() procedure calls.");
    --name_len : v_pltbutils_sc_testcase_name_len; -- VHDL-1993
    print("      The design may contain more errors, for which there are no check() calls.");
    if C_PLTBUTILS_USE_STD_ENDSIM_MSG then
    write(l, now, right, 14);
      -- VHDL-2002:
    writeline(output, l);
      endsim_msg(v_pltbutils_testcase_name.value(1 to name_len),
    write(l, v_pltbutils_chk_cnt.value, right, 11); -- VHDL-2002
        timestamp, v_pltbutils_test_cnt.value, v_pltbutils_chk_cnt.value,
    --write(l, v_pltbutils_chk_cnt, right, 11); -- VHDL-1993
        v_pltbutils_err_cnt.value, show_success_fail);
    write(l, string'(" Checks"));
      -- VHDL-1993:
    writeline(output, l);
      --endsim_msg(v_pltbutils_testcase_name(1 to name_len),
    write(l, v_pltbutils_err_cnt.value, right, 11); -- VHDL-2002
      --  timestamp, v_pltbutils_test_cnt, v_pltbutils_chk_cnt,
    --write(l, v_pltbutils_chk_cnt, right, 11); -- VHDL-1993
      --  v_pltbutils_err_cnt, show_success_fail);
    write(l, string'(" Errors"));
 
    writeline(output, l);
 
 
 
    if show_success_fail then
 
       if v_pltbutils_err_cnt.value = 0 and v_pltbutils_chk_cnt.value > 0 then -- VHDL-2002
 
       --if v_pltbutils_err_cnt = 0 and v_pltbutils_chk_cnt > 0 then -- VHDL-1993
 
        print("*** SUCCESS ***");
 
      elsif v_pltbutils_chk_cnt.value > 0 then -- VHDL-2002
 
      --elsif v_pltbutils_chk_cnt > 0 then -- VHDL-1993
 
        print("*** FAIL ***");
 
      else
 
        print("*** NO CHECKS ***");
 
      end if;
      end if;
 
    if C_PLTBUTILS_USE_CUSTOM_ENDSIM_MSG then
 
      -- VHDL-2002:
 
      custom_endsim_msg(v_pltbutils_testcase_name.value(1 to name_len),
 
        timestamp, v_pltbutils_test_cnt.value, v_pltbutils_chk_cnt.value,
 
        v_pltbutils_err_cnt.value, show_success_fail);
 
      -- VHDL-1993:
 
      --custom_endsim_msg(v_pltbutils_testcase_name(1 to name_len),
 
      --  timestamp, v_pltbutils_test_cnt, v_pltbutils_chk_cnt,
 
      --  v_pltbutils_err_cnt, show_success_fail);
    end if;
    end if;
 
    printv(v_pltbutils_info, "");
    -- VHDL-2002:
    -- VHDL-2002:
    v_pltbutils_stop_sim.set('1');
    v_pltbutils_stop_sim.set('1');
    v_pltbutils_test_num.clr;
    v_pltbutils_test_num.clr;
    v_pltbutils_test_name.set("END OF SIMULATION");
    v_pltbutils_test_name.set("END OF SIMULATION");
 
    v_pltbutils_test_name_len.set(17);
    -- VHDL-1993:
    -- VHDL-1993:
    --v_pltbutils_stop_sim := '1';
    --v_pltbutils_stop_sim := '1';
    --v_pltbutils_test_num := 0;
    --v_pltbutils_test_num := 0;
    --printv(v_pltbutils_test_name, "END OF SIMULATION");
    --printv(v_pltbutils_test_name, "END OF SIMULATION");
 
    --v_pltbutils_test_name_len := 17;
    pltbutils_sc_update(pltbutils_sc);
    pltbutils_sc_update(pltbutils_sc);
    wait for C_WAIT_BEFORE_STOP_TIME;
    wait for C_WAIT_BEFORE_STOP_TIME;
    stop(0); -- VHDL-2008
    if force then
    assert not force
      if C_PLTBUTILS_USE_STD_STOPSIM then
    report "--- FORCE END OF SIMULATION ---" &
        stopsim(now);
           " (ignore this false failure message, it's not a real failure)"
      end if;
    severity failure;
      if C_PLTBUTILS_USE_CUSTOM_STOPSIM then
 
        custom_stopsim(now);
 
      end if;
 
    end if;
    wait;
    wait;
  end procedure endsim;
  end procedure endsim;
 
 
  ----------------------------------------------------------------------------
  ----------------------------------------------------------------------------
  -- testname
  -- starttest
  --
  --
  -- procedure testname(
  -- procedure starttest(
  --   constant num                : in    integer := -1;
  --   constant num                : in    integer := -1;
  --   constant name               : in    string;
  --   constant name               : in    string;
  --   signal   pltbutils_sc       : out   pltbutils_sc_t
  --   signal   pltbutils_sc       : out   pltbutils_sc_t
  -- ) 
  -- ) 
  --
  --
Line 556... Line 671...
  -- computed by incrementing the current test number. 
  -- computed by incrementing the current test number. 
  -- Manually setting the test number may make it easier to find the test code
  -- Manually setting the test number may make it easier to find the test code
  -- in the testbench code, though.
  -- in the testbench code, though.
  --
  --
  -- Examples:
  -- Examples:
  -- testname("Reset test", pltbutils_sc);
  -- starttest("Reset test", pltbutils_sc);
  -- testname(1, "Reset test", pltbutils_sc);
  -- starttest(1, "Reset test", pltbutils_sc);
  ----------------------------------------------------------------------------
  ----------------------------------------------------------------------------
  procedure testname(
  procedure starttest(
    constant num                : in    integer := -1;
    constant num                : in    integer := -1;
    constant name               : in    string;
    constant name               : in    string;
    signal   pltbutils_sc       : out   pltbutils_sc_t
    signal   pltbutils_sc       : out   pltbutils_sc_t
  ) is
  ) is
 
    variable timestamp : time;
  begin
  begin
 
    timestamp := now;
    -- VHDL-2002:
    -- VHDL-2002:
    if num = -1 then
    if num = -1 then
      v_pltbutils_test_num.inc;
      v_pltbutils_test_num.inc;
    else
    else
      v_pltbutils_test_num.set(num);
      v_pltbutils_test_num.set(num);
    end if;
    end if;
 
    v_pltbutils_test_cnt.inc;
    v_pltbutils_test_name.set(name);
    v_pltbutils_test_name.set(name);
 
    v_pltbutils_test_name_len.set(name'length);
 
    v_pltbutils_err_cnt_in_test.clr;
    pltbutils_sc_update(pltbutils_sc);
    pltbutils_sc_update(pltbutils_sc);
    print(lf & "Test " & str(v_pltbutils_test_num.value) & ": " & name);
    if C_PLTBUTILS_USE_STD_STARTTEST_MSG then
 
      starttest_msg(v_pltbutils_test_num.value, name, timestamp);
 
    end if;
 
    if C_PLTBUTILS_USE_CUSTOM_STARTTEST_MSG then
 
      custom_starttest_msg(v_pltbutils_test_num.value, name, timestamp);
 
    end if;
 
 
    -- VHDL-1993:
    -- VHDL-1993:
    --if num = -1 then
    --if num = -1 then
    --  b_pltbutils_test_num := v_pltbutils_test_num + 1;
    --  b_pltbutils_test_num := v_pltbutils_test_num + 1;
    --else
    --else
    --  v_pltbutils_test_num  := num;
    --  v_pltbutils_test_num  := num;
    --end if;
    --end if;
 
    --v_pltbutils_test_cnt := v_pltbutils_test_cnt + 1;
    --printv(v_pltbutils_test_name, name);
    --printv(v_pltbutils_test_name, name);
 
    --v_pltbutils_test_name_len := name'length;
 
    --v_pltbutils_err_cnt_in_test := 0;
    --pltbutils_sc_update(pltbutils_sc);
    --pltbutils_sc_update(pltbutils_sc);
    --print("Test " & str(v_pltbutils_test_num) & ": " & name);
    --if C_PLTBUTILS_USE_STD_STARTTEST_MSG then
 
    --  starttest_msg(v_pltbutils_test_num, name, timestamp);
 
    --end if;
 
    --if C_PLTBUTILS_USE_CUSTOM_STARTTEST_MSG then
 
    --  custom_starttest_msg(v_pltbutils_test_num, name, timestamp);
 
    --end if;
 
  end procedure starttest;
 
 
 
  procedure starttest(
 
    constant name               : in    string;
 
    signal   pltbutils_sc       : out   pltbutils_sc_t
 
  ) is
 
  begin
 
    starttest(-1, name, pltbutils_sc);
 
  end procedure starttest;
 
 
 
  -- Depricated. Will be removed. Use starttest() instead.
 
  procedure testname(
 
    constant num                : in    integer := -1;
 
    constant name               : in    string;
 
    signal   pltbutils_sc       : out   pltbutils_sc_t
 
  ) is
 
  begin
 
    starttest(num, name, pltbutils_sc);
  end procedure testname;
  end procedure testname;
 
 
 
  -- Depricated. Will be removed. Use starttest() instead.
  procedure testname(
  procedure testname(
    constant name               : in    string;
    constant name               : in    string;
    signal   pltbutils_sc       : out   pltbutils_sc_t
    signal   pltbutils_sc       : out   pltbutils_sc_t
  ) is
  ) is
  begin
  begin
    testname(-1, name, pltbutils_sc);
    testname(-1, name, pltbutils_sc);
  end procedure testname;
  end procedure testname;
 
 
  ----------------------------------------------------------------------------
  ----------------------------------------------------------------------------
 
  -- endtest
 
  --
 
  -- procedure endtest(
 
  --   signal   pltbutils_sc       : out   pltbutils_sc_t
 
  -- ) 
 
  --
 
  -- Prints an end-of-test message to the screen.
 
  --
 
  -- Arguments: 
 
  --   pltbutils_sc             PlTbUtils' global status- and control signal.
 
  --                            Must be set to pltbutils_sc.
 
  --
 
  -- Example:
 
  -- endtest(pltbutils_sc);
 
  ----------------------------------------------------------------------------
 
  procedure endtest(
 
    signal   pltbutils_sc       : out   pltbutils_sc_t
 
  ) is
 
    variable timestamp : time;
 
    variable v_name_len : integer;
 
  begin
 
    timestamp := now;
 
    -- Uncommented for VHDL-2002 Protected types, otherwise commented:
 
    v_name_len := v_pltbutils_test_name_len.value; -- VHDL-2002
 
    if C_PLTBUTILS_USE_STD_ENDTEST_MSG then
 
      endtest_msg(v_pltbutils_test_num.value, v_pltbutils_test_name.value(1 to v_name_len),
 
        timestamp, v_pltbutils_chk_cnt_in_test.value, v_pltbutils_err_cnt_in_test.value);
 
    end if;
 
    if C_PLTBUTILS_USE_CUSTOM_ENDTEST_MSG then
 
      custom_endtest_msg(v_pltbutils_test_num.value, v_pltbutils_test_name.value(1 to v_name_len),
 
        timestamp, v_pltbutils_chk_cnt_in_test.value, v_pltbutils_err_cnt_in_test.value);
 
    end if;
 
    -- Uncommented for not using VHDL-2002 Protected Types, otherwise commented:
 
    --name_len := v_pltbutils_test_name_len; -- VHDL-1993
 
    --if C_PLTBUTILS_USE_STD_ENDTEST_MSG then
 
    --  endtest_msg(v_pltbutils_test_num, v_pltbutils_test_name(1 to v_name_len),
 
    --    timestamp, v_pltbutils_chk_cnt_in_test, v_pltbutils_err_cnt_in_test);
 
    --end if;  
 
    --if C_PLTBUTILS_USE_CUSTOM_ENDTEST_MSG then
 
    --  custom_endtest_msg(v_pltbutils_test_num, v_pltbutils_test_name(1 to v_name_len),
 
    --    timestamp, v_pltbutils_chk_cnt_in_test, v_pltbutils_err_cnt_in_test);
 
    --end if;  
 
 
 
    printv(v_pltbutils_test_name, " ");
 
    pltbutils_sc_update(pltbutils_sc);
 
  end procedure endtest;
 
 
 
  ----------------------------------------------------------------------------
  -- print printv print2
  -- print printv print2
  --
  --
  -- procedure print(   
  -- procedure print(   
  --   signal   s                  : out   string;
  --   signal   s                  : out   string;
  --   constant txt                : in    string
  --   constant txt                : in    string
Line 872... Line 1073...
        wait until rising_edge(clk)  for timeout / n;
        wait until rising_edge(clk)  for timeout / n;
      end if;
      end if;
      i := i - 1;
      i := i - 1;
    end loop;
    end loop;
    if now >= v_timeout_time then
    if now >= v_timeout_time then
      assert false
      pltbutils_error("waitclks() timeout", pltbutils_sc);
      report "waitclks() timeout"
 
      severity error;
 
      v_pltbutils_err_cnt.inc; -- VHDL-2002
 
      --v_pltbutils_err_cnt := v_pltbutils_err_cnt + 1; -- VHDL-1993
 
      pltbutils_sc_update(pltbutils_sc);
 
    end if;
    end if;
  end procedure waitclks;
  end procedure waitclks;
 
 
  ----------------------------------------------------------------------------
  ----------------------------------------------------------------------------
  -- waitsig
  -- waitsig
Line 936... Line 1132...
    l1 : loop
    l1 : loop
      waitclks(1, clk, pltbutils_sc, falling, timeout);
      waitclks(1, clk, pltbutils_sc, falling, timeout);
      exit l1 when s = value or now >= v_timeout_time;
      exit l1 when s = value or now >= v_timeout_time;
    end loop;
    end loop;
    if now >= v_timeout_time then
    if now >= v_timeout_time then
      assert false
      pltbutils_error("waitsig() timeout", pltbutils_sc);
      report "waitsig() timeout"
 
      severity error;
 
      v_pltbutils_err_cnt.inc; -- VHDL-2002
 
      --v_pltbutils_err_cnt := v_pltbutils_err_cnt + 1; -- VHDL-1993
 
      pltbutils_sc_update(pltbutils_sc);
 
    end if;
    end if;
  end procedure waitsig;
  end procedure waitsig;
 
 
  procedure waitsig(
  procedure waitsig(
    signal   s                  : in    std_logic;
    signal   s                  : in    std_logic;
Line 961... Line 1152...
    l1 : loop
    l1 : loop
      waitclks(1, clk, pltbutils_sc, falling, timeout);
      waitclks(1, clk, pltbutils_sc, falling, timeout);
      exit l1 when s = value or now >= v_timeout_time;
      exit l1 when s = value or now >= v_timeout_time;
    end loop;
    end loop;
    if now >= v_timeout_time then
    if now >= v_timeout_time then
      assert false
      pltbutils_error("waitsig() timeout", pltbutils_sc);
      report "waitsig() timeout"
 
      severity error;
 
      v_pltbutils_err_cnt.inc; -- VHDL-2002
 
      --v_pltbutils_err_cnt := v_pltbutils_err_cnt + 1; -- VHDL-1993
 
      pltbutils_sc_update(pltbutils_sc);
 
    end if;
    end if;
  end procedure waitsig;
  end procedure waitsig;
 
 
  procedure waitsig(
  procedure waitsig(
    signal   s                  : in    std_logic;
    signal   s                  : in    std_logic;
Line 990... Line 1176...
    end case;
    end case;
    if v_value /= 'X' then
    if v_value /= 'X' then
      waitsig(s, v_value, clk,
      waitsig(s, v_value, clk,
              pltbutils_sc, falling, timeout);
              pltbutils_sc, falling, timeout);
    else
    else
      assert false
      pltbutils_error("waitsig() timeout", pltbutils_sc);
        report "waitsig() illegal value to wait for: " & integer'image(value)
 
        severity error;
 
      v_pltbutils_err_cnt.inc; -- VHDL-2002
 
      --v_pltbutils_err_cnt := v_pltbutils_err_cnt + 1; -- VHDL-1993
 
      pltbutils_sc_update(pltbutils_sc);
 
    end if;
    end if;
  end procedure waitsig;
  end procedure waitsig;
 
 
  procedure waitsig(
  procedure waitsig(
    signal   s                  : in    std_logic_vector;
    signal   s                  : in    std_logic_vector;
Line 1015... Line 1196...
    l1 : loop
    l1 : loop
      waitclks(1, clk, pltbutils_sc, falling, timeout);
      waitclks(1, clk, pltbutils_sc, falling, timeout);
      exit l1 when s = value or now >= v_timeout_time;
      exit l1 when s = value or now >= v_timeout_time;
    end loop;
    end loop;
    if now >= v_timeout_time then
    if now >= v_timeout_time then
      assert false
      pltbutils_error("waitsig() timeout", pltbutils_sc);
      report "waitsig() timeout"
 
      severity error;
 
      v_pltbutils_err_cnt.inc; -- VHDL-2002
 
      --v_pltbutils_err_cnt := v_pltbutils_err_cnt + 1; -- VHDL-1993
 
      pltbutils_sc_update(pltbutils_sc);
 
    end if;
    end if;
  end procedure waitsig;
  end procedure waitsig;
 
 
  procedure waitsig(
  procedure waitsig(
    signal   s                  : in    std_logic_vector;
    signal   s                  : in    std_logic_vector;
Line 1054... Line 1230...
    l1 : loop
    l1 : loop
      waitclks(1, clk, pltbutils_sc, falling, timeout);
      waitclks(1, clk, pltbutils_sc, falling, timeout);
      exit l1 when s = value or now >= v_timeout_time;
      exit l1 when s = value or now >= v_timeout_time;
    end loop;
    end loop;
    if now >= v_timeout_time then
    if now >= v_timeout_time then
      assert false
      pltbutils_error("waitsig() timeout", pltbutils_sc);
      report "waitsig() timeout"
 
      severity error;
 
      v_pltbutils_err_cnt.inc; -- VHDL-2002
 
      --v_pltbutils_err_cnt := v_pltbutils_err_cnt + 1; -- VHDL-1993
 
      pltbutils_sc_update(pltbutils_sc);
 
    end if;
    end if;
  end procedure waitsig;
  end procedure waitsig;
 
 
  procedure waitsig(
  procedure waitsig(
    signal   s                  : in    unsigned;
    signal   s                  : in    unsigned;
Line 1093... Line 1264...
    l1 : loop
    l1 : loop
      waitclks(1, clk, pltbutils_sc, falling, timeout);
      waitclks(1, clk, pltbutils_sc, falling, timeout);
      exit l1 when s = value or now >= v_timeout_time;
      exit l1 when s = value or now >= v_timeout_time;
    end loop;
    end loop;
    if now >= v_timeout_time then
    if now >= v_timeout_time then
      assert false
      pltbutils_error("waitsig() timeout", pltbutils_sc);
      report "waitsig() timeout"
 
      severity error;
 
      v_pltbutils_err_cnt.inc; -- VHDL-2002
 
      --v_pltbutils_err_cnt := v_pltbutils_err_cnt + 1; -- VHDL-1993
 
      pltbutils_sc_update(pltbutils_sc);
 
    end if;
    end if;
  end procedure waitsig;
  end procedure waitsig;
 
 
  procedure waitsig(
  procedure waitsig(
    signal   s                  : in    signed;
    signal   s                  : in    signed;
Line 1121... Line 1287...
  ----------------------------------------------------------------------------
  ----------------------------------------------------------------------------
  -- check
  -- check
  --
  --
  -- procedure check(
  -- procedure check(
  --  constant rpt              : in    string;
  --  constant rpt              : in    string;
  --  constant data             : in    integer|std_logic|std_logic_vector|unsigned|signed;
  --  constant actual           : in    integer|std_logic|std_logic_vector|unsigned|signed;
  --  constant expected         : in    integer|std_logic|std_logic_vector|unsigned|signed;
  --  constant expected         : in    integer|std_logic|std_logic_vector|unsigned|signed;
  --  signal   pltbutils_sc     : out   pltbutils_sc_t
  --  signal   pltbutils_sc     : out   pltbutils_sc_t
  --  )
  --  )
  --
  --
  -- procedure check(
  -- procedure check(
  --  constant rpt              : in    string;
  --  constant rpt              : in    string;
  --  constant data             : in    std_logic_vector;
  --  constant actual           : in    std_logic_vector;
  --  constant expected         : in    std_logic_vector;
  --  constant expected         : in    std_logic_vector;
  --  constant mask             : in    std_logic_vector;
  --  constant mask             : in    std_logic_vector;
  --  signal   pltbutils_sc     : out   pltbutils_sc_t
  --  signal   pltbutils_sc     : out   pltbutils_sc_t
  --  )
  --  )
  --
  --
Line 1153... Line 1319...
  --                            or variable being checked. 
  --                            or variable being checked. 
  --                            The message should NOT contain the expected 
  --                            The message should NOT contain the expected 
  --                            value, becase check() prints that 
  --                            value, becase check() prints that 
  --                            automatically.
  --                            automatically.
  --
  --
  --   data                     The signal or variable to be checked.
  --   actual                   The signal or variable to be checked.
  --                            Supported types: integer, std_logic, 
  --                            Supported types: integer, std_logic, 
  --                            std_logic_vector, unsigned, signed.
  --                            std_logic_vector, unsigned, signed.
  --
  --
  --   expected                 Expected value. 
  --   expected                 Expected value. 
  --                            Same type as data or integer.
  --                            Same type as data or integer.
Line 1182... Line 1348...
  -- check("Counter after data burst", cnt_o > 10, pltbutils_sc);
  -- check("Counter after data burst", cnt_o > 10, pltbutils_sc);
  ----------------------------------------------------------------------------
  ----------------------------------------------------------------------------
  -- check integer
  -- check integer
  procedure check(
  procedure check(
    constant rpt                : in    string;
    constant rpt                : in    string;
    constant data               : in    integer;
    constant actual             : in    integer;
    constant expected           : in    integer;
    constant expected           : in    integer;
    signal   pltbutils_sc       : out   pltbutils_sc_t
    signal   pltbutils_sc       : out   pltbutils_sc_t
  ) is
  ) is
  begin
  begin
    v_pltbutils_chk_cnt.inc; -- VHDL-2002
    check(rpt, actual = expected, str(actual), str(expected), "", pltbutils_sc);
    --v_pltbutils_chk_cnt := v_pltbutils_chk_cnt + 1; -- VHDL-1993
 
    if data   /= expected then
 
      assert false
 
      report "Check " &
 
             str(v_pltbutils_chk_cnt.value) & -- VHDL-2002
 
             --str(v_pltbutils_chk_cnt) & -- VHDL-1993
 
             "; " & rpt &
 
             "; Data=" & str(data) &
 
             " Expected=" & str(expected) &
 
             " " & --str(character'(lf)) &
 
             "  in test " &
 
             str(v_pltbutils_test_num.value) & -- VHDL-2002
 
             --str(v_pltbutils_test_num) & -- VHDL-1993
 
             " " &
 
             v_pltbutils_test_name.value -- VHDL-2002
 
             --v_pltbutils_test_name -- VHDL-1993
 
      severity error;
 
      v_pltbutils_err_cnt.inc; -- VHLD-2002
 
      --v_pltbutils_err_cnt := v_pltbutils_err_cnt + 1; -- VHDL-1993
 
    end if;
 
    pltbutils_sc_update(pltbutils_sc);
 
  end procedure check;
  end procedure check;
 
 
  -- check std_logic
  -- check std_logic
  procedure check(
  procedure check(
    constant rpt                : in    string;
    constant rpt                : in    string;
    constant data               : in    std_logic;
    constant actual             : in    std_logic;
    constant expected           : in    std_logic;
    constant expected           : in    std_logic;
    signal   pltbutils_sc       : out   pltbutils_sc_t
    signal   pltbutils_sc       : out   pltbutils_sc_t
  ) is
  ) is
  begin
  begin
    v_pltbutils_chk_cnt.inc; -- VHDL-2002
    check(rpt, actual = expected, str(actual), str(expected), "", pltbutils_sc);
    --v_pltbutils_chk_cnt := v_pltbutils_chk_cnt + 1; -- VHDL-1993
 
    if data /= expected   then
 
      assert false
 
      report "Check " &
 
             str(v_pltbutils_chk_cnt.value) & -- VHDL-2002
 
             --str(v_pltbutils_chk_cnt) & -- VHDL-1993
 
             "; " & rpt   &
 
             "; Data=" & str(data) &
 
             " Expected=" & str(expected) &
 
             " " & --str(character'(lf)) &
 
             "  in test " &
 
             str(v_pltbutils_test_num.value) & -- VHDL-2002
 
             --str(v_pltbutils_test_num) & -- VHDL-1993
 
             " " &
 
             v_pltbutils_test_name.value -- VHDL-2002
 
             --v_pltbutils_test_name -- VHDL-1993
 
      severity error;
 
      v_pltbutils_err_cnt.inc; -- VHLD-2002
 
      --v_pltbutils_err_cnt := v_pltbutils_err_cnt + 1; -- VHDL-1993
 
    end if;
 
    pltbutils_sc_update(pltbutils_sc);
 
  end procedure check;
  end procedure check;
 
 
  -- check std_logic against integer
  -- check std_logic against integer
  procedure check(
  procedure check(
    constant rpt                : in    string;
    constant rpt                : in    string;
    constant data               : in    std_logic;
    constant actual             : in    std_logic;
    constant expected           : in    integer;
    constant expected           : in    integer;
    signal   pltbutils_sc       : out   pltbutils_sc_t
    signal   pltbutils_sc       : out   pltbutils_sc_t
  ) is
  ) is
    variable v_expected : std_logic;
   -- variable v_expected : std_logic;
 
    --variable equal : boolean;   
  begin
  begin
    if expected = 0 then
    check(rpt, ((actual = '0' and expected = 0) or (actual = '1' and expected = 1)),
      check(rpt , data, std_logic'('0'), pltbutils_sc);
          str(actual), str(expected), "", pltbutils_sc);
    elsif expected = 1 then
 
      check(rpt , data, std_logic'('1'), pltbutils_sc);
 
    else
 
      v_pltbutils_chk_cnt.inc; -- VHDL-2002
 
      --v_pltbutils_chk_cnt := v_pltbutils_chk_cnt + 1; -- VHDL-1993
 
      assert false
 
      report "Check " &
 
             str(v_pltbutils_chk_cnt.value) & -- VHDL-2002
 
             --str(v_pltbutils_chk_cnt) & -- VHDL-1993
 
             "; " & rpt &
 
             "; Data=" & str(data) &
 
             " Expected=" & str(expected) &
 
             " " & --str(character'(lf)) &
 
             "  in test " &
 
             str(v_pltbutils_test_num.value) & -- VHDL-2002
 
             --str(v_pltbutils_test_num) & -- VHDL-1993
 
             " " &
 
             v_pltbutils_test_name.value -- VHDL-2002
 
             --v_pltbutils_test_name -- VHDL-1993
 
      severity error;
 
      v_pltbutils_err_cnt.inc; -- VHLD-2002
 
      --v_pltbutils_err_cnt := v_pltbutils_err_cnt + 1; -- VHDL-1993
 
      pltbutils_sc_update(pltbutils_sc);
 
    end if;
 
  end procedure check;
  end procedure check;
 
 
  -- check std_logic_vector
  -- check std_logic_vector
  procedure check(
  procedure check(
    constant rpt                : in    string;
    constant rpt                : in    string;
    constant data               : in    std_logic_vector;
    constant actual             : in    std_logic_vector;
    constant expected           : in    std_logic_vector;
    constant expected           : in    std_logic_vector;
    signal   pltbutils_sc       : out   pltbutils_sc_t
    signal   pltbutils_sc       : out   pltbutils_sc_t
  ) is
  ) is
  begin
  begin
    v_pltbutils_chk_cnt.inc; -- VHDL-2002
    check(rpt, actual = expected, hxstr(actual, "0x"), hxstr(expected, "0x"), "", pltbutils_sc);
    --v_pltbutils_chk_cnt := v_pltbutils_chk_cnt + 1; -- VHDL-1993
 
    if data   /= expected   then
 
      assert false
 
      report "Check " &
 
             str(v_pltbutils_chk_cnt.value) & -- VHDL-2002
 
             --str(v_pltbutils_chk_cnt) & -- VHDL-1993
 
             "; " & rpt   &
 
             "; Data=" & hxstr(data, "0x") &
 
             " Expected=" & hxstr(expected, "0x") &
 
             " " & --str('lf') &
 
             "  in test " &
 
             str(v_pltbutils_test_num.value) & -- VHDL-2002
 
             --str(v_pltbutils_test_num) & -- VHDL-1993
 
             " " &
 
             v_pltbutils_test_name.value -- VHDL-2002
 
             --v_pltbutils_test_name -- VHDL-1993
 
      severity error;
 
      v_pltbutils_err_cnt.inc; -- VHDL-2002
 
      --v_pltbutils_err_cnt := v_pltbutils_err_cnt + 1; -- VHDL-1993
 
    end if;
 
    pltbutils_sc_update(pltbutils_sc);
 
  end procedure check;
  end procedure check;
 
 
  -- check std_logic_vector with mask
  -- check std_logic_vector with mask
  procedure check(
  procedure check(
    constant rpt                : in    string;
    constant rpt                : in    string;
    constant data               : in    std_logic_vector;
    constant actual             : in    std_logic_vector;
    constant expected           : in    std_logic_vector;
    constant expected           : in    std_logic_vector;
    constant mask               : in    std_logic_vector;
    constant mask               : in    std_logic_vector;
    signal   pltbutils_sc       : out   pltbutils_sc_t
    signal   pltbutils_sc       : out   pltbutils_sc_t
  ) is
  ) is
  begin
  begin
    v_pltbutils_chk_cnt.inc; -- VHDL-2002
    check(rpt, (actual and mask) = (expected and mask),
    --v_pltbutils_chk_cnt := v_pltbutils_chk_cnt + 1; -- VHDL-1993
          hxstr(actual, "0x"), hxstr(expected, "0x"), hxstr(mask, "0x"), pltbutils_sc);
    if (data  and mask) /= (expected and mask) then
 
      assert false
 
      report "Check " &
 
             str(v_pltbutils_chk_cnt.value) & -- VHDL-2002
 
             --str(v_pltbutils_chk_cnt) & -- VHDL-1993
 
             "; " & rpt &
 
             "; Data=" & hxstr(data, "0x") &
 
             " Expected=" & hxstr(expected, "0x") &
 
             " Mask=" & hxstr(mask, "0x") &
 
             " " & --str('lf') &
 
             "  in test " &
 
             str(v_pltbutils_test_num.value) & -- VHDL-2002
 
             --str(v_pltbutils_test_num) & -- VHDL-1993
 
             " " &
 
             v_pltbutils_test_name.value -- VHDL-2002
 
             --v_pltbutils_test_name -- VHDL-1993
 
      severity error;
 
      v_pltbutils_err_cnt.inc; -- VHDL-2002
 
      --v_pltbutils_err_cnt := v_pltbutils_err_cnt + 1; -- VHDL-1993
 
    end if;
 
    pltbutils_sc_update(pltbutils_sc);
 
  end procedure check;
  end procedure check;
 
 
  -- check std_logic_vector against integer
  -- check std_logic_vector against integer
  procedure check(
  procedure check(
    constant rpt                : in    string;
    constant rpt                : in    string;
    constant data               : in    std_logic_vector;
    constant actual             : in    std_logic_vector;
    constant expected           : in    integer;
    constant expected           : in    integer;
    signal   pltbutils_sc       : out   pltbutils_sc_t
    signal   pltbutils_sc       : out   pltbutils_sc_t
  ) is
  ) is
  begin
  begin
    check(rpt, data, std_logic_vector(to_signed(expected, data'length)), pltbutils_sc);
    check(rpt, actual, std_logic_vector(to_signed(expected, actual'length)), pltbutils_sc);
  end procedure check;
  end procedure check;
 
 
  -- check std_logic_vector with mask against integer
  -- check std_logic_vector with mask against integer
  procedure check(
  procedure check(
    constant rpt                : in    string;
    constant rpt                : in    string;
    constant data               : in    std_logic_vector;
    constant actual             : in    std_logic_vector;
    constant expected           : in    integer;
    constant expected           : in    integer;
    constant mask               : in    std_logic_vector;
    constant mask               : in    std_logic_vector;
    signal   pltbutils_sc       : out   pltbutils_sc_t
    signal   pltbutils_sc       : out   pltbutils_sc_t
  ) is
  ) is
  begin
  begin
    check(rpt, data, std_logic_vector(to_signed(expected, data'length)), mask, pltbutils_sc);
    check(rpt, actual, std_logic_vector(to_signed(expected, actual'length)), mask, pltbutils_sc);
  end procedure check;
  end procedure check;
 
 
  -- check unsigned
  -- check unsigned
  procedure check(
  procedure check(
    constant rpt                : in    string;
    constant rpt                : in    string;
    constant data               : in    unsigned;
    constant actual             : in    unsigned;
    constant expected           : in    unsigned;
    constant expected           : in    unsigned;
    signal   pltbutils_sc       : out   pltbutils_sc_t
    signal   pltbutils_sc       : out   pltbutils_sc_t
  ) is
  ) is
  begin
  begin
    v_pltbutils_chk_cnt.inc; -- VHDL-2002
    check(rpt, actual = expected, hxstr(actual, "0x"), hxstr(expected, "0x"), "", pltbutils_sc);
    --v_pltbutils_chk_cnt := v_pltbutils_chk_cnt + 1; -- VHDL-1993
 
    if data   /= expected   then
 
      assert false
 
      report "Check " &
 
             str(v_pltbutils_chk_cnt.value) & -- VHDL-2002
 
             --str(v_pltbutils_chk_cnt) & -- VHDL-1993
 
             "; " & rpt   &
 
             "; Data=" & hxstr(data, "0x") &
 
             " Expected=" & hxstr(expected, "0x") &
 
             " " & --str('lf') &
 
             "  in test " &
 
             str(v_pltbutils_test_num.value) & -- VHDL-2002
 
             --str(v_pltbutils_test_num) & -- VHDL-1993
 
             " " &
 
             v_pltbutils_test_name.value -- VHDL-2002
 
             --v_pltbutils_test_name -- VHDL-1993
 
      severity error;
 
      v_pltbutils_err_cnt.inc; -- VHDL-2002
 
      --v_pltbutils_err_cnt := v_pltbutils_err_cnt + 1; -- VHDL-1993
 
    end if;
 
    pltbutils_sc_update(pltbutils_sc);
 
  end procedure check;
  end procedure check;
 
 
  -- check unsigned against integer
  -- check unsigned against integer
  procedure check(
  procedure check(
    constant rpt                : in    string;
    constant rpt                : in    string;
    constant data               : in    unsigned;
    constant actual             : in    unsigned;
    constant expected           : in    integer;
    constant expected           : in    integer;
    signal   pltbutils_sc       : out   pltbutils_sc_t
    signal   pltbutils_sc       : out   pltbutils_sc_t
  ) is
  ) is
  begin
  begin
    check(rpt, data, to_unsigned(expected, data'length), pltbutils_sc);
    check(rpt, actual, to_unsigned(expected, actual'length), pltbutils_sc);
  end procedure check;
  end procedure check;
 
 
  -- check signed
  -- check signed
  procedure check(
  procedure check(
    constant rpt                : in    string;
    constant rpt                : in    string;
    constant data               : in    signed;
    constant actual             : in    signed;
    constant expected           : in    signed;
    constant expected           : in    signed;
    signal   pltbutils_sc       : out   pltbutils_sc_t
    signal   pltbutils_sc       : out   pltbutils_sc_t
  ) is
  ) is
  begin
  begin
    v_pltbutils_chk_cnt.inc; -- VHDL-2002
    check(rpt, actual = expected, hxstr(actual, "0x"), hxstr(expected, "0x"), "", pltbutils_sc);
    --v_pltbutils_chk_cnt := v_pltbutils_chk_cnt + 1; -- VHDL-1993
 
    if data /= expected   then
 
      assert false
 
      report "Check " &
 
             str(v_pltbutils_chk_cnt.value) & -- VHDL-2002
 
             --str(v_pltbutils_chk_cnt) & -- VHDL-1993
 
             "; " & rpt   &
 
             "; Data=" & hxstr(data, "0x") &
 
             " Expected=" & hxstr(expected, "0x") &
 
             " " & --str('lf') &
 
             "  in test " &
 
             str(v_pltbutils_test_num.value) & -- VHDL-2002
 
             --str(v_pltbutils_test_num) & -- VHDL-1993
 
             " " &
 
             v_pltbutils_test_name.value -- VHDL-2002
 
             --v_pltbutils_test_name -- VHDL-1993
 
      severity error;
 
      v_pltbutils_err_cnt.inc; -- VHDL-2002
 
      --v_pltbutils_err_cnt := v_pltbutils_err_cnt + 1; -- VHDL-1993
 
    end if;
 
    pltbutils_sc_update(pltbutils_sc);
 
  end procedure check;
  end procedure check;
 
 
  -- check signed against integer
  -- check signed against integer
  -- TODO: find the bug reported by tb_pltbutils when expected   is negative (-1):
  -- TODO: find the bug reported by tb_pltbutils when expected   is negative (-1):
  --       ** Error: (vsim-86) numstd_conv_unsigned_nu: NATURAL arg value is negative (-1)
  --       ** Error: (vsim-86) numstd_conv_unsigned_nu: NATURAL arg value is negative (-1)
  procedure check(
  procedure check(
    constant rpt                : in    string;
    constant rpt                : in    string;
    constant data               : in    signed;
    constant actual             : in    signed;
    constant expected           : in    integer;
    constant expected           : in    integer;
    signal   pltbutils_sc       : out   pltbutils_sc_t
    signal   pltbutils_sc       : out   pltbutils_sc_t
  ) is
  ) is
  begin
  begin
    check(rpt, data, to_signed(expected, data'length), pltbutils_sc);
    check(rpt, actual, to_signed(expected, actual'length), pltbutils_sc);
  end procedure check;
  end procedure check;
 
 
  -- check with boolean expression
  -- check with boolean expression
  -- Check signal or variable with a boolean expression as argument C_EXPR.
  -- Check signal or variable with a boolean expression as argument C_EXPR.
  -- This allowes any kind of check.
  -- This allowes any kind of check.
Line 1466... Line 1483...
    constant rpt                : in    string;
    constant rpt                : in    string;
    constant expr               : in    boolean;
    constant expr               : in    boolean;
    signal   pltbutils_sc       : out   pltbutils_sc_t
    signal   pltbutils_sc       : out   pltbutils_sc_t
  ) is
  ) is
  begin
  begin
 
    check(rpt, expr, "", "", "", pltbutils_sc);
 
  end procedure check;
 
 
 
  procedure check(
 
    constant rpt                : in    string;
 
    constant expr               : in    boolean;
 
    constant actual             : in    string;
 
    constant expected           : in    string;
 
    constant mask               : in    string;
 
    signal   pltbutils_sc       : out   pltbutils_sc_t
 
  ) is
 
    variable v_test_name_len    : integer := 1;
 
    variable actual_str         : string(1 to 32) := (others => ' ');
 
    variable actual_str_len     : integer := 1;
 
    variable expected_str       : string(1 to 32) := (others => ' ');
 
    variable expected_str_len   : integer := 1;
 
    variable mask_str           : string(1 to 32) := (others => ' ');
 
    variable mask_str_len       : integer := 1;
 
  begin
    v_pltbutils_chk_cnt.inc; -- VHDL-2002
    v_pltbutils_chk_cnt.inc; -- VHDL-2002
    --v_pltbutils_chk_cnt := v_pltbutils_chk_cnt + 1; -- VHDL-1993
    --v_pltbutils_chk_cnt := v_pltbutils_chk_cnt + 1; -- VHDL-1993
    if not expr then
    if not expr then
      assert false
 
      report "Check " &
 
             str(v_pltbutils_chk_cnt.value) & -- VHDL-2002
 
             --str(v_pltbutils_chk_cnt) & -- VHDL-1993
 
             "; " & rpt   &
 
             " " & --str('lf') &
 
             "  in test " &
 
             str(v_pltbutils_test_num.value) & -- VHDL-2002
 
             --str(v_pltbutils_test_num) & -- VHDL-1993
 
             " " &
 
             v_pltbutils_test_name.value -- VHDL-2002
 
             --v_pltbutils_test_name -- VHDL-1993
 
      severity error;
 
      v_pltbutils_err_cnt.inc; -- VHDL-2002
      v_pltbutils_err_cnt.inc; -- VHDL-2002
 
      v_pltbutils_err_cnt_in_test.inc; -- VHDL-2002
      --v_pltbutils_err_cnt := v_pltbutils_err_cnt + 1; -- VHDL-1993
      --v_pltbutils_err_cnt := v_pltbutils_err_cnt + 1; -- VHDL-1993
 
      --v_pltbutils_err_cnt_in_test := v_pltbutils_err_cnt_in_test + 1; -- VHDL-1993
 
    end if;
 
    v_test_name_len := v_pltbutils_test_name_len.value;
 
    if C_PLTBUTILS_USE_STD_CHECK_MSG then
 
      check_msg(rpt, expr, actual, expected, mask, v_pltbutils_test_num.value,
 
        v_pltbutils_test_name.value(1 to v_test_name_len), v_pltbutils_chk_cnt.value,
 
        v_pltbutils_err_cnt_in_test.value); -- VHDL-2002
 
      --check_msg(rpt, actual, expected, mask, v_pltbutils_test_num,
 
      --  v_pltbutils_test_name(1 to v_test_name_len), v_pltbutils_chk_cnt,
 
      --  v_pltbutils_err_cnt_in_test); -- VHDL-2002
 
    end if;
 
    if C_PLTBUTILS_USE_CUSTOM_CHECK_MSG then
 
      -- VHDL-2002:
 
      custom_check_msg(rpt, expr, actual, expected, mask, v_pltbutils_test_num.value,
 
        v_pltbutils_test_name.value(1 to v_test_name_len), v_pltbutils_chk_cnt.value,
 
        v_pltbutils_err_cnt_in_test.value);
 
      -- VHDL-1993:
 
      --custom_check_msg(rpt, actual, expected, mask, v_pltbutils_test_num,
 
      --  v_pltbutils_test_name(1 to v_test_name_len), v_pltbutils_chk_cnt,
 
      --  v_pltbutils_err_cnt_in_test);
    end if;
    end if;
    pltbutils_sc_update(pltbutils_sc);
    pltbutils_sc_update(pltbutils_sc);
  end procedure check;
  end procedure check;
 
 
  ----------------------------------------------------------------------------
  ----------------------------------------------------------------------------
Line 1594... Line 1638...
 
 
  ----------------------------------------------------------------------------
  ----------------------------------------------------------------------------
  -- hxstr
  -- hxstr
  -- function hxstr(
  -- function hxstr(
  --  constant s                  : std_logic_vector;
  --  constant s                  : std_logic_vector;
  --  constant prefix             : string := ""
  --  constant prefix             : string := "";
 
  --  constant postfix            : string := ""
  -- ) return string;
  -- ) return string;
  --
  --
  -- function hxstr(
  -- function hxstr(
  --  constant s                  : unsigned;
  --  constant s                  : unsigned;
  --  constant prefix             : string := ""
  --  constant prefix             : string := "";
 
  --  constant postfix            : string := ""
  -- ) return string;
  -- ) return string;
  --
  --
  -- function hxstr(
  -- function hxstr(
  --  constant s                  : signed;
  --  constant s                  : signed;
  --  constant prefix             : string := ""
  --  constant prefix             : string := "";
 
  --  constant postfix            : string := ""
  -- ) return string;
  -- ) return string;
  --
  --
  -- Converts a signal to a string in hexadecimal format.
  -- Converts a signal to a string in hexadecimal format.
  -- An optional prefix can be specified, e.g. "0x".
  -- An optional prefix can be specified, e.g. "0x".
  --
  --
Line 1622... Line 1669...
  -- print("value=" & hxstr(s));
  -- print("value=" & hxstr(s));
  -- print("value=" & hxstr(s, "0x"));
  -- print("value=" & hxstr(s, "0x"));
  ----------------------------------------------------------------------------
  ----------------------------------------------------------------------------
  function hxstr(
  function hxstr(
    constant s                  : std_logic_vector;
    constant s                  : std_logic_vector;
    constant prefix             : string := ""
    constant prefix             : string := "";
 
    constant postfix            : string := ""
  ) return string is
  ) return string is
  begin
  begin
    return prefix & hstr(to_descending(s));
    return prefix & hstr(to_descending(s)) & postfix;
  end function hxstr;
  end function hxstr;
 
 
  function hxstr(
  function hxstr(
    constant s                  : unsigned;
    constant s                  : unsigned;
    constant prefix             : string := ""
    constant prefix             : string := "";
 
    constant postfix            : string := ""
  ) return string is
  ) return string is
  begin
  begin
    return prefix & hstr(to_descending(std_logic_vector(s)));
    return prefix & hstr(to_descending(std_logic_vector(s))) & postfix;
  end function hxstr;
  end function hxstr;
 
 
  function hxstr(
  function hxstr(
    constant s                  : signed;
    constant s                  : signed;
    constant prefix             : string := ""
    constant prefix             : string := "";
 
    constant postfix            : string := ""
  ) return string is
  ) return string is
  begin
  begin
    return prefix & hstr(to_descending(std_logic_vector(s)));
    return prefix & hstr(to_descending(std_logic_vector(s))) & postfix;
  end function hxstr;
  end function hxstr;
 
 
  ----------------------------------------------------------------------------
  ----------------------------------------------------------------------------
  -- pltbutils internal procedure(s), called from other pltbutils procedures.
  -- pltbutils internal procedure(s), called from other pltbutils procedures.
  -- Do not to call this/these from user's code.
  -- Do not to call this/these from user's code.
Line 1669... Line 1719...
    --pltbutils_sc.chk_cnt    <= v_pltbutils_chk_cnt;
    --pltbutils_sc.chk_cnt    <= v_pltbutils_chk_cnt;
    --pltbutils_sc.err_cnt    <= v_pltbutils_err_cnt;
    --pltbutils_sc.err_cnt    <= v_pltbutils_err_cnt;
    --pltbutils_sc.stop_sim   <= v_pltbutils_stop_sim;
    --pltbutils_sc.stop_sim   <= v_pltbutils_stop_sim;
  end procedure pltbutils_sc_update;
  end procedure pltbutils_sc_update;
 
 
 
  procedure startsim_msg(
 
    constant testcase_name      : in string;
 
    constant timestamp          : in time
 
  ) is
 
  begin
 
    print(lf & "--- START OF SIMULATION ---");
 
    print("Testcase: " & testcase_name);
 
    print(time'image(timestamp));
 
  end procedure startsim_msg;
 
 
 
  procedure endsim_msg(
 
    constant testcase_name      : in string;
 
    constant timestamp          : in time;
 
    constant num_tests          : in integer;
 
    constant num_checks         : in integer;
 
    constant num_errors         : in integer;
 
    constant show_success_fail  : in boolean
 
  ) is
 
    variable l : line;
 
  begin
 
    print(lf & "--- END OF SIMULATION ---");
 
    print("Note: the results presented below are based on the PlTbUtil's check() procedure calls.");
 
    print("      The design may contain more errors, for which there are no check() calls.");
 
    write(l, timestamp, right, 14);
 
    writeline(output, l);
 
    write(l, num_tests, right, 11);
 
    write(l, string'(" Tests"));
 
    writeline(output, l);
 
    write(l, num_checks, right, 11);
 
    write(l, string'(" Checks"));
 
    writeline(output, l);
 
    write(l, num_errors, right, 11);
 
    write(l, string'(" Errors"));
 
    writeline(output, l);
 
    if show_success_fail then
 
      if num_errors = 0 and num_checks > 0 then
 
        print("*** SUCCESS ***");
 
      elsif num_checks > 0 then
 
        print("*** FAIL ***");
 
      else
 
        print("*** NO CHECKS ***");
 
      end if;
 
    end if;
 
  end procedure endsim_msg;
 
 
 
  procedure starttest_msg(
 
    constant test_num           : in integer;
 
    constant test_name          : in string;
 
    constant timestamp          : in time
 
  ) is
 
  begin
 
    print(lf & "Test " & str(test_num) & ": " & test_name & " (" & time'image(timestamp) & ")");
 
  end procedure starttest_msg;
 
 
 
  procedure endtest_msg(
 
    constant test_num           : in integer;
 
    constant test_name          : in string;
 
    constant timestamp          : in time;
 
    constant num_checks_in_test : in integer;
 
    constant num_errors_in_test : in integer
 
  ) is
 
  begin
 
    print("Done with test " & str(test_num) & ": " & test_name & " (" & time'image(timestamp) & ")");
 
  end procedure endtest_msg;
 
 
 
  procedure check_msg(
 
    constant rpt                : in string;
 
    constant expr               : in boolean;
 
    constant actual             : in string;
 
    constant expected           : in string;
 
    constant mask               : in string;
 
    constant test_num           : in integer;
 
    constant test_name          : in string;
 
    constant check_num          : in integer;
 
    constant err_cnt_in_test    : in integer
 
  ) is
 
    variable comparison_str     : string(1 to 32) := (others => ' ');
 
    variable comparison_str_len : integer := 1;
 
    variable actual_str         : string(1 to 32) := (others => ' ');
 
    variable actual_str_len     : integer := 1;
 
    variable expected_str       : string(1 to 32) := (others => ' ');
 
    variable expected_str_len   : integer := 1;
 
    variable mask_str           : string(1 to 32) := (others => ' ');
 
    variable mask_str_len       : integer := 1;
 
  begin
 
    if not expr then -- Output message only if the check fails
 
      if actual /= "" then
 
        actual_str_len := 8 + actual'length;
 
        actual_str(1 to actual_str_len) := " Actual=" & actual;
 
      end if;
 
      if expected /= "" then
 
        expected_str_len := 10 + expected'length;
 
        expected_str(1 to expected_str_len) := " Expected=" & expected;
 
      end if;
 
      if mask /= "" then
 
        mask_str_len := 6 + mask'length;
 
        mask_str(1 to mask_str_len) := " Mask=" & mask;
 
      end if;
 
      assert false
 
        report "Check " & str(check_num) & "; " & rpt & "; " &
 
               actual_str(1 to actual_str_len) &
 
               expected_str(1 to expected_str_len) &
 
               mask_str(1 to mask_str_len) &
 
               "  in test " & str(test_num) & " " & test_name
 
        severity error;
 
    end if;
 
  end procedure check_msg;
 
 
 
  procedure pltbutils_error(
 
    constant rpt                : in string;
 
    signal   pltbutils_sc       : out   pltbutils_sc_t
 
  ) is
 
  begin
 
    -- VHDL-2002:
 
    v_pltbutils_err_cnt.inc;
 
    if C_PLTBUTILS_USE_STD_ERROR_MSG then
 
      error_msg(rpt, now,
 
        v_pltbutils_test_num.value,
 
        v_pltbutils_test_name.value(1 to v_pltbutils_test_name_len.value),
 
        v_pltbutils_err_cnt_in_test.value);
 
    end if;
 
    if C_PLTBUTILS_USE_CUSTOM_ERROR_MSG then
 
      custom_error_msg(rpt, now,
 
        v_pltbutils_test_num.value,
 
        v_pltbutils_test_name.value(1 to v_pltbutils_test_name_len.value),
 
        v_pltbutils_err_cnt_in_test.value);
 
    end if;
 
    -- VHDL-1993:
 
    --v_pltbutils_err_cnt := v_pltbutils_err_cnt + 1;
 
    --if C_PLTBUTILS_USE_STD_ERROR_MSG then
 
    --  error_msg(rpt, now, 
 
    --    v_pltbutils_test_num, 
 
    --    v_pltbutils_test_name(1 to v_pltbutils_test_name_len),
 
    --    v_pltbutils_err_cnt_in_test);
 
    --end if;
 
    --if C_PLTBUTILS_USE_CUSTOM_ERROR_MSG then
 
    --  custom_error_msg(rpt, now, 
 
    --    v_pltbutils_test_num, 
 
    --    v_pltbutils_test_name(1 to v_pltbutils_test_name_len),
 
    --    v_pltbutils_err_cnt_in_test);
 
    --end if;
 
    pltbutils_sc_update(pltbutils_sc);
 
  end procedure pltbutils_error;
 
 
 
  procedure error_msg(
 
    constant rpt                : in string;
 
    constant timestamp          : in time;
 
    constant test_num           : in integer;
 
    constant test_name          : in string;
 
    constant err_cnt_in_test    : in integer
 
  ) is
 
  begin
 
    assert false
 
    report rpt & " in test " & str(test_num) & ": " & test_name
 
    severity error;
 
  end procedure error_msg;
 
 
 
  procedure stopsim(
 
    constant timestamp          : in time
 
  ) is
 
  begin
 
    assert false
 
    report "--- FORCE END OF SIMULATION ---" &
 
           " (ignore this false failure message, it's not a real failure)"
 
    severity failure;
 
  end procedure stopsim;
 
 
end package body pltbutils_func_pkg;
end package body pltbutils_func_pkg;
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

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