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

Subversion Repositories vhld_tb

[/] [vhld_tb/] [trunk/] [source/] [tb_pkg_body.vhd] - Diff between revs 17 and 19

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

Rev 17 Rev 19
Line 1... Line 1...
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
--             Copyright 2009  Ken Campbell
--             Copyright 2011  Ken Campbell
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-- $Author: sckoarn $
-- $Author: sckoarn $
--
--
-- $Date: 2008-02-24 01:34:11 $
-- $Date:  $
--
--
-- $Id: tb_pkg_body.vhd,v 1.3 2008-02-24 01:34:11 sckoarn Exp $
-- $Id:  $
--
--
-- $Source: /home/marcus/revision_ctrl_test/oc_cvs/cvs/vhld_tb/source/tb_pkg_body.vhd,v $
-- $Source:  $
--
--
-- Description :  The the testbench package body file.
-- Description :  The the testbench package body file.
--                Initial GNU release.
--                GNU release 2 Beta.
--
--
------------------------------------------------------------------------------
------------------------------------------------------------------------------
--This file is part of The VHDL Test Bench.
--This file is part of The VHDL Test Bench.
--
--
--    The VHDL Test Bench is free software; you can redistribute it and/or modify
--    The VHDL Test Bench is free software; you can redistribute it and/or modify
Line 27... Line 27...
--
--
--    You should have received a copy of the GNU General Public License
--    You should have received a copy of the GNU General Public License
--    along with The VHDL Test Bench; if not, write to the Free Software
--    along with The VHDL Test Bench; if not, write to the Free Software
--    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
--    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-- Revision History:
 
-- $Log: not supported by cvs2svn $
 
-- Revision 1.2  2007/09/02 04:04:04  sckoarn
 
-- Update of version 1.2 tb_pkg
 
-- See documentation for details
 
--
 
-- Revision 1.1.1.1  2007/04/06 04:06:48  sckoarn
 
-- Import of the vhld_tb
 
--
 
--
 
-------------------------------------------------------------------------------
 
 
 
