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 23

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 19 sckoarn
-------------------------------------------------------------------------------
2 23 sckoarn
--             Copyright 2014  Ken Campbell
3
--               All rights reserved.
4 19 sckoarn
-------------------------------------------------------------------------------
5
-- $Author: sckoarn $
6
--
7
-- $Date:  $
8
--
9
-- $Id:  $
10
--
11 23 sckoarn
-- $Source:  $
12 19 sckoarn
--
13
-- Description :  The the testbench package header file.
14
--
15
------------------------------------------------------------------------------
16 23 sckoarn
--  This file is part of The VHDL Test Bench Package.
17 19 sckoarn
--
18 23 sckoarn
--  Redistribution and use in source and binary forms, with or without
19
--  modification, are permitted provided that the following conditions are met:
20 19 sckoarn
--
21 23 sckoarn
--  1. Redistributions of source code must retain the above copyright notice,
22
--     this list of conditions and the following disclaimer.
23 19 sckoarn
--
24 23 sckoarn
--  2. Redistributions in binary form must reproduce the above copyright notice,
25
--     this list of conditions and the following disclaimer in the documentation
26
--     and/or other materials provided with the distribution.
27
--
28
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
29
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
31
-- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
32
-- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
33
-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
34
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
35
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
36
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
37
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38
-- POSSIBILITY OF SUCH DAMAGE.
39 19 sckoarn
-------------------------------------------------------------------------------
40
library IEEE;
41
 
42
use IEEE.STD_LOGIC_1164.all;
43
use IEEE.STD_LOGIC_ARITH.all;
44
use std.textio.all;
45
--library ieee_proposed;
46
--use ieee_proposed.STD_LOGIC_1164_additions.all;
47
 
48
package tb_pkg is
49
 
50
  -- Constants
51
  constant max_str_len   : integer := 256;
52
  constant max_field_len : integer := 48;
53
  constant c_stm_text_len  : integer := 200;
54
  -- file handles
55
  file stimulus     : text;             -- file main file
56
  file include_file : text;             -- file declaration for includes
57
 
58
  -- Type Def's
59
  type base is (bin, oct, hex, dec);
60
--  subtype stack_element is integer range 0 to 8192;
61
  type stack_register is array(7 downto 0) of integer;
62
  type state_register is array(7 downto 0) of boolean;
63
  type int_array      is array(1 to 16) of integer;
64
 
65
  subtype text_line  is string(1 to max_str_len);
66
  subtype text_field is string(1 to max_field_len);
67
  subtype stm_text is string(1 to c_stm_text_len);
68
  type stm_text_ptr is access stm_text;
69
  -- define the stimulus line record and access
70
  type stim_line;
71
  type stim_line_ptr is access stim_line;     -- Pointer to stim_line record
72
  type stim_line is record
73
    instruction:   text_field;
74
    inst_field_1:  text_field;
75
    inst_field_2:  text_field;
76
    inst_field_3:  text_field;
77
    inst_field_4:  text_field;
78
    inst_field_5:  text_field;
79
    inst_field_6:  text_field;
80
    txt:           stm_text_ptr;
81
    line_number:   integer;      -- sequence line
82
    num_of_lines:  integer;      -- total number of lines
83
    file_line:     integer;      -- file line number
84
    file_idx:      integer;
85
    next_rec:      stim_line_ptr;
86
  end record;
87
  -- define the variables field and pointer
88
  type var_field;
89
  type var_field_ptr is access var_field;  -- pointer to var_field
90
  type var_field is record
91
    var_name:     text_field;
92
    var_index:    integer;
93
    var_value:    integer;
94
    next_rec:     var_field_ptr;
95
  end record;
96
  -- define the instruction structure
97
  type inst_def;
98
  type inst_def_ptr is access inst_def;
99
  type inst_def is record
100
    instruction:     text_field;
101
    instruction_l:   integer;
102
    params:          integer;
103
    next_rec:        inst_def_ptr;
104
  end record;
105
  -- define the file handle record
106
  type file_def;
107
  type file_def_ptr is access file_def;
108
  type file_def is record
109
    rec_idx:         integer;
110
    file_name:       text_line;
111
    next_rec:        file_def_ptr;
112
  end record;
113
 
114
  -- define the stimulus slave control record types
115
  type stm_sctl is record
116
    rst_n       : std_logic;
117
    addr        : std_logic_vector(31 downto 0);
118
    wdat        : std_logic_vector(31 downto 0);
119
    rwn         : std_logic;
120
    req_n       : std_logic;
121
  end record;
122
  type stm_sack is record
123
    rdat        : std_logic_vector(31 downto 0);
124
    ack_n       : std_logic;
125
    rdy_n       : std_logic;
126
    irq_n       : std_logic;
127
  end record;
128
  -- define the stimulus master control record types
129
  type stm_mctl is record
130
    addr        : std_logic_vector(31 downto 0);
131
    wdat        : std_logic_vector(31 downto 0);
132
    rwn         : std_logic;
133
    req_n       : std_logic;
134
    breq        : std_logic;
135
  end record;
136
  type stm_mack is record
137
    rdat        : std_logic_vector(31 downto 0);
138
    slv_rdy     : std_logic_vector(15 downto 0);
139
    slv_irq     : std_logic_vector(15 downto 0);
140
    ack_n       : std_logic;
141
    bgrant      : std_logic;
142
  end record;
143
 
144
-----
145
--  stm interface neutral functions
146
  function stm_neut return stm_sctl;
147
  function stm_neut return stm_sack;
148
  --function stm_neut() return stm_mctl;
149
  --function stm_neut() return stm_mack;
