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

Subversion Repositories vhld_tb

[/] [vhld_tb/] [trunk/] [source/] [tb_pkg_header.vhd] - Blame information for rev 10

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 sckoarn
-------------------------------------------------------------------------------
2
--             Copyright 2007  Ken Campbell
3
-------------------------------------------------------------------------------
4
-- $Author: sckoarn $
5
--
6 10 sckoarn
-- $Date: 2007-09-02 04:04:04 $
7 2 sckoarn
--
8
-- $Name: not supported by cvs2svn $
9
--
10 10 sckoarn
-- $Id: tb_pkg_header.vhd,v 1.3 2007-09-02 04:04:04 sckoarn Exp $
11 2 sckoarn
--
12
-- $Source: /home/marcus/revision_ctrl_test/oc_cvs/cvs/vhld_tb/source/tb_pkg_header.vhd,v $
13
--
14
-- Description :  The the testbench package header file.
15
--                Initial GNU release.
16
--
17
------------------------------------------------------------------------------
18
--This file is part of The VHDL Test Bench.
19
--
20
--    The VHDL Test Bench is free software; you can redistribute it and/or modify
21
--    it under the terms of the GNU General Public License as published by
22
--    the Free Software Foundation; either version 2 of the License, or
23
--    (at your option) any later version.
24
--
25 10 sckoarn
--    The VHDL Test Bench is distributed in the hope that it will be useful,
26 2 sckoarn
--    but WITHOUT ANY WARRANTY; without even the implied warranty of
27
--    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
28
--    GNU General Public License for more details.
29
--
30
--    You should have received a copy of the GNU General Public License
31
--    along with The VHDL Test Bench; if not, write to the Free Software
32
--    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
33
-------------------------------------------------------------------------------
34
-- Revision History:
35
-- $Log: not supported by cvs2svn $
36 10 sckoarn
-- Revision 1.2  2007/08/21 02:43:14  sckoarn
37
-- Fix package definition to match with body
38
--
39 4 sckoarn
-- Revision 1.1.1.1  2007/04/06 04:06:48  sckoarn
40
-- Import of the vhld_tb
41 2 sckoarn
--
42 4 sckoarn
--
43 2 sckoarn
-------------------------------------------------------------------------------
44
library IEEE;
45
 
46
use IEEE.STD_LOGIC_1164.all;
47
use IEEE.STD_LOGIC_ARITH.all;
48
use std.textio.all;
49
library ieee_proposed;
50
use ieee_proposed.STD_LOGIC_1164_additions.all;
51
 
52 4 sckoarn
package tb_pkg is
53 2 sckoarn
 
54
  -- Constants
55
  constant max_str_len   : integer := 256;
56
  constant max_field_len : integer := 48;
57 10 sckoarn
  constant c_stm_text_len  : integer := 200;
58 2 sckoarn
  -- file handles
59
  file stimulus     : text;             -- file main file
60
  file include_file : text;             -- file declaration for includes
61
 
62
  -- Type Def's
63
  type base is (bin, oct, hex, dec);
64
--  subtype stack_element is integer range 0 to 8192;
65
  type stack_register is array(7 downto 0) of integer;
66
  type state_register is array(7 downto 0) of boolean;
67
  type int_array      is array(1 to 16) of integer;
68
 
69
  subtype text_line  is string(1 to max_str_len);
70
  subtype text_field is string(1 to max_field_len);
71
  subtype stm_text is string(1 to c_stm_text_len);
72
  type stm_text_ptr is access stm_text;
73
  -- define the stimulus line record and access
74
  type stim_line;
75
  type stim_line_ptr is access stim_line;     -- Pointer to stim_line record
76
  type stim_line is record
77
    instruction:   text_field;
78
    inst_field_1:  text_field;
79
    inst_field_2:  text_field;
80
    inst_field_3:  text_field;
81
    inst_field_4:  text_field;
82
    inst_field_5:  text_field;
83
    inst_field_6:  text_field;
84
    txt:           stm_text_ptr;
85
    line_number:   integer;      -- sequence line
86
    num_of_lines:  integer;      -- total number of lines
87
    file_line:     integer;      -- file line number
88 10 sckoarn
    file_idx:      integer;
89 2 sckoarn
    next_rec:      stim_line_ptr;
90
  end record;
91
  -- define the variables field and pointer
92
  type var_field;
93
  type var_field_ptr is access var_field;  -- pointer to var_field
94
  type var_field is record
95
    var_name:     text_field;
96
    var_index:    integer;
97
    var_value:    integer;
98
    next_rec:     var_field_ptr;
99
  end record;
100
  -- define the instruction structure
101
  type inst_def;
102
  type inst_def_ptr is access inst_def;
103
  type inst_def is record
104
    instruction:     text_field;
105
    instruction_l:   integer;
106
    params:          integer;
107
    next_rec:        inst_def_ptr;
108
  end record;
109 10 sckoarn
  -- define the file handle record
110
  type file_def;
111
  type file_def_ptr is access file_def;
112
  type file_def is record
113
    rec_idx:         integer;
114
    file_name:       text_line;
115
    next_rec:        file_def_ptr;
116
  end record;
117 2 sckoarn
 
