-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
-- Copyright 2007 Ken Campbell
|
-- Copyright 2007 Ken Campbell
|
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
-- $Author: sckoarn $
|
-- $Author: sckoarn $
|
--
|
--
|
-- $Date: 2007-04-06 04:06:48 $
|
-- $Date: 2007-04-06 04:06:48 $
|
--
|
--
|
-- $Name: not supported by cvs2svn $
|
-- $Name: not supported by cvs2svn $
|
--
|
--
|
-- $Id: tb_pkg_body.vhd,v 1.1.1.1 2007-04-06 04:06:48 sckoarn Exp $
|
-- $Id: tb_pkg_body.vhd,v 1.1.1.1 2007-04-06 04:06:48 sckoarn Exp $
|
--
|
--
|
-- $Source: /home/marcus/revision_ctrl_test/oc_cvs/cvs/vhld_tb/source/tb_pkg_body.vhd,v $
|
-- $Source: /home/marcus/revision_ctrl_test/oc_cvs/cvs/vhld_tb/source/tb_pkg_body.vhd,v $
|
--
|
--
|
-- Description : The the testbench package body file.
|
-- Description : The the testbench package body file.
|
-- Initial GNU release.
|
-- Initial GNU release.
|
--
|
--
|
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
--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
|
-- it under the terms of the GNU General Public License as published by
|
-- it under the terms of the GNU General Public License as published by
|
-- the Free Software Foundation; either version 2 of the License, or
|
-- the Free Software Foundation; either version 2 of the License, or
|
-- (at your option) any later version.
|
-- (at your option) any later version.
|
--
|
--
|
-- Foobar is distributed in the hope that it will be useful,
|
-- Foobar is distributed in the hope that it will be useful,
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
-- GNU General Public License for more details.
|
-- GNU General Public License for more details.
|
--
|
--
|
-- 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:
|
-- Revision History:
|
-- $Log: not supported by cvs2svn $
|
-- $Log: not supported by cvs2svn $
|
--
|
--
|
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
|
|
package body tb_pkg is
|
package body tb_pkg is
|
|
|
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
-- FUNCTION Defs
|
-- FUNCTION Defs
|
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
-- is_digit
|
-- is_digit
|
function is_digit(constant c: in character) return boolean is
|
function is_digit(constant c: in character) return boolean is
|
variable rtn : boolean;
|
variable rtn : boolean;
|
begin
|
begin
|
if (c >= '0' and c <= '9') then
|
if (c >= '0' and c <= '9') then
|
rtn := true;
|
rtn := true;
|
else
|
else
|
rtn := false;
|
rtn := false;
|
end if;
|
end if;
|
return rtn;
|
return rtn;
|
end is_digit;
|
end is_digit;
|
--------------------------------------
|
--------------------------------------
|
-- is_space
|
-- is_space
|
function is_space(constant c: in character) return boolean is
|
function is_space(constant c: in character) return boolean is
|
variable rtn : boolean;
|
variable rtn : boolean;
|
begin
|
begin
|
if(c = ' ' or c = ht) then
|
if(c = ' ' or c = ht) then
|
rtn := true;
|
rtn := true;
|
else
|
else
|
rtn := false;
|
rtn := false;
|
end if;
|
end if;
|
return rtn;
|
return rtn;
|
end is_space;
|
end is_space;
|
---------------------------------------------------------------
|
---------------------------------------------------------------
|
function ew_to_slv(value : in integer;
|
function ew_to_slv(value : in integer;
|
length : in integer) return std_logic_vector is
|
length : in integer) return std_logic_vector is
|
variable result : std_logic_vector((length - 1) downto 0);
|
variable result : std_logic_vector((length - 1) downto 0);
|
variable temp : natural;
|
variable temp : natural;
|
variable power : natural;
|
variable power : natural;
|
|
|
begin
|
begin
|
assert(length > 1)
|
assert(length > 1)
|
report LF & "Error: ew_to_slv, Bit length must be greater than 1 to form a vector! "
|
report LF & "Error: ew_to_slv, Bit length must be greater than 1 to form a vector! "
|
severity failure;
|
severity failure;
|
temp := value;
|
temp := value;
|
for i in (length - 1) downto 0 loop
|
for i in (length - 1) downto 0 loop
|
power := 2**i;
|
power := 2**i;
|
if(temp > ((2**i) - 1)) then
|
if(temp > ((2**i) - 1)) then
|
result(i) := '1';
|
result(i) := '1';
|
temp := temp - ((2**i) - 1);
|
temp := temp - ((2**i) - 1);
|
else
|
else
|
result(i) := '0';
|
result(i) := '0';
|
end if;
|
end if;
|
end loop;
|
end loop;
|
|
|
return result;
|
return result;
|
end ew_to_slv;
|
end ew_to_slv;
|
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
-- to_char
|
-- to_char
|
function ew_to_char(int: integer) return character is
|
function ew_to_char(int: integer) return character is
|
variable c: character;
|
variable c: character;
|
begin
|
begin
|
c := nul;
|
c := nul;
|
case int is
|
case int is
|
when 0 => c := '0';
|
when 0 => c := '0';
|
when 1 => c := '1';
|
when 1 => c := '1';
|
when 2 => c := '2';
|
when 2 => c := '2';
|
when 3 => c := '3';
|
when 3 => c := '3';
|
when 4 => c := '4';
|
when 4 => c := '4';
|
when 5 => c := '5';
|
when 5 => c := '5';
|
when 6 => c := '6';
|
when 6 => c := '6';
|
when 7 => c := '7';
|
when 7 => c := '7';
|
when 8 => c := '8';
|
when 8 => c := '8';
|
when 9 => c := '9';
|
when 9 => c := '9';
|
when 10 => c := 'A';
|
when 10 => c := 'A';
|
when 11 => c := 'B';
|
when 11 => c := 'B';
|
when 12 => c := 'C';
|
when 12 => c := 'C';
|
when 13 => c := 'D';
|
when 13 => c := 'D';
|
when 14 => c := 'E';
|
when 14 => c := 'E';
|
when 15 => c := 'F';
|
when 15 => c := 'F';
|
when others =>
|
when others =>
|
assert(false)
|
assert(false)
|
report LF & "Error: ew_to_char was given a non Number didgit."
|
report LF & "Error: ew_to_char was given a non Number didgit."
|
severity failure;
|
severity failure;
|
end case;
|
end case;
|
|
|
return c;
|
return c;
|
end ew_to_char;
|
end ew_to_char;
|
|
|
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
-- to_string function integer
|
-- to_string function integer
|
function to_str(int: integer) return string is
|
function to_str(int: integer) return string is
|
begin
|
begin
|
return ew_to_str(int,dec) ;
|
return ew_to_str(int,dec) ;
|
end to_str ;
|
end to_str ;
|
|
|
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
-- ew_str_cat
|
-- ew_str_cat
|
function ew_str_cat(s1: stm_text;
|
function ew_str_cat(s1: stm_text;
|
s2: text_field) return stm_text is
|
s2: text_field) return stm_text is
|
|
|
variable i: integer;
|
variable i: integer;
|
variable j: integer;
|
variable j: integer;
|
variable sc: stm_text;
|
variable sc: stm_text;
|
|
|
begin
|
begin
|
sc := s1;
|
sc := s1;
|
i := 1;
|
i := 1;
|
while(sc(i) /= nul) loop
|
while(sc(i) /= nul) loop
|
i := i + 1;
|
i := i + 1;
|
end loop;
|
end loop;
|
j := 1;
|
j := 1;
|
while(s2(j) /= nul) loop
|
while(s2(j) /= nul) loop
|
sc(i) := s2(j);
|
sc(i) := s2(j);
|
i := i + 1;
|
i := i + 1;
|
j := j + 1;
|
j := j + 1;
|
end loop;
|
end loop;
|
|
|
return sc;
|
return sc;
|
end ew_str_cat;
|
end ew_str_cat;
|
|
|
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
-- fld_len field length
|
-- fld_len field length
|
-- inputs : string of type text_field
|
-- inputs : string of type text_field
|
-- return : integer number of non 'nul' chars
|
-- return : integer number of non 'nul' chars
|
function fld_len(s : in text_field) return integer is
|
function fld_len(s : in text_field) return integer is
|
variable i: integer := 1;
|
variable i: integer := 1;
|
begin
|
begin
|
while(s(i) /= nul) loop
|
while(s(i) /= nul) loop
|
i := i + 1;
|
i := i + 1;
|
end loop;
|
end loop;
|
return (i - 1);
|
return (i - 1);
|
end fld_len;
|
end fld_len;
|
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
-- c2int convert character to integer
|
-- c2int convert character to integer
|
function c2int(c: in character) return integer is
|
function c2int(c: in character) return integer is
|
variable i: integer;
|
variable i: integer;
|
begin
|
begin
|
i := -1;
|
i := -1;
|
case c is
|
case c is
|
when '0' => i := 0;
|
when '0' => i := 0;
|
when '1' => i := 1;
|
when '1' => i := 1;
|
when '2' => i := 2;
|
when '2' => i := 2;
|
when '3' => i := 3;
|
when '3' => i := 3;
|
when '4' => i := 4;
|
when '4' => i := 4;
|
when '5' => i := 5;
|
when '5' => i := 5;
|
when '6' => i := 6;
|
when '6' => i := 6;
|
when '7' => i := 7;
|
when '7' => i := 7;
|
when '8' => i := 8;
|
when '8' => i := 8;
|
when '9' => i := 9;
|
when '9' => i := 9;
|
when others =>
|
when others =>
|
assert(false)
|
assert(false)
|
report LF & "Error: c2int was given a non Number didgit."
|
report LF & "Error: c2int was given a non Number didgit."
|
severity failure;
|
severity failure;
|
end case;
|
end case;
|
return i;
|
return i;
|
end c2int;
|
end c2int;
|
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
-- str2integer Convert a string to integer number.
|
-- str2integer Convert a string to integer number.
|
-- inputs : string
|
-- inputs : string
|
-- output : int value
|
-- output : int value
|
function str2integer(str: in string) return integer is
|
function str2integer(str: in string) return integer is
|
variable l: integer;
|
variable l: integer;
|
variable j: integer := 1;
|
variable j: integer := 1;
|
variable rtn: integer := 0;
|
variable rtn: integer := 0;
|
begin
|
begin
|
l := fld_len(str);
|
l := fld_len(str);
|
|
|
for i in l downto 1 loop
|
for i in l downto 1 loop
|
rtn := rtn + (c2int(str(j)) *(10**(i - 1)));
|
rtn := rtn + (c2int(str(j)) *(10**(i - 1)));
|
j := j + 1;
|
j := j + 1;
|
end loop;
|
end loop;
|
|
|
return rtn;
|
return rtn;
|
end str2integer;
|
end str2integer;
|
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
-- hex2integer convert hex Stimulus field to integer
|
-- hex2integer convert hex Stimulus field to integer
|
-- inputs : string of type text_field containing only Hex numbers
|
-- inputs : string of type text_field containing only Hex numbers
|
-- return : integer value
|
-- return : integer value
|
function hex2integer(hex_number: in text_field;
|
function hex2integer(hex_number: 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 temp_field: text_field;
|
variable temp_field: text_field;
|
variable temp_int: integer;
|
variable temp_int: integer;
|
variable power: integer;
|
variable power: integer;
|
variable int_number: integer;
|
variable int_number: integer;
|
begin
|
begin
|
len := fld_len(hex_number);
|
len := fld_len(hex_number);
|
power := 0;
|
power := 0;
|
temp_int := 0;
|
temp_int := 0;
|
for i in len downto 1 loop
|
for i in len downto 1 loop
|
case hex_number(i) is
|
case hex_number(i) is
|
when '0' =>
|
when '0' =>
|
int_number := 0;
|
int_number := 0;
|
when '1' =>
|
when '1' =>
|
int_number := 1;
|
int_number := 1;
|
when '2' =>
|
when '2' =>
|
int_number := 2;
|
int_number := 2;
|
when '3' =>
|
when '3' =>
|
int_number := 3;
|
int_number := 3;
|
when '4' =>
|
when '4' =>
|
int_number := 4;
|
int_number := 4;
|
when '5' =>
|
when '5' =>
|
int_number := 5;
|
int_number := 5;
|
when '6' =>
|
when '6' =>
|
int_number := 6;
|
int_number := 6;
|
when '7' =>
|
when '7' =>
|
int_number := 7;
|
int_number := 7;
|
when '8' =>
|
when '8' =>
|
int_number := 8;
|
int_number := 8;
|
when '9' =>
|
when '9' =>
|
int_number := 9;
|
int_number := 9;
|
when 'a' | 'A'=>
|
when 'a' | 'A'=>
|
int_number := 10;
|
int_number := 10;
|
when 'b' | 'B'=>
|
when 'b' | 'B'=>
|
int_number := 11;
|
int_number := 11;
|
when 'c' | 'C'=>
|
when 'c' | 'C'=>
|
int_number := 12;
|
int_number := 12;
|
when 'd' | 'D'=>
|
when 'd' | 'D'=>
|
int_number := 13;
|
int_number := 13;
|
when 'e' | 'E'=>
|
when 'e' | 'E'=>
|
int_number := 14;
|
int_number := 14;
|
when 'f' | 'F'=>
|
when 'f' | 'F'=>
|
int_number := 15;
|
int_number := 15;
|
when others =>
|
when others =>
|
assert(false)
|
assert(false)
|
report LF & "Error: hex2integer found non Hex didgit on line "
|
report LF & "Error: hex2integer found non Hex 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;
|
|
|
temp_int := temp_int + (int_number *(16 ** power));
|
temp_int := temp_int + (int_number *(16 ** power));
|
power := power + 1;
|
power := power + 1;
|
end loop;
|
end loop;
|
|
|
return temp_int;
|
return temp_int;
|
end hex2integer;
|
end hex2integer;
|
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
-- convert character to 4 bit vector
|
-- convert character to 4 bit vector
|
-- input character
|
-- input character
|
-- output std_logic_vector 4 bits
|
-- output std_logic_vector 4 bits
|
function c2std_vec(c: in character) return std_logic_vector is
|
function c2std_vec(c: in character) return std_logic_vector is
|
begin
|
begin
|
case c is
|
case c is
|
when '0' => return "0000";
|
when '0' => return "0000";
|
when '1' => return "0001";
|
when '1' => return "0001";
|
when '2' => return "0010";
|
when '2' => return "0010";
|
when '3' => return "0011";
|
when '3' => return "0011";
|
when '4' => return "0100";
|
when '4' => return "0100";
|
when '5' => return "0101";
|
when '5' => return "0101";
|
when '6' => return "0110";
|
when '6' => return "0110";
|
when '7' => return "0111";
|
when '7' => return "0111";
|
when '8' => return "1000";
|
when '8' => return "1000";
|
when '9' => return "1001";
|
when '9' => return "1001";
|
when 'a' | 'A' => return "1010";
|
when 'a' | 'A' => return "1010";
|
when 'b' | 'B' => return "1011";
|
when 'b' | 'B' => return "1011";
|
when 'c' | 'C' => return "1100";
|
when 'c' | 'C' => return "1100";
|
when 'd' | 'D' => return "1101";
|
when 'd' | 'D' => return "1101";
|
when 'e' | 'E' => return "1110";
|
when 'e' | 'E' => return "1110";
|
when 'f' | 'F' => return "1111";
|
when 'f' | 'F' => return "1111";
|
when others =>
|
when others =>
|
assert(false)
|
assert(false)
|
report LF & "Error: c2std_vec found non Hex didgit on file line "
|
report LF & "Error: c2std_vec found non Hex didgit on file line "
|
severity failure;
|
severity failure;
|
return "XXXX";
|
return "XXXX";
|
end case;
|
end case;
|
end c2std_vec;
|
end c2std_vec;
|
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
-- std_vec2c convert 4 bit std_vector to a character
|
-- std_vec2c convert 4 bit std_vector to a character
|
-- input std_logic_vector 4 bits
|
-- input std_logic_vector 4 bits
|
-- output character
|
-- output character
|
function std_vec2c(vec: in std_logic_vector(3 downto 0)) return character is
|
function std_vec2c(vec: in std_logic_vector(3 downto 0)) return character is
|
begin
|
begin
|
case vec is
|
case vec is
|
when "0000" => return '0';
|
when "0000" => return '0';
|
when "0001" => return '1';
|
when "0001" => return '1';
|
when "0010" => return '2';
|
when "0010" => return '2';
|
when "0011" => return '3';
|
when "0011" => return '3';
|
when "0100" => return '4';
|
when "0100" => return '4';
|
when "0101" => return '5';
|
when "0101" => return '5';
|
when "0110" => return '6';
|
when "0110" => return '6';
|
when "0111" => return '7';
|
when "0111" => return '7';
|
when "1000" => return '8';
|
when "1000" => return '8';
|
when "1001" => return '9';
|
when "1001" => return '9';
|
when "1010" => return 'A';
|
when "1010" => return 'A';
|
when "1011" => return 'B';
|
when "1011" => return 'B';
|
when "1100" => return 'C';
|
when "1100" => return 'C';
|
when "1101" => return 'D';
|
when "1101" => return 'D';
|
when "1110" => return 'E';
|
when "1110" => return 'E';
|
when "1111" => return 'F';
|
when "1111" => return 'F';
|
when others =>
|
when others =>
|
assert(false)
|
assert(false)
|
report LF & "Error: std_vec2c found non-binary didgit in vec "
|
report LF & "Error: std_vec2c found non-binary didgit in vec "
|
severity failure;
|
severity failure;
|
return 'X';
|
return 'X';
|
end case;
|
end case;
|
end std_vec2c;
|
end std_vec2c;
|
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
-- bin2integer convert bin Stimulus field to integer
|
-- bin2integer convert bin Stimulus field to integer
|
-- inputs : string of type text_field containing only binary numbers
|
-- inputs : string of type text_field containing only binary numbers
|
-- return : integer value
|
-- return : integer value
|
function bin2integer(bin_number: in text_field;
|
function bin2integer(bin_number: 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 temp_field: text_field;
|
variable temp_field: text_field;
|
variable temp_int: integer;
|
variable temp_int: integer;
|
variable power: integer;
|
variable power: integer;
|
variable int_number: integer;
|
variable int_number: integer;
|
begin
|
begin
|
len := fld_len(bin_number);
|
len := fld_len(bin_number);
|
power := 0;
|
power := 0;
|
temp_int := 0;
|
temp_int := 0;
|
for i in len downto 1 loop
|
for i in len downto 1 loop
|
case bin_number(i) is
|
case bin_number(i) is
|
when '0' =>
|
when '0' =>
|
int_number := 0;
|
int_number := 0;
|
when '1' =>
|
when '1' =>
|
int_number := 1;
|
int_number := 1;
|
when others =>
|
when others =>
|
assert(false)
|
assert(false)
|
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;
|
|
|
temp_int := temp_int + (int_number *(2 ** power));
|
temp_int := temp_int + (int_number *(2 ** power));
|
power := power + 1;
|
power := power + 1;
|
end loop;
|
end loop;
|
|
|
return temp_int;
|
return temp_int;
|
end bin2integer;
|
end bin2integer;
|
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
-- stim_to_integer convert Stimulus field to integer
|
-- stim_to_integer convert Stimulus field to integer
|
-- inputs : string of type text_field "stimulus format of number"
|
-- inputs : string of type text_field "stimulus format of number"
|
-- 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 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);
|
|
|
case field(1) is
|
case field(1) is
|
when 'x' | 'h' =>
|
when 'x' | 'h' =>
|
value := 2;
|
value := 2;
|
while(field(value) /= nul) loop
|
while(field(value) /= nul) loop
|
temp_str(value - 1) := field(value);
|
temp_str(value - 1) := field(value);
|
value := value + 1;
|
value := value + 1;
|
end loop;
|
end loop;
|
value := hex2integer(temp_str,file_name,line);
|
value := hex2integer(temp_str,file_name,line);
|
when 'b' =>
|
when 'b' =>
|
value := 2;
|
value := 2;
|
while(field(value) /= nul) loop
|
while(field(value) /= nul) loop
|
temp_str(value - 1) := field(value);
|
temp_str(value - 1) := field(value);
|
value := value + 1;
|
value := value + 1;
|
end loop;
|
end loop;
|
value := bin2integer(temp_str,file_name,line);
|
value := bin2integer(temp_str,file_name,line);
|
when others =>
|
when others =>
|
-- value := from_string(field(1 to len));
|
-- value := from_string(field(1 to len));
|
value := str2integer(field);
|
value := str2integer(field);
|
end case;
|
end case;
|
return value;
|
return value;
|
end stim_to_integer;
|
end stim_to_integer;
|
|
|
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
-- to_str function with base parameter
|
-- to_str function with base parameter
|
-- Convert integer to number base
|
-- Convert integer to number base
|
function ew_to_str(int: integer; b: base) return text_field is
|
function ew_to_str(int: integer; b: base) return text_field is
|
|
|
variable temp : text_field ;
|
variable temp : text_field ;
|
variable temp1 : text_field ;
|
variable temp1 : text_field ;
|
variable radix : integer := 0;
|
variable radix : integer := 0;
|
variable num : integer := 0;
|
variable num : integer := 0;
|
variable power : integer := 1;
|
variable power : integer := 1;
|
variable len : integer := 1;
|
variable len : integer := 1;
|
variable pre : string(1 to 2);
|
variable pre : string(1 to 2);
|
variable i : integer;
|
variable i : integer;
|
variable j : integer;
|
variable j : integer;
|
variable vec : std_logic_vector(31 downto 0);
|
variable vec : std_logic_vector(31 downto 0);
|
|
|
begin
|
begin
|
|
|
num := int;
|
num := int;
|
temp := (others => nul);
|
temp := (others => nul);
|
case b is
|
case b is
|
when bin =>
|
when bin =>
|
radix := 2; -- depending on what
|
radix := 2; -- depending on what
|
pre := "0b";
|
pre := "0b";
|
when oct =>
|
when oct =>
|
radix := 8; -- base the number is
|
radix := 8; -- base the number is
|
pre := "0o";
|
pre := "0o";
|
when hex =>
|
when hex =>
|
radix := 16; -- to be displayed as
|
radix := 16; -- to be displayed as
|
pre := "0x";
|
pre := "0x";
|
when dec =>
|
when dec =>
|
radix := 10; -- choose a radix range
|
radix := 10; -- choose a radix range
|
pre := (others => nul);
|
pre := (others => nul);
|
end case ;
|
end case ;
|
-- Now jump through Hoops because of sign
|
-- Now jump through Hoops because of sign
|
if(num < 0 and b = hex) then
|
if(num < 0 and b = hex) then
|
vec := std_logic_vector(conv_unsigned(int, 32));
|
vec := std_logic_vector(conv_unsigned(int, 32));
|
temp(1) := std_vec2c(vec(31 downto 28));
|
temp(1) := std_vec2c(vec(31 downto 28));
|
temp(2) := std_vec2c(vec(27 downto 24));
|
temp(2) := std_vec2c(vec(27 downto 24));
|
temp(3) := std_vec2c(vec(23 downto 20));
|
temp(3) := std_vec2c(vec(23 downto 20));
|
temp(4) := std_vec2c(vec(19 downto 16));
|
temp(4) := std_vec2c(vec(19 downto 16));
|
temp(5) := std_vec2c(vec(15 downto 12));
|
temp(5) := std_vec2c(vec(15 downto 12));
|
temp(6) := std_vec2c(vec(11 downto 8));
|
temp(6) := std_vec2c(vec(11 downto 8));
|
temp(7) := std_vec2c(vec(7 downto 4));
|
temp(7) := std_vec2c(vec(7 downto 4));
|
temp(8) := std_vec2c(vec(3 downto 0));
|
temp(8) := std_vec2c(vec(3 downto 0));
|
else
|
else
|
while num >= radix loop -- determine how many
|
while num >= radix loop -- determine how many
|
len := len + 1; -- characters required
|
len := len + 1; -- characters required
|
num := num / radix; -- to represent the
|
num := num / radix; -- to represent the
|
end loop ; -- number.
|
end loop ; -- number.
|
for i in len downto 1 loop -- convert the number to
|
for i in len downto 1 loop -- convert the number to
|
temp(i) := ew_to_char(int/power mod radix); -- a string starting
|
temp(i) := ew_to_char(int/power mod radix); -- a string starting
|
power := power * radix; -- with the right hand
|
power := power * radix; -- with the right hand
|
end loop ; -- side.
|
end loop ; -- side.
|
end if;
|
end if;
|
-- add prefix if is one
|
-- add prefix if is one
|
if(pre(1) /= nul) then
|
if(pre(1) /= nul) then
|
temp1 := temp;
|
temp1 := temp;
|
i := 1;
|
i := 1;
|
j := 3;
|
j := 3;
|
temp(1 to 2) := pre;
|
temp(1 to 2) := pre;
|
while(temp1(i) /= nul) loop
|
while(temp1(i) /= nul) loop
|
temp(j) := temp1(i);
|
temp(j) := temp1(i);
|
i := i + 1;
|
i := i + 1;
|
j := j + 1;
|
j := j + 1;
|
end loop;
|
end loop;
|
end if;
|
end if;
|
|
|
return temp;
|
return temp;
|
|
|
end ew_to_str ;
|
end ew_to_str ;
|
|
|
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
-- Procedure to print instruction records to stdout *for debug*
|
-- Procedure to print instruction records to stdout *for debug*
|
procedure print_inst(variable inst : in stim_line_ptr) is
|
procedure print_inst(variable inst : in stim_line_ptr) is
|
variable l: text_line;
|
variable l: text_line;
|
variable l_i: integer := 1;
|
variable l_i: integer := 1;
|
variable j: integer := 1;
|
variable j: integer := 1;
|
begin
|
begin
|
while (inst.instruction(j) /= nul) loop
|
while (inst.instruction(j) /= nul) loop
|
l(l_i) := inst.instruction(j);
|
l(l_i) := inst.instruction(j);
|
j := j +1;
|
j := j +1;
|
l_i := l_i + 1;
|
l_i := l_i + 1;
|
end loop;
|
end loop;
|
|
|
l(l_i) := ' ';
|
l(l_i) := ' ';
|
l_i := l_i + 1;
|
l_i := l_i + 1;
|
j := 1;
|
j := 1;
|
-- field one
|
-- field one
|
if(inst.inst_field_1(1) /= nul) then
|
if(inst.inst_field_1(1) /= nul) then
|
while (inst.inst_field_1(j) /= nul) loop
|
while (inst.inst_field_1(j) /= nul) loop
|
l(l_i) := inst.inst_field_1(j);
|
l(l_i) := inst.inst_field_1(j);
|
j := j +1;
|
j := j +1;
|
l_i := l_i + 1;
|
l_i := l_i + 1;
|
end loop;
|
end loop;
|
l(l_i) := ' ';
|
l(l_i) := ' ';
|
l_i := l_i + 1;
|
l_i := l_i + 1;
|
j := 1;
|
j := 1;
|
-- field two
|
-- field two
|
if(inst.inst_field_2(1) /= nul) then
|
if(inst.inst_field_2(1) /= nul) then
|
while (inst.inst_field_2(j) /= nul) loop
|
while (inst.inst_field_2(j) /= nul) loop
|
l(l_i) := inst.inst_field_2(j);
|
l(l_i) := inst.inst_field_2(j);
|
j := j +1;
|
j := j +1;
|
l_i := l_i + 1;
|
l_i := l_i + 1;
|
end loop;
|
end loop;
|
l(l_i) := ' ';
|
l(l_i) := ' ';
|
l_i := l_i + 1;
|
l_i := l_i + 1;
|
j := 1;
|
j := 1;
|
-- field three
|
-- field three
|
if(inst.inst_field_3(1) /= nul) then
|
if(inst.inst_field_3(1) /= nul) then
|
while (inst.inst_field_3(j) /= nul) loop
|
while (inst.inst_field_3(j) /= nul) loop
|
l(l_i) := inst.inst_field_3(j);
|
l(l_i) := inst.inst_field_3(j);
|
j := j +1;
|
j := j +1;
|
l_i := l_i + 1;
|
l_i := l_i + 1;
|
end loop;
|
end loop;
|
l(l_i) := ' ';
|
l(l_i) := ' ';
|
l_i := l_i + 1;
|
l_i := l_i + 1;
|
j := 1;
|
j := 1;
|
-- field four
|
-- field four
|
if(inst.inst_field_4(1) /= nul) then
|
if(inst.inst_field_4(1) /= nul) then
|
while (inst.inst_field_4(j) /= nul) loop
|
while (inst.inst_field_4(j) /= nul) loop
|
l(l_i) := inst.inst_field_4(j);
|
l(l_i) := inst.inst_field_4(j);
|
j := j +1;
|
j := j +1;
|
l_i := l_i + 1;
|
l_i := l_i + 1;
|
end loop;
|
end loop;
|
end if;
|
end if;
|
end if;
|
end if;
|
end if;
|
end if;
|
end if;
|
end if;
|
print(l);
|
print(l);
|
|
|
print(" Sequence Number: " & to_str(inst.line_number) &
|
print(" Sequence Number: " & to_str(inst.line_number) &
|
" File Line Number: " & to_str(inst.file_line));
|
" File Line Number: " & to_str(inst.file_line));
|
if(inst.num_of_lines > 0) then
|
if(inst.num_of_lines > 0) then
|
print(" Number of Lines: " & to_str(inst.num_of_lines));
|
print(" Number of Lines: " & to_str(inst.num_of_lines));
|
end if;
|
end if;
|
end print_inst;
|
end print_inst;
|
|
|
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
-- access_variable
|
-- access_variable
|
-- inputs:
|
-- inputs:
|
-- Text field containing variable
|
-- Text field containing variable
|
-- outputs:
|
-- outputs:
|
-- value $VAR returns Value of VAR
|
-- value $VAR returns Value of VAR
|
-- value VAR returns index of VAR
|
-- value VAR returns index of VAR
|
--
|
--
|
-- valid is 1 if valid 0 if not
|
-- valid is 1 if valid 0 if not
|
procedure access_variable(variable var_list : in var_field_ptr;
|
procedure access_variable(variable var_list : in var_field_ptr;
|
variable var : in text_field;
|
variable var : in text_field;
|
variable value : out integer;
|
variable value : out integer;
|
variable valid : out integer) is
|
variable valid : out integer) is
|
variable l : integer;
|
variable l : integer;
|
variable l_2 : integer;
|
variable l_2 : integer;
|
variable var_ptr : var_field_ptr;
|
variable var_ptr : var_field_ptr;
|
variable temp_field : text_field;
|
variable temp_field : text_field;
|
variable ptr : integer := 0; -- 0 is index, 1 is pointer
|
variable ptr : integer := 0; -- 0 is index, 1 is pointer
|
begin
|
begin
|
l := fld_len(var);
|
l := fld_len(var);
|
valid := 0;
|
valid := 0;
|
-- if the variable is a special
|
-- if the variable is a special
|
if(var(1) = '=') then
|
if(var(1) = '=') then
|
value := 0;
|
value := 0;
|
valid := 1;
|
valid := 1;
|
elsif(var(1 to 2) = ">=") then
|
elsif(var(1 to 2) = ">=") then
|
value := 4;
|
value := 4;
|
valid := 1;
|
valid := 1;
|
elsif(var(1 to 2) = "<=") then
|
elsif(var(1 to 2) = "<=") then
|
value := 5;
|
value := 5;
|
valid := 1;
|
valid := 1;
|
elsif(var(1) = '>') then
|
elsif(var(1) = '>') then
|
value := 1;
|
value := 1;
|
valid := 1;
|
valid := 1;
|
elsif(var(1) = '<') then
|
elsif(var(1) = '<') then
|
value := 2;
|
value := 2;
|
valid := 1;
|
valid := 1;
|
elsif(var(1 to 2) = "!=") then
|
elsif(var(1 to 2) = "!=") then
|
value := 3;
|
value := 3;
|
valid := 1;
|
valid := 1;
|
|
|
else
|
else
|
if(var(1) = '$') then
|
if(var(1) = '$') then
|
ptr := 1; -- this is a pointer
|
ptr := 1; -- this is a pointer
|
for i in 2 to l loop
|
for i in 2 to l loop
|
temp_field(i-1) := var(i);
|
temp_field(i-1) := var(i);
|
end loop;
|
end loop;
|
else
|
else
|
temp_field := var;
|
temp_field := var;
|
end if;
|
end if;
|
|
|
var_ptr := var_list;
|
var_ptr := var_list;
|
while(var_ptr.next_rec /= null) loop
|
while(var_ptr.next_rec /= null) loop
|
-- if we have a match
|
-- if we have a match
|
if(temp_field = var_ptr.var_name) then
|
if(temp_field = var_ptr.var_name) then
|
if(ptr = 1) then
|
if(ptr = 1) then
|
value := var_ptr.var_value;
|
value := var_ptr.var_value;
|
valid := 1;
|
valid := 1;
|
else
|
else
|
value := var_ptr.var_index;
|
value := var_ptr.var_index;
|
valid := 1;
|
valid := 1;
|
end if;
|
end if;
|
exit;
|
exit;
|
end if;
|
end if;
|
var_ptr := var_ptr.next_rec;
|
var_ptr := var_ptr.next_rec;
|
end loop;
|
end loop;
|
|
|
-- if we have a match and was the last record
|
-- if we have a match and was the last record
|
if(var_ptr.next_rec = null and temp_field = var_ptr.var_name) then
|
if(var_ptr.next_rec = null and temp_field = var_ptr.var_name) then
|
if(ptr = 1) then
|
if(ptr = 1) then
|
value := var_ptr.var_value;
|
value := var_ptr.var_value;
|
valid := 1;
|
valid := 1;
|
else
|
else
|
value := var_ptr.var_index;
|
value := var_ptr.var_index;
|
valid := 1;
|
valid := 1;
|
end if;
|
end if;
|
end if;
|
end if;
|
end if;
|
end if;
|
end access_variable;
|
end access_variable;
|
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
-- index_variable
|
-- index_variable
|
-- inputs:
|
-- inputs:
|
-- index: the index of the variable being accessed
|
-- index: the index of the variable being accessed
|
-- outputs:
|
-- outputs:
|
-- Variable Value
|
-- Variable Value
|
-- valid is 1 if valid 0 if not
|
-- valid is 1 if valid 0 if not
|
procedure index_variable(variable var_list : in var_field_ptr;
|
procedure index_variable(variable var_list : in var_field_ptr;
|
variable index : in integer;
|
variable index : in integer;
|
variable value : out integer;
|
variable value : out integer;
|
variable valid : out integer) is
|
variable valid : out integer) is
|
variable ptr: var_field_ptr;
|
variable ptr: var_field_ptr;
|
begin
|
begin
|
ptr := var_list;
|
ptr := var_list;
|
valid := 0;
|
valid := 0;
|
while(ptr.next_rec /= null) loop
|
while(ptr.next_rec /= null) loop
|
if(ptr.var_index = index) then
|
if(ptr.var_index = index) then
|
value := ptr.var_value;
|
value := ptr.var_value;
|
valid := 1;
|
valid := 1;
|
exit;
|
exit;
|
end if;
|
end if;
|
ptr := ptr.next_rec;
|
ptr := ptr.next_rec;
|
end loop;
|
end loop;
|
if(ptr.var_index = index) then
|
if(ptr.var_index = index) then
|
value := ptr.var_value;
|
value := ptr.var_value;
|
valid := 1;
|
valid := 1;
|
end if;
|
end if;
|
end index_variable;
|
end index_variable;
|
|
|
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
-- update_variable
|
-- update_variable
|
-- inputs:
|
-- inputs:
|
-- index: the index of the variable being updated
|
-- index: the index of the variable being updated
|
-- outputs:
|
-- outputs:
|
-- valid is 1 if valid 0 if not
|
-- valid is 1 if valid 0 if not
|
procedure update_variable(variable var_list : in var_field_ptr;
|
procedure update_variable(variable var_list : in var_field_ptr;
|
variable index : in integer;
|
variable index : in integer;
|
variable value : in integer;
|
variable value : in integer;
|
variable valid : out integer) is
|
variable valid : out integer) is
|
variable ptr: var_field_ptr;
|
variable ptr: var_field_ptr;
|
begin
|
begin
|
ptr := var_list;
|
ptr := var_list;
|
valid := 0;
|
valid := 0;
|
while(ptr.next_rec /= null) loop
|
while(ptr.next_rec /= null) loop
|
if(ptr.var_index = index) then
|
if(ptr.var_index = index) then
|
ptr.var_value := value;
|
ptr.var_value := value;
|
valid := 1;
|
valid := 1;
|
exit;
|
exit;
|
end if;
|
end if;
|
ptr := ptr.next_rec;
|
ptr := ptr.next_rec;
|
end loop;
|
end loop;
|
-- check the current one
|
-- check the current one
|
if(ptr.var_index = index) then
|
if(ptr.var_index = index) then
|
ptr.var_value := value;
|
ptr.var_value := value;
|
valid := 1;
|
valid := 1;
|
end if;
|
end if;
|
end update_variable;
|
end update_variable;
|
|
|
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
-- Read a line from a file
|
-- Read a line from a file
|
-- inputs : file of type text
|
-- inputs : file of type text
|
-- outputs : The line of type text_line
|
-- outputs : The line of type text_line
|
procedure file_read_line(file file_name: text;
|
procedure file_read_line(file file_name: text;
|
variable file_line: out text_line
|
variable file_line: out text_line
|
) is
|
) is
|
variable index: integer; -- index into string
|
variable index: integer; -- index into string
|
variable rline: line;
|
variable rline: line;
|
|
|
begin
|
begin
|
|
|
index := 1; -- set index to begin of string
|
index := 1; -- set index to begin of string
|
file_line := (others => nul);
|
file_line := (others => nul);
|
if(not endfile(file_name)) then
|
if(not endfile(file_name)) then
|
readline(file_name,rline);
|
readline(file_name,rline);
|
|
|
while(rline'right /= (index - 1) and rline'length /= 0) loop
|
while(rline'right /= (index - 1) and rline'length /= 0) loop
|
file_line(index) := rline(index);
|
file_line(index) := rline(index);
|
index := index + 1;
|
index := index + 1;
|
end loop;
|
end loop;
|
end if;
|
end if;
|
end file_read_line;
|
end file_read_line;
|
|
|
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
-- procedure to break a line down in to text fields
|
-- procedure to break a line down in to text fields
|
procedure tokenize_line(variable text_line: in text_line;
|
procedure tokenize_line(variable text_line: in text_line;
|
variable token1: out text_field;
|
variable token1: out text_field;
|
variable token2: out text_field;
|
variable token2: out text_field;
|
variable token3: out text_field;
|
variable token3: out text_field;
|
variable token4: out text_field;
|
variable token4: out text_field;
|
variable token5: out text_field;
|
variable token5: out text_field;
|
variable token6: out text_field;
|
variable token6: out text_field;
|
variable token7: out text_field;
|
variable token7: out text_field;
|
variable txt_ptr: out stm_text_ptr;
|
variable txt_ptr: out stm_text_ptr;
|
variable valid: out integer) is
|
variable valid: out integer) is
|
variable token_index: integer := 0;
|
variable token_index: integer := 0;
|
variable current_token: text_field;
|
variable current_token: text_field;
|
variable token_number: integer := 0;
|
variable token_number: integer := 0;
|
variable c: string(1 to 2);
|
variable c: string(1 to 2);
|
variable comment_found: integer := 0;
|
variable comment_found: integer := 0;
|
variable txt_found: integer := 0;
|
variable txt_found: integer := 0;
|
variable j: integer;
|
variable j: integer;
|
|
|
begin
|
begin
|
-- null outputs
|
-- null outputs
|
token1 := (others => nul);
|
token1 := (others => nul);
|
token2 := (others => nul);
|
token2 := (others => nul);
|
token3 := (others => nul);
|
token3 := (others => nul);
|
token4 := (others => nul);
|
token4 := (others => nul);
|
token5 := (others => nul);
|
token5 := (others => nul);
|
token6 := (others => nul);
|
token6 := (others => nul);
|
token7 := (others => nul);
|
token7 := (others => nul);
|
txt_ptr := null;
|
txt_ptr := null;
|
valid := 0;
|
valid := 0;
|
txt_found := 0;
|
txt_found := 0;
|
j := 1;
|
j := 1;
|
|
|
-- loop for max number of char
|
-- loop for max number of char
|
for i in 1 to text_line'high loop
|
for i in 1 to text_line'high loop
|
-- collect for comment test ** assumed no line will be max 256
|
-- collect for comment test ** assumed no line will be max 256
|
c(1) := text_line(i);
|
c(1) := text_line(i);
|
c(2) := text_line(i + 1); -- or this line will blow up
|
c(2) := text_line(i + 1); -- or this line will blow up
|
if(c = "--") then
|
if(c = "--") then
|
comment_found := 1;
|
comment_found := 1;
|
exit;
|
exit;
|
end if;
|
end if;
|
-- if is begin text char '"'
|
-- if is begin text char '"'
|
if(c(1) = '"') then --" <-- this double quote is just to fix highlighting.
|
if(c(1) = '"') then --" <-- this double quote is just to fix highlighting.
|
txt_found := 1;
|
txt_found := 1;
|
txt_ptr := new stm_text;
|
txt_ptr := new stm_text;
|
next;
|
next;
|
end if;
|
end if;
|
|
|
-- if we have found a txt string
|
-- if we have found a txt string
|
if (txt_found = 1 and text_line(i) /= nul) then
|
if (txt_found = 1 and text_line(i) /= nul) then
|
-- if string too long, prevent tool hang, truncate and notify
|
-- if string too long, prevent tool hang, truncate and notify
|
if(j > c_stm_text_len) then
|
if(j > c_stm_text_len) then
|
print("tokenize_line: truncated txt line, it was larger than c_stm_text_len");
|
print("tokenize_line: truncated txt line, it was larger than c_stm_text_len");
|
exit;
|
exit;
|
end if;
|
end if;
|
txt_ptr(j) := text_line(i);
|
txt_ptr(j) := text_line(i);
|
j := j + 1;
|
j := j + 1;
|
-- if is a character store in the right token
|
-- if is a character store in the right token
|
elsif(is_space(text_line(i)) = false and text_line(i) /= nul) then
|
elsif(is_space(text_line(i)) = false and text_line(i) /= nul) then
|
token_index := token_index + 1;
|
token_index := token_index + 1;
|
current_token(token_index) := text_line(i);
|
current_token(token_index) := text_line(i);
|
-- else is a space, deal with pointers
|
-- else is a space, deal with pointers
|
elsif(is_space(text_line(i + 1)) = false and text_line(i + 1) /= nul) then
|
elsif(is_space(text_line(i + 1)) = false and text_line(i + 1) /= nul) then
|
case token_number is
|
case token_number is
|
when 0 =>
|
when 0 =>
|
if(token_index /= 0) then
|
if(token_index /= 0) then
|
token1 := current_token;
|
token1 := current_token;
|
current_token := (others => nul);
|
current_token := (others => nul);
|
token_number := 1;
|
token_number := 1;
|
valid := 1;
|
valid := 1;
|
token_index := 0;
|
token_index := 0;
|
end if;
|
end if;
|
when 1 =>
|
when 1 =>
|
token2 := current_token;
|
token2 := current_token;
|
current_token := (others => nul);
|
current_token := (others => nul);
|
token_number := 2;
|
token_number := 2;
|
valid := 2;
|
valid := 2;
|
token_index := 0;
|
token_index := 0;
|
when 2 =>
|
when 2 =>
|
token3 := current_token;
|
token3 := current_token;
|
current_token := (others => nul);
|
current_token := (others => nul);
|
token_number := 3;
|
token_number := 3;
|
valid := 3;
|
valid := 3;
|
token_index := 0;
|
token_index := 0;
|
when 3 =>
|
when 3 =>
|
token4 := current_token;
|
token4 := current_token;
|
current_token := (others => nul);
|
current_token := (others => nul);
|
token_number := 4;
|
token_number := 4;
|
valid := 4;
|
valid := 4;
|
token_index := 0;
|
token_index := 0;
|
when 4 =>
|
when 4 =>
|
token5 := current_token;
|
token5 := current_token;
|
current_token := (others => nul);
|
current_token := (others => nul);
|
token_number := 5;
|
token_number := 5;
|
valid := 5;
|
valid := 5;
|
token_index := 0;
|
token_index := 0;
|
when 5 =>
|
when 5 =>
|
token6 := current_token;
|
token6 := current_token;
|
current_token := (others => nul);
|
current_token := (others => nul);
|
token_number := 6;
|
token_number := 6;
|
valid := 6;
|
valid := 6;
|
token_index := 0;
|
token_index := 0;
|
when 6 =>
|
when 6 =>
|
token7 := current_token;
|
token7 := current_token;
|
current_token := (others => nul);
|
current_token := (others => nul);
|
token_number := 7;
|
token_number := 7;
|
valid := 7;
|
valid := 7;
|
token_index := 0;
|
token_index := 0;
|
when 7 =>
|
when 7 =>
|
when others =>
|
when others =>
|
null;
|
null;
|
end case;
|
end case;
|
end if;
|
end if;
|
-- break from loop if is null
|
-- break from loop if is null
|
if(text_line(i) = nul) then
|
if(text_line(i) = nul) then
|
if(token_index /= 0) then
|
if(token_index /= 0) then
|
case token_number is
|
case token_number is
|
when 0 =>
|
when 0 =>
|
token1 := current_token;
|
token1 := current_token;
|
valid := 1;
|
valid := 1;
|
when 1 =>
|
when 1 =>
|
token2 := current_token;
|
token2 := current_token;
|
valid := 2;
|
valid := 2;
|
when 2 =>
|
when 2 =>
|
token3 := current_token;
|
token3 := current_token;
|
valid := 3;
|
valid := 3;
|
when 3 =>
|
when 3 =>
|
token4 := current_token;
|
token4 := current_token;
|
valid := 4;
|
valid := 4;
|
when 4 =>
|
when 4 =>
|
token5 := current_token;
|
token5 := current_token;
|
valid := 5;
|
valid := 5;
|
when 5 =>
|
when 5 =>
|
token6 := current_token;
|
token6 := current_token;
|
valid := 6;
|
valid := 6;
|
when 6 =>
|
when 6 =>
|
token7 := current_token;
|
token7 := current_token;
|
valid := 7;
|
valid := 7;
|
when others =>
|
when others =>
|
null;
|
null;
|
end case;
|
end case;
|
end if;
|
end if;
|
exit;
|
exit;
|
end if;
|
end if;
|
end loop;
|
end loop;
|
-- did we find a comment and there is a token
|
-- did we find a comment and there is a token
|
if(comment_found = 1) then
|
if(comment_found = 1) then
|
if(token_index /= 0) then
|
if(token_index /= 0) then
|
case token_number is
|
case token_number is
|
when 0 =>
|
when 0 =>
|
token1 := current_token;
|
token1 := current_token;
|
valid := 1;
|
valid := 1;
|
when 1 =>
|
when 1 =>
|
token2 := current_token;
|
token2 := current_token;
|
valid := 2;
|
valid := 2;
|
when 2 =>
|
when 2 =>
|
token3 := current_token;
|
token3 := current_token;
|
valid := 3;
|
valid := 3;
|
when 3 =>
|
when 3 =>
|
token4 := current_token;
|
token4 := current_token;
|
valid := 4;
|
valid := 4;
|
when 4 =>
|
when 4 =>
|
token5 := current_token;
|
token5 := current_token;
|
valid := 5;
|
valid := 5;
|
when 5 =>
|
when 5 =>
|
token6 := current_token;
|
token6 := current_token;
|
valid := 6;
|
valid := 6;
|
when 6 =>
|
when 6 =>
|
token7 := current_token;
|
token7 := current_token;
|
valid := 7;
|
valid := 7;
|
when others =>
|
when others =>
|
null;
|
null;
|
end case;
|
end case;
|
end if;
|
end if;
|
end if;
|
end if;
|
end tokenize_line;
|
end tokenize_line;
|
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
-- Add a new instruction to the instruction list
|
-- Add a new instruction to the instruction list
|
-- inputs :
|
-- inputs :
|
-- outputs :
|
-- outputs :
|
procedure define_instruction(variable inst_set: inout inst_def_ptr;
|
procedure define_instruction(variable inst_set: inout inst_def_ptr;
|
constant inst: in string;
|
constant inst: in string;
|
constant args: in integer) is
|
constant args: in integer) is
|
variable v_inst_ptr: inst_def_ptr;
|
variable v_inst_ptr: inst_def_ptr;
|
variable v_prev_ptr: inst_def_ptr;
|
variable v_prev_ptr: inst_def_ptr;
|
variable v_new_ptr: inst_def_ptr;
|
variable v_new_ptr: inst_def_ptr;
|
variable v_temp_inst: inst_def_ptr;
|
variable v_temp_inst: inst_def_ptr;
|
variable v_length: integer;
|
variable v_length: integer;
|
variable v_list_size: integer;
|
variable v_list_size: integer;
|
variable v_dup_error: boolean;
|
variable v_dup_error: boolean;
|
|
|
begin
|
begin
|
assert(inst'high <= max_field_len)
|
assert(inst'high <= max_field_len)
|
report LF & "Error: Creation of Instruction of length greater than Max_field_len attemped!!" &
|
report LF & "Error: Creation of Instruction of length greater than Max_field_len attemped!!" &
|
LF & "This Max is currently set to " & (integer'image(max_field_len))
|
LF & "This Max is currently set to " & (integer'image(max_field_len))
|
severity failure;
|
severity failure;
|
-- get to the last element and test is not exsiting
|
-- get to the last element and test is not exsiting
|
v_temp_inst := inst_set;
|
v_temp_inst := inst_set;
|
v_inst_ptr := inst_set;
|
v_inst_ptr := inst_set;
|
-- zero the size
|
-- zero the size
|
v_list_size := 0;
|
v_list_size := 0;
|
while(v_inst_ptr /= null) loop
|
while(v_inst_ptr /= null) loop
|
-- if there is a chance of a duplicate command
|
-- if there is a chance of a duplicate command
|
if(v_inst_ptr.instruction_l = inst'high) then
|
if(v_inst_ptr.instruction_l = inst'high) then
|
v_dup_error := true;
|
v_dup_error := true;
|
for i in 1 to inst'high loop
|
for i in 1 to inst'high loop
|
if(v_inst_ptr.instruction(i) /= inst(i)) then
|
if(v_inst_ptr.instruction(i) /= inst(i)) then
|
v_dup_error := false;
|
v_dup_error := false;
|
end if;
|
end if;
|
end loop;
|
end loop;
|
-- if we find a duplicate, die
|
-- if we find a duplicate, die
|
assert(v_dup_error = false)
|
assert(v_dup_error = false)
|
report LF & "Error: Duplicate instruction definition attempted!"
|
report LF & "Error: Duplicate instruction definition attempted!"
|
severity failure;
|
severity failure;
|
end if;
|
end if;
|
v_prev_ptr := v_inst_ptr; -- store for pointer updates
|
v_prev_ptr := v_inst_ptr; -- store for pointer updates
|
v_inst_ptr := v_inst_ptr.next_rec;
|
v_inst_ptr := v_inst_ptr.next_rec;
|
v_list_size := v_list_size + 1;
|
v_list_size := v_list_size + 1;
|
end loop;
|
end loop;
|
|
|
-- add the new instruction
|
-- add the new instruction
|
v_new_ptr := new inst_def;
|
v_new_ptr := new inst_def;
|
-- if this is the first command return new pointer
|
-- if this is the first command return new pointer
|
if(v_list_size = 0) then
|
if(v_list_size = 0) then
|
v_temp_inst := v_new_ptr;
|
v_temp_inst := v_new_ptr;
|
-- else write new pointer to next_rec
|
-- else write new pointer to next_rec
|
else
|
else
|
v_prev_ptr.next_rec := v_new_ptr;
|
v_prev_ptr.next_rec := v_new_ptr;
|
end if;
|
end if;
|
v_new_ptr.instruction_l := inst'high;
|
v_new_ptr.instruction_l := inst'high;
|
v_new_ptr.params := args;
|
v_new_ptr.params := args;
|
-- copy the instruction text into field
|
-- copy the instruction text into field
|
for i in 1 to v_new_ptr.instruction_l loop
|
for i in 1 to v_new_ptr.instruction_l loop
|
v_new_ptr.instruction(i) := inst(i);
|
v_new_ptr.instruction(i) := inst(i);
|
end loop;
|
end loop;
|
-- return the pointer
|
-- return the pointer
|
inst_set := v_temp_inst;
|
inst_set := v_temp_inst;
|
|
|
end define_instruction;
|
end define_instruction;
|
|
|
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
-- Check for valid instruction in the list of instructions
|
-- Check for valid instruction in the list of instructions
|
procedure check_valid_inst(variable inst : in text_field;
|
procedure check_valid_inst(variable inst : in text_field;
|
variable inst_set : in inst_def_ptr;
|
variable inst_set : in inst_def_ptr;
|
variable token_num: in integer;
|
variable token_num: in integer;
|
variable line_num : in integer;
|
variable line_num : in integer;
|
variable name : in text_line) is
|
variable name : in text_line) is
|
variable l : integer := 0;
|
variable l : integer := 0;
|
variable seti: inst_def_ptr;
|
variable seti: inst_def_ptr;
|
variable match: integer := 0;
|
variable match: integer := 0;
|
variable ilv: integer := 0; -- inline variable
|
variable ilv: integer := 0; -- inline variable
|
begin
|
begin
|
-- create useable pointer
|
-- create useable pointer
|
seti := inst_set;
|
seti := inst_set;
|
-- count up the characters in inst
|
-- count up the characters in inst
|
l := fld_len(inst);
|
l := fld_len(inst);
|
-- if this is a referance variable -- handle in add variable Proc
|
-- if this is a referance variable -- handle in add variable Proc
|
if(inst(l) = ':') then
|
if(inst(l) = ':') then
|
match := 1;
|
match := 1;
|
ilv := 1;
|
ilv := 1;
|
else
|
else
|
-- process list till null next
|
-- process list till null next
|
while (seti.next_rec /= null) loop
|
while (seti.next_rec /= null) loop
|
if(seti.instruction_l = l) then
|
if(seti.instruction_l = l) then
|
match := 1;
|
match := 1;
|
for j in 1 to l loop
|
for j in 1 to l loop
|
if(seti.instruction(j) /= inst(j)) then
|
if(seti.instruction(j) /= inst(j)) then
|
match := 0;
|
match := 0;
|
end if;
|
end if;
|
end loop;
|
end loop;
|
end if;
|
end if;
|
if(match = 0) then
|
if(match = 0) then
|
seti := seti.next_rec;
|
seti := seti.next_rec;
|
else
|
else
|
exit;
|
exit;
|
end if;
|
end if;
|
end loop;
|
end loop;
|
-- check current one
|
-- check current one
|
if(seti.instruction_l = l and match = 0) then
|
if(seti.instruction_l = l and match = 0) then
|
match := 1;
|
match := 1;
|
for j in 1 to l loop
|
for j in 1 to l loop
|
if(seti.instruction(j) /= inst(j)) then
|
if(seti.instruction(j) /= inst(j)) then
|
match := 0;
|
match := 0;
|
end if;
|
end if;
|
end loop;
|
end loop;
|
end if;
|
end if;
|
end if;
|
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
|
-- if we find a duplicate, die
|
assert(match = 1)
|
assert(match = 1)
|
report LF & "Error: Undefined Instruction on line " & (integer'image(line_num)) &
|
report LF & "Error: Undefined Instruction on line " & (integer'image(line_num)) &
|
" found in input file " & name & LF
|
" found in input file " & name & LF
|
severity failure;
|
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
|
-- available at this time.
|
-- available at this time.
|
procedure add_variable(variable var_list : inout var_field_ptr;
|
procedure add_variable(variable var_list : inout var_field_ptr;
|
variable p1 : in text_field; -- should be var name
|
variable p1 : in text_field; -- should be var name
|
variable p2 : in text_field; -- should be value
|
variable p2 : in text_field; -- should be value
|
variable token_num : in integer;
|
variable token_num : in integer;
|
variable sequ_num : in integer;
|
variable sequ_num : in integer;
|
variable line_num : in integer;
|
variable line_num : in integer;
|
variable name : in text_line;
|
variable name : in text_line;
|
variable length : in integer) is
|
variable length : in integer) is
|
|
|
variable temp_var: var_field_ptr;
|
variable temp_var: var_field_ptr;
|
variable current_ptr: var_field_ptr;
|
variable current_ptr: var_field_ptr;
|
variable index: integer := 1;
|
variable index: integer := 1;
|
|
|
begin
|
begin
|
-- if this is NOT the first one
|
-- if this is NOT the first one
|
if(var_list /= null) then
|
if(var_list /= null) then
|
current_ptr := var_list;
|
current_ptr := var_list;
|
index := index + 1;
|
index := index + 1;
|
if(p1(length) /= ':') then -- is not an inline variable
|
if(p1(length) /= ':') then -- is not an inline variable
|
while(current_ptr.next_rec /= null) loop
|
while(current_ptr.next_rec /= null) loop
|
-- if we have defined the current before then die
|
-- if we have defined the current before then die
|
assert(current_ptr.var_name /= p1)
|
assert(current_ptr.var_name /= p1)
|
report LF & "Error: Attemping to add a duplicate Variable definition "
|
report LF & "Error: Attemping to add a duplicate Variable definition "
|
& " on line " & (integer'image(line_num)) & " of file " & name
|
& " on line " & (integer'image(line_num)) & " of file " & name
|
severity failure;
|
severity failure;
|
|
|
current_ptr := current_ptr.next_rec;
|
current_ptr := current_ptr.next_rec;
|
index := index + 1;
|
index := index + 1;
|
end loop;
|
end loop;
|
-- if we have defined the current before then die. This checks the last one
|
-- if we have defined the current before then die. This checks the last one
|
assert(current_ptr.var_name /= p1)
|
assert(current_ptr.var_name /= p1)
|
report LF & "Error: Attemping to add a duplicate Variable definition "
|
report LF & "Error: Attemping to add a duplicate Variable definition "
|
& " on line " & (integer'image(line_num)) & " of file " & name
|
& " on line " & (integer'image(line_num)) & " of file " & name
|
severity failure;
|
severity failure;
|
|
|
temp_var := new var_field;
|
temp_var := new var_field;
|
temp_var.var_name := p1; -- direct write of text_field
|
temp_var.var_name := p1; -- direct write of text_field
|
temp_var.var_value := stim_to_integer(p2,name,line_num); -- convert text_field to integer
|
temp_var.var_value := stim_to_integer(p2,name,line_num); -- convert text_field to integer
|
temp_var.var_index := index;
|
temp_var.var_index := index;
|
current_ptr.next_rec := temp_var;
|
current_ptr.next_rec := temp_var;
|
else
|
else
|
while(current_ptr.next_rec /= null) loop
|
while(current_ptr.next_rec /= null) loop
|
-- if we have defined the current before then die
|
-- if we have defined the current before then die
|
assert(current_ptr.var_name(1 to (length - 1)) /= p1(1 to (length - 1)))
|
assert(current_ptr.var_name(1 to (length - 1)) /= p1(1 to (length - 1)))
|
report LF & "Error: Attemping to add a duplicate Inline Variable definition "
|
report LF & "Error: Attemping to add a duplicate Inline Variable definition "
|
& " on line " & (integer'image(line_num)) & " of file " & name
|
& " on line " & (integer'image(line_num)) & " of file " & name
|
severity failure;
|
severity failure;
|
|
|
current_ptr := current_ptr.next_rec;
|
current_ptr := current_ptr.next_rec;
|
index := index + 1;
|
index := index + 1;
|
end loop;
|
end loop;
|
-- if we have defined the current before then die. This checks the last one
|
-- if we have defined the current before then die. This checks the last one
|
assert(current_ptr.var_name(1 to (length - 1)) /= p1(1 to (length - 1)))
|
assert(current_ptr.var_name(1 to (length - 1)) /= p1(1 to (length - 1)))
|
report LF & "Error: Attemping to add a duplicate Inline Variable definition "
|
report LF & "Error: Attemping to add a duplicate Inline Variable definition "
|
& " on line " & (integer'image(line_num)) & " of file " & name
|
& " on line " & (integer'image(line_num)) & " of file " & name
|
severity failure;
|
severity failure;
|
|
|
temp_var := new var_field;
|
temp_var := new var_field;
|
temp_var.var_name(1 to (length - 1)) := p1(1 to (length - 1));
|
temp_var.var_name(1 to (length - 1)) := p1(1 to (length - 1));
|
temp_var.var_value := sequ_num;
|
temp_var.var_value := sequ_num;
|
temp_var.var_index := index;
|
temp_var.var_index := index;
|
current_ptr.next_rec := temp_var;
|
current_ptr.next_rec := temp_var;
|
end if;
|
end if;
|
-- this is the first one
|
-- this is the first one
|
else
|
else
|
if(p1(length) /= ':') then -- is not an inline variable
|
if(p1(length) /= ':') then -- is not an inline variable
|
temp_var := new var_field;
|
temp_var := new var_field;
|
temp_var.var_name := p1; -- direct write of text_field
|
temp_var.var_name := p1; -- direct write of text_field
|
temp_var.var_index := index;
|
temp_var.var_index := index;
|
temp_var.var_value := stim_to_integer(p2,name,line_num); -- convert text_field to integer
|
temp_var.var_value := stim_to_integer(p2,name,line_num); -- convert text_field to integer
|
var_list := temp_var;
|
var_list := temp_var;
|
else
|
else
|
temp_var := new var_field;
|
temp_var := new var_field;
|
temp_var.var_name(1 to (length - 1)) := p1(1 to (length - 1));
|
temp_var.var_name(1 to (length - 1)) := p1(1 to (length - 1));
|
temp_var.var_value := sequ_num;
|
temp_var.var_value := sequ_num;
|
temp_var.var_index := index;
|
temp_var.var_index := index;
|
var_list := temp_var;
|
var_list := temp_var;
|
end if;
|
end if;
|
end if;
|
end if;
|
end add_variable;
|
end add_variable;
|
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
-- add_instruction
|
-- add_instruction
|
-- This is the procedure that adds the instruction to the linked list of
|
-- This is the procedure that adds the instruction to the linked list of
|
-- instructions. Also Variable addition are called and or handled.
|
-- instructions. Also Variable addition are called and or handled.
|
-- the instruction sequence Link list.
|
-- the instruction sequence Link list.
|
-- inputs:
|
-- inputs:
|
-- stim_line_ptr is the pointer to the instruction List
|
-- stim_line_ptr is the pointer to the instruction List
|
-- inst is the instruction token
|
-- inst is the instruction token
|
-- p1 paramitor one, corrisponds to field one of stimulus
|
-- p1 paramitor one, corrisponds to field one of stimulus
|
-- p2 paramitor one, corrisponds to field two of stimulus
|
-- p2 paramitor one, corrisponds to field two of stimulus
|
-- p3 paramitor one, corrisponds to field three of stimulus
|
-- p3 paramitor one, corrisponds to field three of stimulus
|
-- p4 paramitor one, corrisponds to field four of stimulus
|
-- p4 paramitor one, corrisponds to field four of stimulus
|
-- p5 paramitor one, corrisponds to field three of stimulus
|
-- p5 paramitor one, corrisponds to field three of stimulus
|
-- p6 paramitor one, corrisponds to field four of stimulus
|
-- p6 paramitor one, corrisponds to field four of stimulus
|
-- str_ptr pointer to string for print instruction
|
-- str_ptr pointer to string for print instruction
|
-- token_num the number of tokens, including instruction
|
-- token_num the number of tokens, including instruction
|
-- sequ_num is the stimulus file line referance ie program line number
|
-- sequ_num is the stimulus file line referance ie program line number
|
-- line_num Line number in the text file
|
-- line_num Line number in the text file
|
-- outputs:
|
-- outputs:
|
-- none. Error will terminate sim
|
-- none. Error will terminate sim
|
procedure add_instruction(variable inst_list : inout stim_line_ptr;
|
procedure add_instruction(variable inst_list : inout stim_line_ptr;
|
variable var_list : inout var_field_ptr;
|
variable var_list : inout var_field_ptr;
|
variable inst : in text_field;
|
variable inst : in text_field;
|
variable p1 : in text_field;
|
variable p1 : in text_field;
|
variable p2 : in text_field;
|
variable p2 : in text_field;
|
variable p3 : in text_field;
|
variable p3 : in text_field;
|
variable p4 : in text_field;
|
variable p4 : in text_field;
|
variable p5 : in text_field;
|
variable p5 : in text_field;
|
variable p6 : in text_field;
|
variable p6 : in text_field;
|
variable str_ptr : in stm_text_ptr;
|
variable str_ptr : in stm_text_ptr;
|
variable token_num : in integer;
|
variable token_num : in integer;
|
variable sequ_num : inout integer;
|
variable sequ_num : inout integer;
|
variable line_num : in integer;
|
variable line_num : in integer;
|
variable file_name : in text_line) is
|
variable file_name : in text_line) is
|
-- variable temp_string: string;
|
-- variable temp_string: string;
|
variable temp_stim_line: stim_line_ptr;
|
variable temp_stim_line: stim_line_ptr;
|
variable temp_current: stim_line_ptr;
|
variable temp_current: stim_line_ptr;
|
variable valid: integer;
|
variable valid: integer;
|
variable l: integer;
|
variable l: integer;
|
begin
|
begin
|
valid := 1;
|
valid := 1;
|
l := fld_len(inst);
|
l := fld_len(inst);
|
temp_current := inst_list;
|
temp_current := inst_list;
|
-- take care of special cases
|
-- take care of special cases
|
if(inst(1 to l) = "DEFINE_VAR") then
|
if(inst(1 to l) = "DEFINE_VAR") then
|
l := fld_len(p1);
|
l := fld_len(p1);
|
-- Add the variable to the Variable pool, not considered an instruction
|
-- Add the variable to the Variable pool, not considered an instruction
|
add_variable(var_list,p1,p2,token_num,sequ_num,line_num,file_name,l);
|
add_variable(var_list,p1,p2,token_num,sequ_num,line_num,file_name,l);
|
elsif(inst(l) = ':') then
|
elsif(inst(l) = ':') then
|
add_variable(var_list,inst,p1,token_num,sequ_num,line_num,file_name,l);
|
add_variable(var_list,inst,p1,token_num,sequ_num,line_num,file_name,l);
|
valid := 0;
|
valid := 0;
|
end if;
|
end if;
|
|
|
if(valid = 1) then
|
if(valid = 1) then
|
-- prepare the new record
|
-- prepare the new record
|
temp_stim_line := new stim_line;
|
temp_stim_line := new stim_line;
|
temp_stim_line.instruction := inst;
|
temp_stim_line.instruction := inst;
|
temp_stim_line.inst_field_1 := p1;
|
temp_stim_line.inst_field_1 := p1;
|
temp_stim_line.inst_field_2 := p2;
|
temp_stim_line.inst_field_2 := p2;
|
temp_stim_line.inst_field_3 := p3;
|
temp_stim_line.inst_field_3 := p3;
|
temp_stim_line.inst_field_4 := p4;
|
temp_stim_line.inst_field_4 := p4;
|
temp_stim_line.inst_field_5 := p5;
|
temp_stim_line.inst_field_5 := p5;
|
temp_stim_line.inst_field_6 := p6;
|
temp_stim_line.inst_field_6 := p6;
|
temp_stim_line.txt := str_ptr;
|
temp_stim_line.txt := str_ptr;
|
temp_stim_line.line_number := sequ_num;
|
temp_stim_line.line_number := sequ_num;
|
temp_stim_line.file_name := file_name;
|
temp_stim_line.file_name := file_name;
|
temp_stim_line.file_line := line_num;
|
temp_stim_line.file_line := line_num;
|
|
|
-- if is not the first instruction
|
-- if is not the first instruction
|
if(inst_list /= null) then
|
if(inst_list /= null) then
|
while(temp_current.next_rec /= null) loop
|
while(temp_current.next_rec /= null) loop
|
temp_current := temp_current.next_rec;
|
temp_current := temp_current.next_rec;
|
end loop;
|
end loop;
|
temp_current.next_rec := temp_stim_line;
|
temp_current.next_rec := temp_stim_line;
|
inst_list.num_of_lines := inst_list.num_of_lines + 1;
|
inst_list.num_of_lines := inst_list.num_of_lines + 1;
|
-- other wise is first instruction to be added
|
-- other wise is first instruction to be added
|
else
|
else
|
inst_list := temp_stim_line;
|
inst_list := temp_stim_line;
|
inst_list.num_of_lines := 1;
|
inst_list.num_of_lines := 1;
|
end if;
|
end if;
|
sequ_num := sequ_num + 1;
|
sequ_num := sequ_num + 1;
|
-- print_inst(temp_stim_line); -- for debug
|
-- print_inst(temp_stim_line); -- for debug
|
end if;
|
end if;
|
|
|
end add_instruction;
|
end add_instruction;
|
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
-- The read include file procedure
|
-- The read include file procedure
|
-- This is the main procedure for reading, parcing, checking and returning
|
-- This is the main procedure for reading, parcing, checking and returning
|
-- the instruction sequence Link list.
|
-- the instruction sequence Link list.
|
procedure read_include_file(variable name: text_line;
|
procedure read_include_file(variable name: text_line;
|
variable sequ_numb: inout integer;
|
variable sequ_numb: inout integer;
|
variable inst_set: inout inst_def_ptr;
|
variable inst_set: inout inst_def_ptr;
|
variable var_list: inout var_field_ptr;
|
variable var_list: inout var_field_ptr;
|
variable inst_sequ: inout stim_line_ptr;
|
variable inst_sequ: inout stim_line_ptr;
|
variable status: inout integer) is
|
variable status: inout integer) is
|
variable l: text_line; -- the line
|
variable l: text_line; -- the line
|
variable l_num: integer; -- line number file
|
variable l_num: integer; -- line number file
|
variable sequ_line: integer; -- line number program
|
variable sequ_line: integer; -- line number program
|
variable t1: text_field;
|
variable t1: text_field;
|
variable t2: text_field;
|
variable t2: text_field;
|
variable t3: text_field;
|
variable t3: text_field;
|
variable t4: text_field;
|
variable t4: text_field;
|
variable t5: text_field;
|
variable t5: text_field;
|
variable t6: text_field;
|
variable t6: text_field;
|
variable t7: text_field;
|
variable t7: text_field;
|
variable t_txt: stm_text_ptr;
|
variable t_txt: stm_text_ptr;
|
variable valid: integer;
|
variable valid: integer;
|
variable v_inst_ptr: inst_def_ptr;
|
variable v_inst_ptr: inst_def_ptr;
|
variable v_var_prt: var_field_ptr;
|
variable v_var_prt: var_field_ptr;
|
variable v_sequ_ptr: stim_line_ptr;
|
variable v_sequ_ptr: stim_line_ptr;
|
variable v_len: integer;
|
variable v_len: integer;
|
variable v_stat: file_open_status;
|
variable v_stat: file_open_status;
|
|
|
begin
|
begin
|
sequ_line := sequ_numb;
|
sequ_line := sequ_numb;
|
|
|
file_open(v_stat, include_file, name, read_mode);
|
file_open(v_stat, include_file, name, read_mode);
|
if(v_stat /= open_ok) then
|
if(v_stat /= open_ok) then
|
print("Error: Unable to open include file " & name);
|
print("Error: Unable to open include file " & name);
|
status := 1;
|
status := 1;
|
return;
|
return;
|
end if;
|
end if;
|
l_num := 1; -- initialize line number
|
l_num := 1; -- initialize line number
|
|
|
v_inst_ptr := inst_set;
|
v_inst_ptr := inst_set;
|
v_var_prt := var_list;
|
v_var_prt := var_list;
|
v_sequ_ptr := inst_sequ;
|
v_sequ_ptr := inst_sequ;
|
|
|
-- while not the end of file read it
|
-- while not the end of file read it
|
while(not endfile(include_file)) loop
|
while(not endfile(include_file)) loop
|
file_read_line(include_file,l);
|
file_read_line(include_file,l);
|
-- tokenize the line
|
-- tokenize the line
|
tokenize_line(l,t1,t2,t3,t4,t5,t6,t7,t_txt,valid);
|
tokenize_line(l,t1,t2,t3,t4,t5,t6,t7,t_txt,valid);
|
v_len := fld_len(t1);
|
v_len := fld_len(t1);
|
if(t1(1 to v_len) = "INCLUDE") then
|
if(t1(1 to v_len) = "INCLUDE") then
|
print("Nested INCLUDE statement found: " & t2);
|
print("Nested INCLUDE statement found: " & t2);
|
assert(false)
|
assert(false)
|
report LF & "Error: Nested INCLUDE statements are not supported at this time."
|
report LF & "Error: Nested INCLUDE statements are not supported at this time."
|
severity failure;
|
severity failure;
|
|
|
-- if there was valid tokens
|
-- if there was valid tokens
|
elsif(valid /= 0) then
|
elsif(valid /= 0) then
|
check_valid_inst(t1, v_inst_ptr, valid, l_num, name);
|
check_valid_inst(t1, v_inst_ptr, valid, l_num, name);
|
add_instruction(v_sequ_ptr,v_var_prt,t1,t2,t3,t4,t5,t6,t7,t_txt,valid,sequ_line,l_num,name);
|
add_instruction(v_sequ_ptr,v_var_prt,t1,t2,t3,t4,t5,t6,t7,t_txt,valid,sequ_line,l_num,name);
|
end if;
|
end if;
|
l_num := l_num + 1;
|
l_num := l_num + 1;
|
end loop; -- end loop read file
|
end loop; -- end loop read file
|
file_close(include_file);
|
file_close(include_file);
|
sequ_numb := sequ_line;
|
sequ_numb := sequ_line;
|
inst_set := v_inst_ptr;
|
inst_set := v_inst_ptr;
|
var_list := v_var_prt;
|
var_list := v_var_prt;
|
inst_sequ := v_sequ_ptr;
|
inst_sequ := v_sequ_ptr;
|
end read_include_file;
|
end read_include_file;
|
|
|
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
-- The read instruction file procedure
|
-- The read instruction file procedure
|
-- This is the main procedure for reading, parcing, checking and returning
|
-- This is the main procedure for reading, parcing, checking and returning
|
-- the instruction sequence Link list.
|
-- the instruction sequence Link list.
|
procedure read_instruction_file(constant file_name: string;
|
procedure read_instruction_file(constant file_name: string;
|
variable inst_set: inout inst_def_ptr;
|
variable inst_set: inout inst_def_ptr;
|
variable var_list: inout var_field_ptr;
|
variable var_list: inout var_field_ptr;
|
variable inst_sequ: inout stim_line_ptr) is
|
variable inst_sequ: inout stim_line_ptr) is
|
variable l: text_line; -- the line
|
variable l: text_line; -- the line
|
variable l_num: integer; -- line number file
|
variable l_num: integer; -- line number file
|
variable sequ_line: integer; -- line number program
|
variable sequ_line: integer; -- line number program
|
variable t1: text_field;
|
variable t1: text_field;
|
variable t2: text_field;
|
variable t2: text_field;
|
variable t3: text_field;
|
variable t3: text_field;
|
variable t4: text_field;
|
variable t4: text_field;
|
variable t5: text_field;
|
variable t5: text_field;
|
variable t6: text_field;
|
variable t6: text_field;
|
variable t7: text_field;
|
variable t7: text_field;
|
variable t_txt: stm_text_ptr;
|
variable t_txt: stm_text_ptr;
|
variable valid: integer;
|
variable valid: integer;
|
variable v_ostat: integer;
|
variable v_ostat: integer;
|
variable v_inst_ptr: inst_def_ptr;
|
variable v_inst_ptr: inst_def_ptr;
|
variable v_var_prt: var_field_ptr;
|
variable v_var_prt: var_field_ptr;
|
variable v_sequ_ptr: stim_line_ptr;
|
variable v_sequ_ptr: stim_line_ptr;
|
variable v_len: integer;
|
variable v_len: integer;
|
variable v_stat: file_open_status;
|
variable v_stat: file_open_status;
|
variable v_name: text_line;
|
variable v_name: text_line;
|
variable v_iname: text_line;
|
variable v_iname: text_line;
|
|
|
begin
|
begin
|
-- open the stimulus_file and check
|
-- open the stimulus_file and check
|
file_open(v_stat, stimulus, file_name, read_mode);
|
file_open(v_stat, stimulus, file_name, read_mode);
|
assert(v_stat = open_ok)
|
assert(v_stat = open_ok)
|
report LF & "Error: Unable to open stimulus_file " & file_name
|
report LF & "Error: Unable to open stimulus_file " & file_name
|
severity failure;
|
severity failure;
|
-- copy file name to type text_line
|
-- copy file name to type text_line
|
for i in 1 to file_name'high loop
|
for i in 1 to file_name'high loop
|
v_name(i) := file_name(i);
|
v_name(i) := file_name(i);
|
end loop;
|
end loop;
|
|
|
l_num := 1;
|
l_num := 1;
|
sequ_line := 1;
|
sequ_line := 1;
|
v_ostat := 0;
|
v_ostat := 0;
|
|
|
v_inst_ptr := inst_set;
|
v_inst_ptr := inst_set;
|
v_var_prt := var_list;
|
v_var_prt := var_list;
|
v_sequ_ptr := inst_sequ;
|
v_sequ_ptr := inst_sequ;
|
|
|
-- while not the end of file read it
|
-- while not the end of file read it
|
while(not endfile(stimulus)) loop
|
while(not endfile(stimulus)) loop
|
file_read_line(stimulus,l);
|
file_read_line(stimulus,l);
|
-- tokenize the line
|
-- tokenize the line
|
tokenize_line(l,t1,t2,t3,t4,t5,t6,t7,t_txt,valid);
|
tokenize_line(l,t1,t2,t3,t4,t5,t6,t7,t_txt,valid);
|
v_len := fld_len(t1);
|
v_len := fld_len(t1);
|
-- if there is an INCLUDE instruction
|
-- if there is an INCLUDE instruction
|
if(t1(1 to v_len) = "INCLUDE") then
|
if(t1(1 to v_len) = "INCLUDE") then
|
if(valid = 2) then
|
if(valid = 2) then
|
v_iname := (others => nul);
|
v_iname := (others => nul);
|
for i in 1 to max_field_len loop
|
for i in 1 to max_field_len loop
|
v_iname(i) := t2(i);
|
v_iname(i) := t2(i);
|
end loop;
|
end loop;
|
else
|
else
|
v_iname := (others => nul);
|
v_iname := (others => nul);
|
for i in 1 to c_stm_text_len loop
|
for i in 1 to c_stm_text_len loop
|
v_iname(i) := t_txt(i);
|
v_iname(i) := t_txt(i);
|
end loop;
|
end loop;
|
end if;
|
end if;
|
print("INCLUDE found: Loading file " & v_iname);
|
print("INCLUDE found: Loading file " & v_iname);
|
read_include_file(v_iname,sequ_line,v_inst_ptr,v_var_prt,v_sequ_ptr,v_ostat);
|
read_include_file(v_iname,sequ_line,v_inst_ptr,v_var_prt,v_sequ_ptr,v_ostat);
|
-- if include file not found
|
-- if include file not found
|
if(v_ostat = 1) then
|
if(v_ostat = 1) then
|
exit;
|
exit;
|
end if;
|
end if;
|
-- if there was valid tokens
|
-- if there was valid tokens
|
elsif(valid /= 0) then
|
elsif(valid /= 0) then
|
check_valid_inst(t1, v_inst_ptr, valid, l_num, v_name);
|
check_valid_inst(t1, v_inst_ptr, valid, l_num, v_name);
|
add_instruction(v_sequ_ptr,v_var_prt,t1,t2,t3,t4,t5,t6,t7,t_txt,valid,sequ_line,l_num,v_name);
|
add_instruction(v_sequ_ptr,v_var_prt,t1,t2,t3,t4,t5,t6,t7,t_txt,valid,sequ_line,l_num,v_name);
|
end if;
|
end if;
|
l_num := l_num + 1;
|
l_num := l_num + 1;
|
end loop; -- end loop read file
|
end loop; -- end loop read file
|
|
|
file_close(stimulus); -- close the file when done
|
file_close(stimulus); -- close the file when done
|
|
|
assert(v_ostat = 0)
|
assert(v_ostat = 0)
|
report LF & "Include file not found! Test Terminated" & LF
|
report LF & "Include file not found! Test Terminated" & LF
|
severity failure;
|
severity failure;
|
|
|
inst_set := v_inst_ptr;
|
inst_set := v_inst_ptr;
|
var_list := v_var_prt;
|
var_list := v_var_prt;
|
inst_sequ := v_sequ_ptr;
|
inst_sequ := v_sequ_ptr;
|
end read_instruction_file;
|
end read_instruction_file;
|
|
|
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
-- access_inst_sequ
|
-- access_inst_sequ
|
-- This procedure accesses the instruction sequence and returns the parameters
|
-- This procedure accesses the instruction sequence and returns the parameters
|
-- as the exsist related to the variables state.
|
-- as the exsist related to the variables state.
|
procedure access_inst_sequ(variable inst_sequ : in stim_line_ptr;
|
procedure access_inst_sequ(variable inst_sequ : in stim_line_ptr;
|
variable var_list : in var_field_ptr;
|
variable var_list : in var_field_ptr;
|
variable sequ_num : in integer;
|
variable sequ_num : in integer;
|
variable inst : out text_field;
|
variable inst : out text_field;
|
variable p1 : out integer;
|
variable p1 : out integer;
|
variable p2 : out integer;
|
variable p2 : out integer;
|
variable p3 : out integer;
|
variable p3 : out integer;
|
variable p4 : out integer;
|
variable p4 : out integer;
|
variable p5 : out integer;
|
variable p5 : out integer;
|
variable p6 : out integer;
|
variable p6 : out integer;
|
variable txt : out stm_text_ptr;
|
variable txt : out stm_text_ptr;
|
variable inst_len : out integer;
|
variable inst_len : out integer;
|
variable fname : out text_line;
|
variable fname : out text_line;
|
variable file_line : out integer
|
variable file_line : out integer
|
) is
|
) is
|
variable temp_text_field: text_field;
|
variable temp_text_field: text_field;
|
variable temp_var: text_field;
|
variable temp_var: text_field;
|
variable inst_ptr: stim_line_ptr;
|
variable inst_ptr: stim_line_ptr;
|
variable valid: integer;
|
variable valid: integer;
|
variable line: integer; -- value of the file_line
|
variable line: integer; -- value of the file_line
|
variable file_name: text_line;
|
variable file_name: text_line;
|
begin
|
begin
|
-- inst_ptr := inst_sequ;
|
-- inst_ptr := inst_sequ;
|
-- while(inst_ptr.next_rec /= null) loop
|
-- while(inst_ptr.next_rec /= null) loop
|
-- print_inst(inst_ptr);
|
-- print_inst(inst_ptr);
|
-- inst_ptr := inst_ptr.next_rec;
|
-- inst_ptr := inst_ptr.next_rec;
|
-- end loop;
|
-- end loop;
|
-- get to the instruction indicated by sequ_num
|
-- get to the instruction indicated by sequ_num
|
inst_ptr := inst_sequ;
|
inst_ptr := inst_sequ;
|
while(inst_ptr.next_rec /= null) loop
|
while(inst_ptr.next_rec /= null) loop
|
if(inst_ptr.line_number = sequ_num) then
|
if(inst_ptr.line_number = sequ_num) then
|
exit;
|
exit;
|
else
|
else
|
inst_ptr := inst_ptr.next_rec;
|
inst_ptr := inst_ptr.next_rec;
|
end if;
|
end if;
|
end loop;
|
end loop;
|
-- output the instruction and its length
|
-- output the instruction and its length
|
inst := inst_ptr.instruction;
|
inst := inst_ptr.instruction;
|
inst_len := fld_len(inst_ptr.instruction);
|
inst_len := fld_len(inst_ptr.instruction);
|
file_line := inst_ptr.file_line;
|
file_line := inst_ptr.file_line;
|
line := inst_ptr.file_line;
|
line := inst_ptr.file_line;
|
file_name := inst_ptr.file_name;
|
file_name := inst_ptr.file_name;
|
fname := inst_ptr.file_name;
|
fname := inst_ptr.file_name;
|
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;
|
if(temp_text_field(1) /= nul) then
|
if(temp_text_field(1) /= nul) then
|
-- if this is a numaric field convert to integer
|
-- if this is a numaric field convert to integer
|
if(temp_text_field(1) = 'x' or temp_text_field(1) = 'h' or
|
if(temp_text_field(1) = 'x' or temp_text_field(1) = 'h' or
|
temp_text_field(1) = 'b') then
|
temp_text_field(1) = 'b') then
|
p1 := stim_to_integer(temp_text_field,file_name,line);
|
p1 := stim_to_integer(temp_text_field,file_name,line);
|
elsif(is_digit(temp_text_field(1)) = true) then
|
elsif(is_digit(temp_text_field(1)) = true) then
|
p1 := stim_to_integer(temp_text_field,file_name,line);
|
p1 := stim_to_integer(temp_text_field,file_name,line);
|
else -- else is a variable, get the value or halt incase of error
|
else -- else is a variable, get the value or halt incase of error
|
access_variable(var_list,temp_text_field,p1,valid);
|
access_variable(var_list,temp_text_field,p1,valid);
|
assert(valid = 1)
|
assert(valid = 1)
|
report LF & "Error: First variable on stimulus line " & (integer'image(line))
|
report LF & "Error: First variable on stimulus line " & (integer'image(line))
|
& " is not valid!!" & LF & "In file " & file_name
|
& " is not valid!!" & LF & "In file " & file_name
|
severity failure;
|
severity failure;
|
end if;
|
end if;
|
end if;
|
end if;
|
-- load parameter two
|
-- load parameter two
|
temp_text_field := inst_ptr.inst_field_2;
|
temp_text_field := inst_ptr.inst_field_2;
|
if(temp_text_field(1) /= nul) then
|
if(temp_text_field(1) /= nul) then
|
-- if this is a numaric field convert to integer
|
-- if this is a numaric field convert to integer
|
if(temp_text_field(1) = 'x' or temp_text_field(1) = 'h' or
|
if(temp_text_field(1) = 'x' or temp_text_field(1) = 'h' or
|
temp_text_field(1) = 'b') then
|
temp_text_field(1) = 'b') then
|
p2 := stim_to_integer(temp_text_field,file_name,line);
|
p2 := stim_to_integer(temp_text_field,file_name,line);
|
elsif(is_digit(temp_text_field(1)) = true) then
|
elsif(is_digit(temp_text_field(1)) = true) then
|
p2 := stim_to_integer(temp_text_field,file_name,line);
|
p2 := stim_to_integer(temp_text_field,file_name,line);
|
else -- else is a variable, get the value or halt incase of error
|
else -- else is a variable, get the value or halt incase of error
|
access_variable(var_list,temp_text_field,p2,valid);
|
access_variable(var_list,temp_text_field,p2,valid);
|
assert(valid = 1)
|
assert(valid = 1)
|
report LF & "Error: Second variable on stimulus line " & (integer'image(line))
|
report LF & "Error: Second variable on stimulus line " & (integer'image(line))
|
& " is not valid!!" & LF & "In file " & file_name
|
& " is not valid!!" & LF & "In file " & file_name
|
severity failure;
|
severity failure;
|
end if;
|
end if;
|
end if;
|
end if;
|
-- load parameter three
|
-- load parameter three
|
temp_text_field := inst_ptr.inst_field_3;
|
temp_text_field := inst_ptr.inst_field_3;
|
if(temp_text_field(1) /= nul) then
|
if(temp_text_field(1) /= nul) then
|
-- if this is a numaric field convert to integer
|
-- if this is a numaric field convert to integer
|
if(temp_text_field(1) = 'x' or temp_text_field(1) = 'h' or
|
if(temp_text_field(1) = 'x' or temp_text_field(1) = 'h' or
|
temp_text_field(1) = 'b') then
|
temp_text_field(1) = 'b') then
|
p3 := stim_to_integer(temp_text_field,file_name,line);
|
p3 := stim_to_integer(temp_text_field,file_name,line);
|
elsif(is_digit(temp_text_field(1)) = true) then
|
elsif(is_digit(temp_text_field(1)) = true) then
|
p3 := stim_to_integer(temp_text_field,file_name,line);
|
p3 := stim_to_integer(temp_text_field,file_name,line);
|
else -- else is a variable, get the value or halt incase of error
|
else -- else is a variable, get the value or halt incase of error
|
access_variable(var_list,temp_text_field,p3,valid);
|
access_variable(var_list,temp_text_field,p3,valid);
|
assert(valid = 1)
|
assert(valid = 1)
|
report LF & "Error: Third variable on stimulus line " & (integer'image(line))
|
report LF & "Error: Third variable on stimulus line " & (integer'image(line))
|
& " is not valid!!" & LF & "In file " & file_name
|
& " is not valid!!" & LF & "In file " & file_name
|
severity failure;
|
severity failure;
|
end if;
|
end if;
|
end if;
|
end if;
|
-- load parameter four
|
-- load parameter four
|
temp_text_field := inst_ptr.inst_field_4;
|
temp_text_field := inst_ptr.inst_field_4;
|
if(temp_text_field(1) /= nul) then
|
if(temp_text_field(1) /= nul) then
|
-- if this is a numaric field convert to integer
|
-- if this is a numaric field convert to integer
|
if(temp_text_field(1) = 'x' or temp_text_field(1) = 'h' or
|
if(temp_text_field(1) = 'x' or temp_text_field(1) = 'h' or
|
temp_text_field(1) = 'b') then
|
temp_text_field(1) = 'b') then
|
p4 := stim_to_integer(temp_text_field,file_name,line);
|
p4 := stim_to_integer(temp_text_field,file_name,line);
|
elsif(is_digit(temp_text_field(1)) = true) then
|
elsif(is_digit(temp_text_field(1)) = true) then
|
p4 := stim_to_integer(temp_text_field,file_name,line);
|
p4 := stim_to_integer(temp_text_field,file_name,line);
|
else -- else is a variable, get the value or halt incase of error
|
else -- else is a variable, get the value or halt incase of error
|
access_variable(var_list,temp_text_field,p4,valid);
|
access_variable(var_list,temp_text_field,p4,valid);
|
assert(valid = 1)
|
assert(valid = 1)
|
report LF & "Error: Forth variable on stimulus line " & (integer'image(line))
|
report LF & "Error: Forth variable on stimulus line " & (integer'image(line))
|
& " is not valid!!" & LF & "In file " & file_name
|
& " is not valid!!" & LF & "In file " & file_name
|
severity failure;
|
severity failure;
|
end if;
|
end if;
|
end if;
|
end if;
|
-- load parameter five
|
-- load parameter five
|
temp_text_field := inst_ptr.inst_field_5;
|
temp_text_field := inst_ptr.inst_field_5;
|
if(temp_text_field(1) /= nul) then
|
if(temp_text_field(1) /= nul) then
|
-- if this is a numaric field convert to integer
|
-- if this is a numaric field convert to integer
|
if(temp_text_field(1) = 'x' or temp_text_field(1) = 'h' or
|
if(temp_text_field(1) = 'x' or temp_text_field(1) = 'h' or
|
temp_text_field(1) = 'b') then
|
temp_text_field(1) = 'b') then
|
p5 := stim_to_integer(temp_text_field,file_name,line);
|
p5 := stim_to_integer(temp_text_field,file_name,line);
|
elsif(is_digit(temp_text_field(1)) = true) then
|
elsif(is_digit(temp_text_field(1)) = true) then
|
p5 := stim_to_integer(temp_text_field,file_name,line);
|
p5 := stim_to_integer(temp_text_field,file_name,line);
|
else -- else is a variable, get the value or halt incase of error
|
else -- else is a variable, get the value or halt incase of error
|
access_variable(var_list,temp_text_field,p5,valid);
|
access_variable(var_list,temp_text_field,p5,valid);
|
assert(valid = 1)
|
assert(valid = 1)
|
report LF & "Error: Fifth variable on stimulus line " & (integer'image(line))
|
report LF & "Error: Fifth variable on stimulus line " & (integer'image(line))
|
& " is not valid!!" & LF & "In file " & file_name
|
& " is not valid!!" & LF & "In file " & file_name
|
severity failure;
|
severity failure;
|
end if;
|
end if;
|
end if;
|
end if;
|
-- load parameter six
|
-- load parameter six
|
temp_text_field := inst_ptr.inst_field_6;
|
temp_text_field := inst_ptr.inst_field_6;
|
if(temp_text_field(1) /= nul) then
|
if(temp_text_field(1) /= nul) then
|
-- if this is a numaric field convert to integer
|
-- if this is a numaric field convert to integer
|
if(temp_text_field(1) = 'x' or temp_text_field(1) = 'h' or
|
if(temp_text_field(1) = 'x' or temp_text_field(1) = 'h' or
|
temp_text_field(1) = 'b') then
|
temp_text_field(1) = 'b') then
|
p6 := stim_to_integer(temp_text_field,file_name,line);
|
p6 := stim_to_integer(temp_text_field,file_name,line);
|
elsif(is_digit(temp_text_field(1)) = true) then
|
elsif(is_digit(temp_text_field(1)) = true) then
|
p6 := stim_to_integer(temp_text_field,file_name,line);
|
p6 := stim_to_integer(temp_text_field,file_name,line);
|
else -- else is a variable, get the value or halt incase of error
|
else -- else is a variable, get the value or halt incase of error
|
access_variable(var_list,temp_text_field,p6,valid);
|
access_variable(var_list,temp_text_field,p6,valid);
|
assert(valid = 1)
|
assert(valid = 1)
|
report LF & "Error: Sixth variable on stimulus line " & (integer'image(line))
|
report LF & "Error: Sixth variable on stimulus line " & (integer'image(line))
|
& " is not valid!!" & LF & "In file " & file_name
|
& " is not valid!!" & LF & "In file " & file_name
|
severity failure;
|
severity failure;
|
end if;
|
end if;
|
end if;
|
end if;
|
end access_inst_sequ;
|
end access_inst_sequ;
|
|
|
-------------------------------------------------------------------------
|
-------------------------------------------------------------------------
|
-- dump inst_sequ
|
-- dump inst_sequ
|
-- This procedure dumps to the simulation window the current instruction
|
-- This procedure dumps to the simulation window the current instruction
|
-- sequence. The whole thing will be dumped, which could be big.
|
-- sequence. The whole thing will be dumped, which could be big.
|
-- ** intended for testbench development debug **
|
-- ** intended for testbench development debug **
|
procedure dump_inst_sequ(variable inst_sequ : in stim_line_ptr) is
|
procedure dump_inst_sequ(variable inst_sequ : in stim_line_ptr) is
|
variable v_sequ : stim_line_ptr;
|
variable v_sequ : stim_line_ptr;
|
begin
|
begin
|
v_sequ := inst_sequ;
|
v_sequ := inst_sequ;
|
while(v_sequ.next_rec /= null) loop
|
while(v_sequ.next_rec /= null) loop
|
print("-----------------------------------------------------------------");
|
print("-----------------------------------------------------------------");
|
print("Instruction is " & v_sequ.instruction & " Par1: " & v_sequ.inst_field_1 &
|
print("Instruction is " & v_sequ.instruction & " Par1: " & v_sequ.inst_field_1 &
|
" Par2: " & v_sequ.inst_field_2 & " Par3: " & v_sequ.inst_field_3 &
|
" Par2: " & v_sequ.inst_field_2 & " Par3: " & v_sequ.inst_field_3 &
|
" Par4: " & v_sequ.inst_field_4);
|
" Par4: " & v_sequ.inst_field_4);
|
print("Line Number: " & to_str(v_sequ.line_number) & " File Line Number: " & to_str(v_sequ.file_line) &
|
print("Line Number: " & to_str(v_sequ.line_number) & " File Line Number: " & to_str(v_sequ.file_line) &
|
" File Name: " & v_sequ.file_name);
|
" File Name: " & v_sequ.file_name);
|
|
|
v_sequ := v_sequ.next_rec;
|
v_sequ := v_sequ.next_rec;
|
end loop;
|
end loop;
|
-- get the last one
|
-- get the last one
|
print("-----------------------------------------------------------------");
|
print("-----------------------------------------------------------------");
|
print("Instruction is " & v_sequ.instruction & " Par1: " & v_sequ.inst_field_1 &
|
print("Instruction is " & v_sequ.instruction & " Par1: " & v_sequ.inst_field_1 &
|
" Par2: " & v_sequ.inst_field_2 & " Par3: " & v_sequ.inst_field_3 &
|
" Par2: " & v_sequ.inst_field_2 & " Par3: " & v_sequ.inst_field_3 &
|
" Par4: " & v_sequ.inst_field_4);
|
" Par4: " & v_sequ.inst_field_4);
|
print("Line Number: " & to_str(v_sequ.line_number) & " File Line Number: " & to_str(v_sequ.file_line) &
|
print("Line Number: " & to_str(v_sequ.line_number) & " File Line Number: " & to_str(v_sequ.file_line) &
|
" File Name: " & v_sequ.file_name);
|
" File Name: " & v_sequ.file_name);
|
end dump_inst_sequ;
|
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
|
write(l, s);
|
write(l, s);
|
writeline(output,l);
|
writeline(output,l);
|
end print;
|
end print;
|
|
|
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
-- procedure to print to the stdout the txt pointer
|
-- procedure to print to the stdout the txt pointer
|
procedure txt_print(variable ptr: in stm_text_ptr) is
|
procedure txt_print(variable ptr: in stm_text_ptr) is
|
variable txt_str : stm_text;
|
variable txt_str : stm_text;
|
begin
|
begin
|
|
|
if (ptr /= null) then
|
if (ptr /= null) then
|
txt_str := (others => nul);
|
txt_str := (others => nul);
|
for i in 1 to 128 loop
|
for i in 1 to 128 loop
|
if (ptr(i) = nul) then
|
if (ptr(i) = nul) then
|
exit;
|
exit;
|
end if;
|
end if;
|
txt_str(i) := ptr(i);
|
txt_str(i) := ptr(i);
|
end loop;
|
end loop;
|
print(txt_str);
|
print(txt_str);
|
end if;
|
end if;
|
end txt_print;
|
end txt_print;
|
|
|
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
-- procedure to print to the stdout the txt pointer, and
|
-- procedure to print to the stdout the txt pointer, and
|
-- sub any variables found
|
-- sub any variables found
|
procedure txt_print_wvar(variable var_list : in var_field_ptr;
|
procedure txt_print_wvar(variable var_list : in var_field_ptr;
|
variable ptr : in stm_text_ptr;
|
variable ptr : in stm_text_ptr;
|
constant b : in base) is
|
constant b : in base) is
|
|
|
variable i: integer;
|
variable i: integer;
|
variable j: integer;
|
variable j: integer;
|
variable k: integer;
|
variable k: integer;
|
variable txt_str: stm_text;
|
variable txt_str: stm_text;
|
variable tmp_str: stm_text;
|
variable tmp_str: stm_text;
|
variable v1: integer;
|
variable v1: integer;
|
variable valid: integer;
|
variable valid: integer;
|
variable tmp_field: text_field;
|
variable tmp_field: text_field;
|
variable tmp_i: integer;
|
variable tmp_i: integer;
|
|
|
begin
|
begin
|
if(ptr /= null) then
|
if(ptr /= null) then
|
i := 1;
|
i := 1;
|
j := 1;
|
j := 1;
|
txt_str := (others => nul);
|
txt_str := (others => nul);
|
while(i <= 128 and j <= 128) loop
|
while(i <= 128 and j <= 128) loop
|
if(ptr(i) /= '$') then
|
if(ptr(i) /= '$') then
|
txt_str(j) := ptr(i);
|
txt_str(j) := ptr(i);
|
i := i + 1;
|
i := i + 1;
|
j := j + 1;
|
j := j + 1;
|
else
|
else
|
tmp_field := (others => nul);
|
tmp_field := (others => nul);
|
tmp_i := 1;
|
tmp_i := 1;
|
tmp_field(tmp_i) := ptr(i);
|
tmp_field(tmp_i) := ptr(i);
|
i := i + 1;
|
i := i + 1;
|
tmp_i := tmp_i + 1;
|
tmp_i := tmp_i + 1;
|
-- parse to the next space
|
-- parse to the next space
|
while(ptr(i) /= ' ' and ptr(i) /= nul) loop
|
while(ptr(i) /= ' ' and ptr(i) /= nul) loop
|
tmp_field(tmp_i) := ptr(i);
|
tmp_field(tmp_i) := ptr(i);
|
i := i + 1;
|
i := i + 1;
|
tmp_i := tmp_i + 1;
|
tmp_i := tmp_i + 1;
|
end loop;
|
end loop;
|
access_variable(var_list,tmp_field,v1,valid);
|
access_variable(var_list,tmp_field,v1,valid);
|
assert(valid = 1)
|
assert(valid = 1)
|
report LF & "Invalid Variable found in stm_text_ptr: ignoring."
|
report LF & "Invalid Variable found in stm_text_ptr: ignoring."
|
severity warning;
|
severity warning;
|
|
|
if(valid = 1) then
|
if(valid = 1) then
|
|
|
txt_str := ew_str_cat(txt_str, ew_to_str(v1, b));
|
txt_str := ew_str_cat(txt_str, ew_to_str(v1, b));
|
k := 1;
|
k := 1;
|
while(txt_str(k) /= nul) loop
|
while(txt_str(k) /= nul) loop
|
k := k + 1;
|
k := k + 1;
|
end loop;
|
end loop;
|
j := k;
|
j := k;
|
end if;
|
end if;
|
end if;
|
end if;
|
end loop;
|
end loop;
|
-- print the created string
|
-- print the created string
|
print(txt_str);
|
print(txt_str);
|
end if;
|
end if;
|
end txt_print_wvar;
|
end txt_print_wvar;
|
|
|
end tb_pkg;
|
end tb_pkg;
|
|
|
|
|