150
 
151
---*****************************************************************************
152
  -- Function Declaration
153
--  function str_len(variable line: text_line) return text_field;
154
--  function fld_len(s : in text_field) integer;
155
 
156
    function c2std_vec(c: in character) return std_logic_vector;
157
 
158
--------------------------------------------------------------------------------
159
  -- Procedure declarations
160
--------------------------------------------------------------------------
161
-- define_instruction
162
--    inputs     file_name  the file to be read from
163
--
164
--    output     file_line  a line of text from the file
165
  procedure define_instruction(variable inst_set: inout inst_def_ptr;
166
                               constant inst:     in    string;
167
                               constant args:     in    integer);
168
 
169
--------------------------------------------------------------------------------
170
--  index_variable
171
--     inputs:
172
--               index:  the index of the variable being accessed
173
--     outputs:
174
--               Variable Value
175
--               valid  is 1 if valid 0 if not
176
  procedure index_variable(variable var_list : in  var_field_ptr;
177
                           variable index    : in  integer;
178
                           variable value    : out integer;
179
                           variable valid    : out integer);
180
 
181
--------------------------------------------------------------------------------
182
--  update_variable
183
--     inputs:
184
--               index:  the index of the variable being accessed
185
--     outputs:
186
--               Variable Value
187
--               valid  is 1 if valid 0 if not
188
  procedure update_variable(variable var_list : in  var_field_ptr;
189
                            variable index    : in  integer;
190
                            variable value    : in  integer;
191
                            variable valid    : out integer);
192
 
193
-------------------------------------------------------------------------------
194
-- read_instruction_file
195
--  This procedure reads the instruction file, name passed throught file_name.
196
--  Pointers to records are passed in and out.  A table of variables is created
197
--  with variable name and value (converted to integer).  The instructions are
198
--  parsesed into the inst_sequ list.  Instructions are validated against the
199
--  inst_set which must have been set up prior to loading the instruction file.
200
  procedure read_instruction_file(constant file_name:  string;
201
                                  variable inst_set:   inout inst_def_ptr;
202
                                  variable var_list:   inout var_field_ptr;
203
                                  variable inst_sequ:  inout stim_line_ptr;
204
                                  variable file_list:  inout file_def_ptr);
205
 
206
------------------------------------------------------------------------------
207
-- access_inst_sequ
208
--   This procedure retreeves an instruction from the sequence of instructions.
209
--   Based on the line number you pass to it, it returns the instruction with
210
--   any variables substituted as integers.
211
  procedure access_inst_sequ(variable inst_sequ  :  in  stim_line_ptr;
212
                             variable var_list   :  in  var_field_ptr;
213
                             variable file_list  :  in  file_def_ptr;
214
                             variable sequ_num   :  in  integer;
215
                             variable inst       :  out text_field;
216
                             variable p1         :  out integer;
217
                             variable p2         :  out integer;
218
                             variable p3         :  out integer;
219
                             variable p4         :  out integer;
220
                             variable p5         :  out integer;
221
                             variable p6         :  out integer;
222
                             variable txt        :  out stm_text_ptr;
223
                             variable inst_len   :  out integer;
224
                             variable fname      :  out text_line;
225
                             variable file_line  :  out integer;
226
                             variable last_num   :  inout integer;
227
                             variable last_ptr   :  inout stim_line_ptr
228
                             );
229
------------------------------------------------------------------------
230
--  tokenize_line
231
--    This procedure takes a type text_line in and returns up to 6
232
--    tokens and the count in integer valid, as well if text string
233
--    is found the pointer to that is returned.
234
  procedure tokenize_line(variable text_line:   in  text_line;
235
                          variable token1:      out text_field;
236
                          variable token2:      out text_field;
237
                          variable token3:      out text_field;
238
                          variable token4:      out text_field;
239
                          variable token5:      out text_field;
240
                          variable token6:      out text_field;
241
                          variable token7:      out text_field;
242
                          variable txt_ptr:     out stm_text_ptr;
243
                          variable valid:       out integer);
244
-------------------------------------------------------------------------
245
-- string convertion
246
  function ew_to_str(int: integer; b: base) return text_field;
247
  function to_str(int: integer) return string;
248
 
249
-------------------------------------------------------------------------
250
--  Procedre print
251
--    print to stdout  string
252
  procedure print(s: in string);
253
-------------------------------------------------------------------------
254
--  Procedure print stim txt
255
  procedure txt_print(variable ptr: in stm_text_ptr);
256
-------------------------------------------------------------------------
257
--  Procedure print stim txt sub variables found
258
  procedure txt_print_wvar(variable var_list   :  in  var_field_ptr;
259
                           variable ptr        :  in  stm_text_ptr;
260
                           constant b          :  in  base);
261
 
262
-------------------------------------------------------------------------
263
--  convert a std_logic_vector to an unsigned integer
264
    function to_uninteger  ( constant vect     : in std_logic_vector
265
                         ) return integer;
266
 
267
end tb_pkg;
268
-------------------------------------------------------------------------------
269
--  new version 1.4
270
-- Revision History:
271
-- $Log: not supported by cvs2svn $
272
-- Revision 1.3  2007/09/02 04:04:04  sckoarn
273
-- Update of version 1.2 tb_pkg
274
-- See documentation for details
275
--
276
-- Revision 1.2  2007/08/21 02:43:14  sckoarn
277
-- Fix package definition to match with body
278
--
279
-- Revision 1.1.1.1  2007/04/06 04:06:48  sckoarn
280
-- Import of the vhld_tb
281
-------------------------------------------------------------------------------

powered by: WebSVN 2.1.0

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