118
---*****************************************************************************
119
  -- Function Declaration
120
--  function str_len(variable line: text_line) return text_field;
121
--  function fld_len(s : in text_field) integer;
122
 
123
    function c2std_vec(c: in character) return std_logic_vector;
124
 
125
--------------------------------------------------------------------------------
126
  -- Procedure declarations
127
--------------------------------------------------------------------------
128
-- define_instruction
129
--    inputs     file_name  the file to be read from
130
--
131
--    output     file_line  a line of text from the file
132
  procedure define_instruction(variable inst_set: inout inst_def_ptr;
133
                               constant inst:     in    string;
134
                               constant args:     in    integer);
135
 
136
--------------------------------------------------------------------------------
137
--  index_variable
138
--     inputs:
139
--               index:  the index of the variable being accessed
140
--     outputs:
141
--               Variable Value
142
--               valid  is 1 if valid 0 if not
143
  procedure index_variable(variable var_list : in  var_field_ptr;
144
                           variable index    : in  integer;
145
                           variable value    : out integer;
146
                           variable valid    : out integer);
147
 
148
--------------------------------------------------------------------------------
149
--  update_variable
150
--     inputs:
151
--               index:  the index of the variable being accessed
152
--     outputs:
153
--               Variable Value
154
--               valid  is 1 if valid 0 if not
155
  procedure update_variable(variable var_list : in  var_field_ptr;
156
                            variable index    : in  integer;
157
                            variable value    : in  integer;
158
                            variable valid    : out integer);
159
 
160
-------------------------------------------------------------------------------
161
-- read_instruction_file
162
--  This procedure reads the instruction file, name passed throught file_name.
163
--  Pointers to records are passed in and out.  A table of variables is created
164
--  with variable name and value (converted to integer).  The instructions are
165
--  parsesed into the inst_sequ list.  Instructions are validated against the
166
--  inst_set which must have been set up prior to loading the instruction file.
167
  procedure read_instruction_file(constant file_name:  string;
168
                                  variable inst_set:   inout inst_def_ptr;
169
                                  variable var_list:   inout var_field_ptr;
170 10 sckoarn
                                  variable inst_sequ:  inout stim_line_ptr;
171
                                  variable file_list:  inout file_def_ptr);
172 2 sckoarn
 
173
------------------------------------------------------------------------------
174
-- access_inst_sequ
175
--   This procedure retreeves an instruction from the sequence of instructions.
176
--   Based on the line number you pass to it, it returns the instruction with
177
--   any variables substituted as integers.
178
  procedure access_inst_sequ(variable inst_sequ  :  in  stim_line_ptr;
179
                             variable var_list   :  in  var_field_ptr;
180 10 sckoarn
                             variable file_list  :  in  file_def_ptr;
181 2 sckoarn
                             variable sequ_num   :  in  integer;
182
                             variable inst       :  out text_field;
183
                             variable p1         :  out integer;
184
                             variable p2         :  out integer;
185
                             variable p3         :  out integer;
186
                             variable p4         :  out integer;
187
                             variable p5         :  out integer;
188
                             variable p6         :  out integer;
189
                             variable txt        :  out stm_text_ptr;
190
                             variable inst_len   :  out integer;
191
                             variable fname      :  out text_line;
192
                             variable file_line  :  out integer
193
                             );
194
------------------------------------------------------------------------
195
--  tokenize_line
196
--    This procedure takes a type text_line in and returns up to 6
197
--    tokens and the count in integer valid, as well if text string
198
--    is found the pointer to that is returned.
199
  procedure tokenize_line(variable text_line:   in  text_line;
200
                          variable token1:      out text_field;
201
                          variable token2:      out text_field;
202
                          variable token3:      out text_field;
203
                          variable token4:      out text_field;
204
                          variable token5:      out text_field;
205
                          variable token6:      out text_field;
206
                          variable token7:      out text_field;
207
                          variable txt_ptr:     out stm_text_ptr;
208
                          variable valid:       out integer);
209
-------------------------------------------------------------------------
210
-- string convertion
211
  function ew_to_str(int: integer; b: base) return text_field;
212
  function to_str(int: integer) return string;
213
 
214
-------------------------------------------------------------------------
215
--  Procedre print
216
--    print to stdout  string
217
  procedure print(s: in string);
218
-------------------------------------------------------------------------
219
--  Procedure print stim txt
220
  procedure txt_print(variable ptr: in stm_text_ptr);
221
-------------------------------------------------------------------------
222
--  Procedure print stim txt sub variables found
223
  procedure txt_print_wvar(variable var_list   :  in  var_field_ptr;
224
                           variable ptr        :  in  stm_text_ptr;
225
                           constant b          :  in  base);
226
-------------------------------------------------------------------------
227
-- dump inst_sequ
228
--  This procedure dumps to the simulation window the current instruction
229
--  sequence.  The whole thing will be dumped, which could be big.
230
--   ** intended for testbench development debug**
231 10 sckoarn
--  procedure dump_inst_sequ(variable inst_sequ  :  in  stim_line_ptr);
232 2 sckoarn
 
233 4 sckoarn
end tb_pkg;

powered by: WebSVN 2.1.0

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