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 14

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