package body tb_pkg is
package body tb_pkg is
 
 
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-- FUNCTION Defs
-- FUNCTION Defs
Line 337... Line 326...
           report LF & "Error: bin2integer found non Binary didgit on line "
           report LF & "Error: bin2integer found non Binary didgit on line "
                     & (integer'image(line)) & " of file " & file_name
                     & (integer'image(line)) & " of file " & file_name
         severity failure;
         severity failure;
       end case;
       end case;
 
 
 
       if (int_number = 1) then
       temp_int  := temp_int + (int_number *(2 ** power));
       temp_int  := temp_int + (int_number *(2 ** power));
 
       end if;
       power     := power + 1;
       power     := power + 1;
     end loop;
     end loop;
 
 
     return temp_int;
     return temp_int;
  end bin2integer;
  end bin2integer;
Line 351... Line 342...
--          return :  integer value
--          return :  integer value
function stim_to_integer(field:      in text_field;
function stim_to_integer(field:      in text_field;
                         file_name:  in text_line;
                         file_name:  in text_line;
                         line:       in integer) return integer is
                         line:       in integer) return integer is
    variable len:       integer;
    variable len:       integer;
    variable text:      text_field;
 
    variable value:     integer := 1;
    variable value:     integer := 1;
    variable temp_str : string(1 to 48);
    variable temp_str : string(1 to 48);
  begin
  begin
    len := fld_len(field);
    len := fld_len(field);
 
 
Line 451... Line 441...
 
 
    return temp;
    return temp;
 
 
  end ew_to_str ;
  end ew_to_str ;
 
 
-------------------------------------------------------------------------------
---------------------------------------------------------------------------------------
-- Procedure to print instruction records to stdout  *for debug*
-- convert std_logic_vector to an unsigned integer
  procedure print_inst(variable inst  :  in stim_line_ptr) is
  function to_uninteger ( constant vect     : in std_logic_vector
    variable l:    text_line;
                        ) return integer is
    variable l_i:  integer := 1;
    variable result   : integer := 0;
    variable j:    integer := 1;
    variable len      : integer := vect'length;
 
    variable idx      : integer;
 
    variable tmp_str  : text_field;
 
    variable file_name: text_line;
  begin
  begin
    while (inst.instruction(j) /= nul) loop
    -- point to start of string
      l(l_i) := inst.instruction(j);
    idx  :=  1;
      j   := j +1;
    -- convert std_logic_vector to text_field
      l_i := l_i + 1;
    for i in len - 1 downto 0 loop
    end loop;
      if(vect(i) = '1') then
 
        tmp_str(idx) := '1';
    l(l_i) := ' ';
      elsif(vect(i) = '0') then
    l_i := l_i + 1;
        tmp_str(idx) := '0';
    j   := 1;
      else
    -- field one
        assert(false)
    if(inst.inst_field_1(1) /= nul) then
          report LF & "ERROR:  Non 0/1 value found in std_logic_vector passed to to_uninteger function!!" & LF &
      while (inst.inst_field_1(j) /= nul) loop
                "Returning 0."
        l(l_i) := inst.inst_field_1(j);
        severity note;
        j   := j +1;
        return result;
        l_i := l_i + 1;
 
      end loop;
 
      l(l_i) := ' ';
 
      l_i := l_i + 1;
 
      j   := 1;
 
      -- field two
 
      if(inst.inst_field_2(1) /= nul) then
 
        while (inst.inst_field_2(j) /= nul) loop
 
          l(l_i) := inst.inst_field_2(j);
 
          j   := j +1;
 
          l_i := l_i + 1;
 
        end loop;
 
        l(l_i) := ' ';
 
        l_i := l_i + 1;
 
        j   := 1;
 
        -- field three
 
        if(inst.inst_field_3(1) /= nul) then
 
          while (inst.inst_field_3(j) /= nul) loop
 
            l(l_i) := inst.inst_field_3(j);
 
            j   := j +1;
 
            l_i := l_i + 1;
 
          end loop;
 
          l(l_i) := ' ';
 
          l_i := l_i + 1;
 
          j   := 1;
 
          -- field four
 
          if(inst.inst_field_4(1) /= nul) then
 
            while (inst.inst_field_4(j) /= nul) loop
 
              l(l_i) := inst.inst_field_4(j);
 
              j   := j +1;
 
              l_i := l_i + 1;
 
            end loop;
 
          end if;
 
        end if;
 
      end if;
 
    end if;
 
    print(l);
 
 
 
    print("   Sequence Number: " & to_str(inst.line_number) &
 
          "  File Line Number: " & to_str(inst.file_line));
 
    if(inst.num_of_lines > 0) then
 
      print("   Number of Lines: " & to_str(inst.num_of_lines));
 
    end if;
    end if;
  end print_inst;
      idx := idx + 1;
 
    end loop;
 
    -- call bin txt to int fuction with dummy fn and sequ idx
 
    result := bin2integer(tmp_str, file_name, idx);
 
    return result;
 
 
 
  end to_uninteger;
 
 
 
 
 
--------------------
 
-- stm neut
 
  function stm_neut return stm_sctl is
 
    variable tmp  : stm_sctl;
 
  begin
 
    tmp.rst_n    :=  '1';
 
    tmp.addr     := (others => 'Z');
 
    tmp.wdat     := (others => 'Z');
 
    tmp.rwn      := 'Z';
 
    tmp.req_n    := 'Z';
 
    return tmp;
 
  end stm_neut;
 
 
 
  function stm_neut return stm_sack is
 
    variable tmp  : stm_sack;
 
  begin
 
    tmp.rdat     := (others => 'Z');
 
    tmp.ack_n    := '1';
 
    tmp.rdy_n    := '1';
 
    tmp.irq_n    := '1';
 
    return tmp;
 
  end stm_neut;
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--  access_variable
--  access_variable
--     inputs:
--     inputs:
--               Text field containing variable
--               Text field containing variable
--     outputs:
--     outputs:
Line 970... Line 950...
          end if;
          end if;
        end loop;
        end loop;
      end if;
      end if;
    end if;
    end if;
 
 
 
    -- if instruction was not found, die
 
    assert(match = 1)
 
      report LF & "Error: Undefined Instruction on line " & (integer'image(line_num)) &
 
                  " found in input file " & name & LF
 
    severity failure;
 
 
 
      -- if the definition of the number of parameters is > 6 skip testing
 
      --   this is how the variable number of parameters is implemented
 
      --   just skip testing for specified number
 
      if(seti.params > 6) then
 
        return;
 
      end if;
    -- if we had a match, check the number of paramiters
    -- if we had a match, check the number of paramiters
    if(match = 1 and ilv = 0) then
    if(match = 1 and ilv = 0) then
      assert(seti.params = (token_num - 1))
      assert(seti.params = (token_num - 1))
        report LF & "Error: Undefined Instruction was found, incorrect number of fields passed!" & LF &
        report LF & "Error: Undefined Instruction was found, incorrect number of fields passed!" & LF &
                    "This is found on line " & (integer'image(line_num)) & " in file " & name & LF
                    "This is found on line " & (integer'image(line_num)) & " in file " & name & LF
      severity failure;
      severity failure;
    end if;
    end if;
 
 
    -- if we find a duplicate, die
 
    assert(match = 1)
 
      report LF & "Error: Undefined Instruction on line " & (integer'image(line_num)) &
 
                  " found in input file " & name & LF
 
    severity failure;
 
  end check_valid_inst;
  end check_valid_inst;
 
 
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--  add_variable
--  add_variable
--    This procedure adds a variable to the variable list.  This is localy
--    This procedure adds a variable to the variable list.  This is localy
Line 1640... Line 1626...
      if(temp_fn_prt.rec_idx = tmp_int) then
      if(temp_fn_prt.rec_idx = tmp_int) then
        exit;
        exit;
      end if;
      end if;
      temp_fn_prt  :=  temp_fn_prt.next_rec;
      temp_fn_prt  :=  temp_fn_prt.next_rec;
    end loop;
    end loop;
    for i in 1 to fname'high loop
    for i in 1 to fname'high loop                       --<<<<<<<<<<<<<  Fix for file name output Apr 2011.
      file_name(i) :=  temp_fn_prt.file_name(i);
      file_name(i) :=  temp_fn_prt.file_name(i);
 
      fname(i)     :=  temp_fn_prt.file_name(i);
 
      if(temp_fn_prt.file_name(i) = nul) then
 
        exit;
 
      end if;
    end loop;
    end loop;
 
 
    txt       := inst_ptr.txt;
    txt       := inst_ptr.txt;
    -- load parameter one
    -- load parameter one
    temp_text_field  :=  inst_ptr.inst_field_1;
    temp_text_field  :=  inst_ptr.inst_field_1;
Line 1749... Line 1739...
        severity failure;
        severity failure;
      end if;
      end if;
    end if;
    end if;
  end access_inst_sequ;
  end access_inst_sequ;
 
 
-------------------------------------------------------------------------
 
-- dump inst_sequ
 
--  This procedure dumps to the simulation window the current instruction
 
--  sequence.  The whole thing will be dumped, which could be big.
 
--   ** intended for testbench development debug **
 
--  procedure dump_inst_sequ(variable inst_sequ  :  in  stim_line_ptr) is
 
--    variable v_sequ  :  stim_line_ptr;
 
--  begin
 
--    v_sequ  :=  inst_sequ;
 
--    while(v_sequ.next_rec /= null) loop
 
--      print("-----------------------------------------------------------------");
 
--      print("Instruction is " & v_sequ.instruction &
 
--      "     Par1: "   & v_sequ.inst_field_1 &
 
--      "     Par2: "   & v_sequ.inst_field_2 &
 
--      "     Par3: "   & v_sequ.inst_field_3 &
 
--      "     Par4: "   & v_sequ.inst_field_4);
 
--      print("Line Number: " & to_str(v_sequ.line_number) & "     File Line Number: " & to_str(v_sequ.file_line) &
 
--      "     File Name: " & v_sequ.file_name);
 
--      
 
--      v_sequ  :=  v_sequ.next_rec;
 
--    end loop;
 
--    -- get the last one
 
--    print("-----------------------------------------------------------------");
 
--    print("Instruction is " & v_sequ.instruction & "     Par1: "   & v_sequ.inst_field_1 &
 
--    "     Par2: "   & v_sequ.inst_field_2 & "     Par3: "   & v_sequ.inst_field_3 &
 
--    "     Par4: "   & v_sequ.inst_field_4);
 
--    print("Line Number: " & to_str(v_sequ.line_number) & "     File Line Number: " & to_str(v_sequ.file_line) &
 
--    "     File Name: " & v_sequ.file_name);
 
--  end dump_inst_sequ;
 
 
 
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-- Procedure to print messages to stdout
-- Procedure to print messages to stdout
  procedure print(s: in string) is
  procedure print(s: in string) is
    variable l: line;
    variable l: line;
  begin
  begin
Line 1868... Line 1828...
    end if;
    end if;
  end txt_print_wvar;
  end txt_print_wvar;
 
 
end tb_pkg;
end tb_pkg;
 
 
 
-------------------------------------------------------------------------------
 
--  Revision  1.3
 
-- Revision History:
 
-- $Log: not supported by cvs2svn $
 
-- Revision 1.2  2007/09/02 04:04:04  sckoarn
 
-- Update of version 1.2 tb_pkg
 
-- See documentation for details
 
--
 
-- Revision 1.1.1.1  2007/04/06 04:06:48  sckoarn
 
-- Import of the vhld_tb
 
-------------------------------------------------------------------------------
 
 
 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.