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

Subversion Repositories vhld_tb

[/] [vhld_tb/] [trunk/] [source/] [tb_pkg_body.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_body.vhd,v 1.3 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_body.vhd,v $
13
--
14
-- Description :  The the testbench package body 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.2  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.1.1.1  2007/04/06 04:06:48  sckoarn
41
-- Import of the vhld_tb
42 2 sckoarn
--
43 10 sckoarn
--
44 2 sckoarn
-------------------------------------------------------------------------------
45
 
46
package body tb_pkg is
47
 
48
-------------------------------------------------------------------------------
49
-- FUNCTION Defs
50
-------------------------------------------------------------------------------
51
--  is_digit
52
 function is_digit(constant c: in character) return boolean is
53
   variable rtn : boolean;
54
 begin
55
   if (c >= '0' and c <= '9') then
56
        rtn := true;
57
   else
58
        rtn := false;
59
   end if;
60
   return rtn;
61
 end is_digit;
62
--------------------------------------
63
-- is_space 
64
 function is_space(constant c: in character) return boolean is
65
   variable rtn : boolean;
66
 begin
67
   if(c = ' ' or c = ht) then
68
        rtn := true;
69
   else
70
        rtn := false;
71
   end if;
72
   return rtn;
73
 end is_space;
74
------------------------------------------------------------------------------
75
--  to_char
76
  function ew_to_char(int: integer) return character is
77
    variable c: character;
78
  begin
79
    c := nul;
80
    case int is
81
      when 0 => c := '0';
82
      when 1 => c := '1';
83
      when 2 => c := '2';
84
      when 3 => c := '3';
85
      when 4 => c := '4';
86
      when 5 => c := '5';
87
      when 6 => c := '6';
88
      when 7 => c := '7';
89
      when 8 => c := '8';
90
      when 9 => c := '9';
91
      when 10 => c := 'A';
92
      when 11 => c := 'B';
93
      when 12 => c := 'C';
94
      when 13 => c := 'D';
95
      when 14 => c := 'E';
96
      when 15 => c := 'F';
97
      when others =>
98
         assert(false)
99
           report LF & "Error: ew_to_char was given a non Number didgit."
100
         severity failure;
101
    end case;
102
 
103
    return c;
104
  end ew_to_char;
105
 
106
-------------------------------------------------------------------------------
107
--  to_string function  integer
108
  function to_str(int: integer) return string is
109
  begin
110
    return ew_to_str(int,dec) ;
111
  end to_str ;
112
 
113
-------------------------------------------------------------------------------
114
--  ew_str_cat
115
  function ew_str_cat(s1: stm_text;
116
                      s2: text_field) return stm_text is
117
 
118
    variable i:  integer;
119
    variable j:  integer;
120
    variable sc: stm_text;
121
 
122
  begin
123
    sc := s1;
124
    i := 1;
125
    while(sc(i) /= nul) loop
126
      i := i + 1;
127
    end loop;
128
    j := 1;
129
    while(s2(j) /= nul) loop
130
      sc(i) := s2(j);
131
      i := i + 1;
132
      j := j + 1;
133
    end loop;
134
 
135
    return sc;
136
  end ew_str_cat;
137
 
138
-------------------------------------------------------------------------------
139
-- fld_len    field length
140
--          inputs :  string of type text_field
141
--          return :  integer number of non 'nul' chars
142
function fld_len(s : in text_field) return integer is
143
    variable i:  integer := 1;
144
  begin
145
    while(s(i) /= nul) loop
146
      i := i + 1;
147
    end loop;
148
    return (i - 1);
149
  end fld_len;
150
------------------------------------------------------------------------------
151
-- c2int   convert character to integer
152
function c2int(c: in character) return integer is
153
  variable i:  integer;
154
begin
155
  i := -1;
156
  case c is
157
    when '0' => i := 0;
158
    when '1' => i := 1;
159
    when '2' => i := 2;
160
    when '3' => i := 3;
161
    when '4' => i := 4;
162
    when '5' => i := 5;
163
    when '6' => i := 6;
164
    when '7' => i := 7;
165
    when '8' => i := 8;
166
    when '9' => i := 9;
167
    when others =>
168
      assert(false)
169
        report LF & "Error: c2int was given a non Number didgit."
170
      severity failure;
171
  end case;
172
  return i;
173
end c2int;
174
-------------------------------------------------------------------------------
175
-- str2integer   Convert a string to integer number.
176
--   inputs  :  string
177
--   output  :  int value
178
function str2integer(str: in string) return integer is
179
  variable l:   integer;
180
  variable j:   integer := 1;
181
  variable rtn: integer := 0;
182
begin
183
  l := fld_len(str);
184
 
185
  for i in l downto 1 loop
186
    rtn := rtn + (c2int(str(j)) *(10**(i - 1)));
187
    j := j + 1;
188
  end loop;
189
 
190
  return rtn;
191
end str2integer;
192
-------------------------------------------------------------------------------
193
-- hex2integer    convert hex Stimulus field to integer
194
--          inputs :  string of type text_field containing only Hex numbers
195
--          return :  integer value
196
function hex2integer(hex_number:  in text_field;
197
                     file_name:   in text_line;
198
                     line:        in integer) return integer is
199
    variable len:         integer;
200
    variable temp_field:  text_field;
201
    variable temp_int:    integer;
202
    variable power:       integer;
203
    variable int_number:  integer;
204
  begin
205
     len      := fld_len(hex_number);
206
     power    := 0;
207
     temp_int := 0;
208
     for i in len downto 1 loop
209
       case hex_number(i) is
210
         when '0' =>
211
           int_number  := 0;
212
         when '1' =>
213
           int_number  := 1;
214
         when '2' =>
215
           int_number  := 2;
216
         when '3' =>
217
           int_number  := 3;
218
         when '4' =>
219
           int_number  := 4;
220
         when '5' =>
221
           int_number  := 5;
222
         when '6' =>
223
           int_number  := 6;
224
         when '7' =>
225
           int_number  := 7;
226
         when '8' =>
227
           int_number  := 8;
228
         when '9' =>
229
           int_number  := 9;
230
         when 'a' | 'A'=>
231
           int_number  := 10;
232
         when 'b' | 'B'=>
233
           int_number  := 11;
234
         when 'c' | 'C'=>
235
           int_number  := 12;
236
         when 'd' | 'D'=>
237
           int_number  := 13;
238
         when 'e' | 'E'=>
239
           int_number  := 14;
240
         when 'f' | 'F'=>
241
           int_number  := 15;
242
         when others =>
243
         assert(false)
244
           report LF & "Error: hex2integer found non Hex didgit on line "
245
                     & (integer'image(line)) & " of file " & file_name
246
         severity failure;
247
       end case;
248
 
249
       temp_int  := temp_int + (int_number *(16 ** power));
250
       power     := power + 1;
251
     end loop;
252
 
253
     return temp_int;
254
  end hex2integer;
255
-------------------------------------------------------------------------------
256
-- convert character to 4 bit vector
257
--   input    character
258
--   output   std_logic_vector  4 bits
259
function c2std_vec(c: in character) return std_logic_vector is
260
begin
261
  case c is
262
    when '0' =>  return "0000";
263
    when '1' =>  return "0001";
264
    when '2' =>  return "0010";
265
    when '3' =>  return "0011";
266
    when '4' =>  return "0100";
267
    when '5' =>  return "0101";
268
    when '6' =>  return "0110";
269
    when '7' =>  return "0111";
270
    when '8' =>  return "1000";
271
    when '9' =>  return "1001";
272
    when 'a' | 'A' =>  return "1010";
273
    when 'b' | 'B' =>  return "1011";
274
    when 'c' | 'C' =>  return "1100";
275
    when 'd' | 'D' =>  return "1101";
276
    when 'e' | 'E' =>  return "1110";
277
    when 'f' | 'F' =>  return "1111";
278
    when others =>
279
     assert(false)
280
       report LF & "Error: c2std_vec found non Hex didgit on file line "
281
     severity failure;
282
     return "XXXX";
283
  end case;
284
end c2std_vec;
285
-------------------------------------------------------------------------------
286
--  std_vec2c  convert 4 bit std_vector to a character
287
--     input  std_logic_vector 4 bits
288
--     output  character
289
function std_vec2c(vec: in std_logic_vector(3 downto 0)) return character is
290
begin
291
  case vec is
292
    when "0000" => return '0';
293
    when "0001" => return '1';
294
    when "0010" => return '2';
295
    when "0011" => return '3';
296
    when "0100" => return '4';
297
    when "0101" => return '5';
298
    when "0110" => return '6';
299
    when "0111" => return '7';
300
    when "1000" => return '8';
301
    when "1001" => return '9';
302
    when "1010" => return 'A';
303
    when "1011" => return 'B';
304
    when "1100" => return 'C';
305
    when "1101" => return 'D';
306
    when "1110" => return 'E';
307
    when "1111" => return 'F';
308
    when others =>
309
     assert(false)
310
       report LF & "Error: std_vec2c found non-binary didgit in vec "
311
     severity failure;
312
     return 'X';
313
  end case;
314
end std_vec2c;
315
-------------------------------------------------------------------------------
316
-- bin2integer    convert bin Stimulus field to integer
317
--          inputs :  string of type text_field containing only binary numbers
318
--          return :  integer value
319
function bin2integer(bin_number:  in text_field;
320
                     file_name:   in text_line;
321
                     line:        in integer) return integer is
322
    variable len:         integer;
323
    variable temp_field:  text_field;
324
    variable temp_int:    integer;
325
    variable power:       integer;
326
    variable int_number:  integer;
327
  begin
328
     len      := fld_len(bin_number);
329
     power    := 0;
330
     temp_int := 0;
331
     for i in len downto 1 loop
332
       case bin_number(i) is
333
         when '0' =>
334
           int_number  := 0;
335
         when '1' =>
336
           int_number  := 1;
337
         when others =>
338
         assert(false)
339
           report LF & "Error: bin2integer found non Binary didgit on line "
340
                     & (integer'image(line)) & " of file " & file_name
341
         severity failure;
342
       end case;
343
 
344
       temp_int  := temp_int + (int_number *(2 ** power));
345
       power     := power + 1;
346
     end loop;
347
 
348
     return temp_int;
349
  end bin2integer;
350
-------------------------------------------------------------------------------
351
-- stim_to_integer    convert Stimulus field to integer
352
--          inputs :  string of type text_field "stimulus format of number"
353
--          return :  integer value
354
function stim_to_integer(field:      in text_field;
355
                         file_name:  in text_line;
356
                         line:       in integer) return integer is
357
    variable len:       integer;
358
    variable text:      text_field;
359
    variable value:     integer := 1;
360
    variable temp_str : string(1 to 48);
361
  begin
362
    len := fld_len(field);
363
 
364
    case field(1) is
365
      when 'x' | 'h' =>
366
        value := 2;
367
        while(field(value) /= nul) loop
368
          temp_str(value - 1) := field(value);
369
          value := value + 1;
370
        end loop;
371
        value  := hex2integer(temp_str,file_name,line);
372
      when 'b' =>
373
        value := 2;
374
        while(field(value) /= nul) loop
375
          temp_str(value - 1) := field(value);
376
          value := value + 1;
377
        end loop;
378
        value  := bin2integer(temp_str,file_name,line);
379
      when others =>
380
--        value  := from_string(field(1 to len));
381
        value  := str2integer(field);
382
    end case;
383
    return value;
384
  end stim_to_integer;
385
 
386
-------------------------------------------------------------------------------
387
--  to_str function  with base parameter
388
--     Convert integer to number base
389
  function ew_to_str(int: integer; b: base) return text_field is
390
 
391
    variable temp  : text_field ;
392
    variable temp1 : text_field ;
393
    variable radix : integer := 0;
394
    variable num   : integer := 0;
395
    variable power : integer := 1;
396
    variable len   : integer := 1;
397
    variable pre   : string(1 to 2);
398
    variable i     : integer;
399
    variable j     : integer;
400
    variable vec   : std_logic_vector(31 downto 0);
401
 
402
  begin
403
 
404
    num := int;
405
    temp := (others => nul);
406
    case b is
407
      when bin =>
408
        radix := 2;                -- depending on what
409
        pre := "0b";
410
      when oct =>
411
        radix := 8;                -- base the number is
412
        pre := "0o";
413
      when hex =>
414
        radix := 16;               -- to be displayed as
415
        pre := "0x";
416
      when dec =>
417
        radix := 10;               -- choose a radix range
418
        pre := (others => nul);
419
    end case ;
420
    -- Now jump through Hoops because of sign
421
    if(num < 0 and b = hex) then
422
      vec := std_logic_vector(conv_unsigned(int, 32));
423
      temp(1) := std_vec2c(vec(31 downto 28));
424
      temp(2) := std_vec2c(vec(27 downto 24));
425
      temp(3) := std_vec2c(vec(23 downto 20));
426
      temp(4) := std_vec2c(vec(19 downto 16));
427
      temp(5) := std_vec2c(vec(15 downto 12));
428
      temp(6) := std_vec2c(vec(11 downto 8));
429
      temp(7) := std_vec2c(vec(7 downto 4));
430
      temp(8) := std_vec2c(vec(3 downto 0));
431
    else
432
      while num >= radix loop                   -- determine how many
433
        len := len + 1;                        -- characters required
434
        num := num / radix;                    -- to represent the
435
      end loop ;                                -- number.
436
      for i in len downto 1 loop                -- convert the number to
437
        temp(i) := ew_to_char(int/power mod radix); -- a string starting
438
        power := power * radix;                 -- with the right hand
439
      end loop ;                                -- side.
440
    end if;
441
    -- add prefix if is one
442
    if(pre(1) /= nul) then
443
      temp1 := temp;
444
      i := 1;
445
      j := 3;
446
      temp(1 to 2) := pre;
447
      while(temp1(i) /= nul) loop
448
        temp(j) := temp1(i);
449
        i := i + 1;
450
        j := j + 1;
451
      end loop;
452
    end if;
453
 
454
    return temp;
455
 
456
  end ew_to_str ;
457
 
458
-------------------------------------------------------------------------------
459
-- Procedure to print instruction records to stdout  *for debug*
460
  procedure print_inst(variable inst  :  in stim_line_ptr) is
461
    variable l:    text_line;
462
    variable l_i:  integer := 1;
463
    variable j:    integer := 1;
464
  begin
465
    while (inst.instruction(j) /= nul) loop
466
      l(l_i) := inst.instruction(j);
467
      j   := j +1;
468
      l_i := l_i + 1;
469
    end loop;
470
 
471
    l(l_i) := ' ';
472
    l_i := l_i + 1;
473
    j   := 1;
474
    -- field one
475
    if(inst.inst_field_1(1) /= nul) then
476
      while (inst.inst_field_1(j) /= nul) loop
477
        l(l_i) := inst.inst_field_1(j);
478
        j   := j +1;
479
        l_i := l_i + 1;
480
      end loop;
481
      l(l_i) := ' ';
482
      l_i := l_i + 1;
483
      j   := 1;
484
      -- field two
485
      if(inst.inst_field_2(1) /= nul) then
486
        while (inst.inst_field_2(j) /= nul) loop
487
          l(l_i) := inst.inst_field_2(j);
488
          j   := j +1;
489
          l_i := l_i + 1;
490
        end loop;
491
        l(l_i) := ' ';
492
        l_i := l_i + 1;
493
        j   := 1;
494
        -- field three
495
        if(inst.inst_field_3(1) /= nul) then
496
          while (inst.inst_field_3(j) /= nul) loop
497
            l(l_i) := inst.inst_field_3(j);
498
            j   := j +1;
499
            l_i := l_i + 1;
500
          end loop;
501
          l(l_i) := ' ';
502
          l_i := l_i + 1;
503
          j   := 1;
504
          -- field four
505
          if(inst.inst_field_4(1) /= nul) then
506
            while (inst.inst_field_4(j) /= nul) loop
507
              l(l_i) := inst.inst_field_4(j);
508
              j   := j +1;
509
              l_i := l_i + 1;
510
            end loop;
511
          end if;
512
        end if;
513
      end if;
514
    end if;
515
    print(l);
516
 
517
    print("   Sequence Number: " & to_str(inst.line_number) &
518
          "  File Line Number: " & to_str(inst.file_line));
519
    if(inst.num_of_lines > 0) then
520
      print("   Number of Lines: " & to_str(inst.num_of_lines));
521
    end if;
522
  end print_inst;
523
 
524
--------------------------------------------------------------------------------
525
--  access_variable
526
--     inputs:
527
--               Text field containing variable
528
--     outputs:
529
--               value  $VAR  returns Value of VAR
530
--               value  VAR   returns index of VAR
531
--
532
--               valid  is 1 if valid 0 if not
533
  procedure access_variable(variable var_list : in  var_field_ptr;
534
                            variable var      : in text_field;
535
                            variable value    : out integer;
536
                            variable valid    : out integer) is
537
    variable l          : integer;
538
    variable l_2        : integer;
539
    variable var_ptr    : var_field_ptr;
540
    variable temp_field : text_field;
541
    variable ptr        : integer := 0;  -- 0 is index, 1 is pointer
542
  begin
543
    l      := fld_len(var);
544
    valid  := 0;
545
    -- if the variable is a special
546
    if(var(1) = '=') then
547
          value  := 0;
548
          valid  := 1;
549
    elsif(var(1 to 2) = ">=") then
550
          value  := 4;
551
          valid  := 1;
552
    elsif(var(1 to 2) = "<=") then
553
          value  := 5;
554
          valid  := 1;
555
    elsif(var(1) = '>') then
556
          value  := 1;
557
          valid  := 1;
558
    elsif(var(1) = '<') then
559
          value  := 2;
560
          valid  := 1;
561
    elsif(var(1 to 2) = "!=") then
562
          value  := 3;
563
          valid  := 1;
564
 
565
    else
566
      if(var(1) = '$') then
567
        ptr := 1; -- this is a pointer
568
        for i in 2 to l loop
569
          temp_field(i-1) := var(i);
570
        end loop;
571
      else
572
        temp_field  :=  var;
573
      end if;
574
 
575
      var_ptr := var_list;
576
      while(var_ptr.next_rec  /= null) loop
577
        -- if we have a match
578
        if(temp_field = var_ptr.var_name) then
579
          if(ptr = 1) then
580
            value  := var_ptr.var_value;
581
            valid  := 1;
582
          else
583
            value  := var_ptr.var_index;
584
            valid  := 1;
585
          end if;
586
          exit;
587
        end if;
588
        var_ptr := var_ptr.next_rec;
589
      end loop;
590
 
591
      -- if we have a match and was the last record
592
      if(var_ptr.next_rec  = null and temp_field = var_ptr.var_name) then
593
        if(ptr = 1) then
594
          value  := var_ptr.var_value;
595
          valid  := 1;
596
        else
597
          value  := var_ptr.var_index;
598
          valid  := 1;
599
        end if;
600
      end if;
601
    end if;
602
  end access_variable;
603
--------------------------------------------------------------------------------
604
--  index_variable
605
--     inputs:
606
--               index:  the index of the variable being accessed
607
--     outputs:
608
--               Variable Value
609
--               valid  is 1 if valid 0 if not
610
  procedure index_variable(variable var_list : in  var_field_ptr;
611
                           variable index    : in  integer;
612
                           variable value    : out integer;
613
                           variable valid    : out integer) is
614
    variable ptr:  var_field_ptr;
615
  begin
616
    ptr    :=  var_list;
617
    valid  :=  0;
618
    while(ptr.next_rec  /= null) loop
619
      if(ptr.var_index = index) then
620
        value :=  ptr.var_value;
621
        valid :=  1;
622
        exit;
623
      end if;
624
      ptr  :=  ptr.next_rec;
625
    end loop;
626
    if(ptr.var_index = index) then
627
      value :=  ptr.var_value;
628
      valid :=  1;
629
    end if;
630
  end index_variable;
631
 
632
--------------------------------------------------------------------------------
633
--  update_variable
634
--     inputs:
635
--               index:  the index of the variable being updated
636
--     outputs:
637
--               valid  is 1 if valid 0 if not
638
  procedure update_variable(variable var_list : in  var_field_ptr;
639 10 sckoarn
                            variable index    : in  integer;
640
                            variable value    : in  integer;
641
                            variable valid    : out integer) is
642 2 sckoarn
    variable ptr:  var_field_ptr;
643
  begin
644
    ptr    :=  var_list;
645
    valid  :=  0;
646
    while(ptr.next_rec  /= null) loop
647
      if(ptr.var_index = index) then
648
        ptr.var_value :=  value;
649
        valid :=  1;
650
        exit;
651
      end if;
652
      ptr  :=  ptr.next_rec;
653
    end loop;
654
    -- check the current one
655
    if(ptr.var_index = index) then
656
      ptr.var_value :=  value;
657
      valid :=  1;
658
    end if;
659
  end update_variable;
660
 
661
-------------------------------------------------------------------------------
662
-- Read a line from a file
663
--   inputs  :   file of type text
664
--   outputs :   The line of type text_line
665
  procedure file_read_line(file file_name: text;
666
                           variable file_line: out text_line
667
                          ) is
668
    variable index:  integer;             -- index into string
669
    variable rline:  line;
670
 
671
  begin
672
 
673
    index := 1;  -- set index to begin of string
674
    file_line := (others => nul);
675
    if(not endfile(file_name)) then
676
      readline(file_name,rline);
677
 
678
      while(rline'right /= (index - 1) and rline'length /= 0) loop
679
        file_line(index) := rline(index);
680
        index    := index + 1;
681
      end loop;
682
    end if;
683
  end file_read_line;
684
 
685
  ------------------------------------------------------------------------------
686
  -- procedure to break a line down in to text fields
687
  procedure tokenize_line(variable text_line:   in  text_line;
688
                          variable token1:      out text_field;
689
                          variable token2:      out text_field;
690
                          variable token3:      out text_field;
691
                          variable token4:      out text_field;
692
                          variable token5:      out text_field;
693
                          variable token6:      out text_field;
694
                          variable token7:      out text_field;
695
                          variable txt_ptr:     out stm_text_ptr;
696
                          variable valid:       out integer) is
697
    variable token_index:     integer  :=  0;
698
    variable current_token:   text_field;
699
    variable token_number:    integer  :=  0;
700
    variable c:               string(1 to 2);
701
    variable comment_found:   integer  :=  0;
702
    variable txt_found:       integer  :=  0;
703
    variable j:               integer;
704
 
705
  begin
706
    -- null outputs
707
    token1  :=  (others => nul);
708
    token2  :=  (others => nul);
709
    token3  :=  (others => nul);
710
    token4  :=  (others => nul);
711
    token5  :=  (others => nul);
712
    token6  :=  (others => nul);
713
    token7  :=  (others => nul);
714
    txt_ptr :=  null;
715
    valid   :=  0;
716
    txt_found  :=  0;
717
    j := 1;
718
 
719
    -- loop for max number of char
720
    for i in 1 to text_line'high loop
721
      -- collect for comment test ** assumed no line will be max 256
722
      c(1)  := text_line(i);
723
      c(2)  := text_line(i + 1);  -- or this line will blow up
724
      if(c = "--") then
725
        comment_found  :=  1;
726
        exit;
727
      end if;
728
      -- if is begin text char '"'
729
      if(c(1) = '"') then  --"  <-- this double quote is just to fix highlighting.
730
        txt_found := 1;
731
        txt_ptr := new stm_text;
732
        next;
733
      end if;
734
 
735
      -- if we have found a txt string
736
      if (txt_found = 1 and text_line(i) /= nul) then
737
        -- if string too long, prevent tool hang, truncate and notify
738
        if(j > c_stm_text_len) then
739
          print("tokenize_line: truncated txt line, it was larger than c_stm_text_len");
740
          exit;
741
        end if;
742
        txt_ptr(j) := text_line(i);
743
        j := j + 1;
744
      -- if is a character store in the right token
745
      elsif(is_space(text_line(i)) = false and text_line(i) /= nul) then
746
        token_index  := token_index + 1;
747
        current_token(token_index)    := text_line(i);
748
      -- else is a space, deal with pointers
749
      elsif(is_space(text_line(i + 1)) = false and text_line(i + 1) /= nul) then
750
        case token_number is
751
          when 0 =>
752
            if(token_index /= 0) then
753
              token1  :=  current_token;
754
              current_token  :=  (others => nul);
755
              token_number := 1;
756
              valid        := 1;
757
              token_index  := 0;
758
            end if;
759
          when 1 =>
760
            token2  :=  current_token;
761
            current_token  :=  (others => nul);
762
            token_number := 2;
763
            valid        := 2;
764
            token_index  := 0;
765
          when 2 =>
766
            token3  :=  current_token;
767
            current_token  :=  (others => nul);
768
            token_number := 3;
769
            valid        := 3;
770
            token_index  := 0;
771
          when 3 =>
772
            token4  :=  current_token;
773
            current_token  :=  (others => nul);
774
            token_number := 4;
775
            valid        := 4;
776
            token_index  := 0;
777
          when 4 =>
778
            token5  :=  current_token;
779
            current_token  :=  (others => nul);
780
            token_number := 5;
781
            valid        := 5;
782
            token_index  := 0;
783
          when 5 =>
784
            token6  :=  current_token;
785
            current_token  :=  (others => nul);
786
            token_number := 6;
787
            valid        := 6;
788
            token_index  := 0;
789
          when 6 =>
790
            token7  :=  current_token;
791
            current_token  :=  (others => nul);
792
            token_number := 7;
793
            valid        := 7;
794
            token_index  := 0;
795
          when 7 =>
796
          when others =>
797
            null;
798
        end case;
799
      end if;
800
      -- break from loop if is null
801
      if(text_line(i) = nul) then
802
        if(token_index /= 0) then
803
          case token_number is
804
            when 0 =>
805
              token1  :=  current_token;
806
              valid   := 1;
807
            when 1 =>
808
              token2  :=  current_token;
809
              valid   := 2;
810
            when 2 =>
811
              token3  :=  current_token;
812
              valid   := 3;
813
            when 3 =>
814
              token4  :=  current_token;
815
              valid   := 4;
816
            when 4 =>
817
              token5  :=  current_token;
818
              valid   := 5;
819
            when 5 =>
820
              token6  :=  current_token;
821
              valid   := 6;
822
            when 6 =>
823
              token7  :=  current_token;
824
              valid   := 7;
825
            when others =>
826
              null;
827
          end case;
828
        end if;
829
        exit;
830
      end if;
831
    end loop;
832
    -- did we find a comment and there is a token
833
    if(comment_found = 1) then
834
      if(token_index /= 0) then
835
        case token_number is
836
          when 0 =>
837
            token1  :=  current_token;
838
            valid   := 1;
839
          when 1 =>
840
            token2  :=  current_token;
841
            valid   := 2;
842
          when 2 =>
843
            token3  :=  current_token;
844
            valid   := 3;
845
          when 3 =>
846
            token4  :=  current_token;
847
            valid   := 4;
848
          when 4 =>
849
            token5  :=  current_token;
850
            valid   := 5;
851
          when 5 =>
852
            token6  :=  current_token;
853
            valid   := 6;
854
          when 6 =>
855
            token7  :=  current_token;
856
            valid   := 7;
857
          when others =>
858
            null;
859
        end case;
860
      end if;
861
    end if;
862
  end tokenize_line;
863
-------------------------------------------------------------------------------
864
-- Add a new instruction to the instruction list
865 10 sckoarn
--   inputs  :   the linked list of instructions
866
--               the instruction
867
--               the number of args
868
--   outputs :   Updated instruction set linked list
869 2 sckoarn
  procedure define_instruction(variable inst_set: inout inst_def_ptr;
870
                               constant inst:     in    string;
871
                               constant args:     in    integer) is
872
    variable v_inst_ptr:    inst_def_ptr;
873
    variable v_prev_ptr:    inst_def_ptr;
874
    variable v_new_ptr:     inst_def_ptr;
875
    variable v_temp_inst:   inst_def_ptr;
876
    variable v_length:      integer;
877
    variable v_list_size:   integer;
878
    variable v_dup_error:   boolean;
879
 
880
  begin
881
    assert(inst'high <= max_field_len)
882
      report LF & "Error: Creation of Instruction of length greater than Max_field_len attemped!!" &
883
             LF & "This Max is currently set to " & (integer'image(max_field_len))
884
    severity failure;
885
    -- get to the last element and test is not exsiting
886
    v_temp_inst :=  inst_set;
887
    v_inst_ptr  :=  inst_set;
888
    -- zero the size
889
    v_list_size :=  0;
890
    while(v_inst_ptr /= null) loop
891
      -- if there is a chance of a duplicate command
892
      if(v_inst_ptr.instruction_l = inst'high) then
893
        v_dup_error := true;
894
        for i in 1 to inst'high loop
895
          if(v_inst_ptr.instruction(i) /= inst(i)) then
896
            v_dup_error := false;
897
          end if;
898
        end loop;
899
        -- if we find a duplicate, die
900
        assert(v_dup_error = false)
901
          report LF & "Error: Duplicate instruction definition attempted!"
902
        severity failure;
903
      end if;
904
      v_prev_ptr  := v_inst_ptr;  -- store for pointer updates
905
      v_inst_ptr  := v_inst_ptr.next_rec;
906
      v_list_size :=  v_list_size + 1;
907
    end loop;
908
 
909
    -- add the new instruction
910
    v_new_ptr   := new inst_def;
911
    -- if this is the first command return new pointer
912
    if(v_list_size = 0) then
913
      v_temp_inst :=  v_new_ptr;
914
    -- else write new pointer to next_rec
915
    else
916
      v_prev_ptr.next_rec  :=  v_new_ptr;
917
    end if;
918
    v_new_ptr.instruction_l := inst'high;
919
    v_new_ptr.params        := args;
920
    -- copy the instruction text into field
921
    for i in 1 to v_new_ptr.instruction_l loop
922
      v_new_ptr.instruction(i) := inst(i);
923
    end loop;
924
    -- return the pointer
925
    inst_set  :=  v_temp_inst;
926
 
927
  end define_instruction;
928
 
929
--------------------------------------------------------------------------------
930
--  Check for valid instruction in the list of instructions
931
procedure check_valid_inst(variable inst     :  in text_field;
932
                           variable inst_set :  in inst_def_ptr;
933
                           variable token_num:  in integer;
934
                           variable line_num :  in integer;
935
                           variable name     :  in text_line) is
936
    variable l :     integer  := 0;
937
    variable seti:   inst_def_ptr;
938
    variable match:  integer  := 0;
939
    variable ilv:    integer  := 0;  -- inline variable
940
  begin
941
    -- create useable pointer
942
    seti  := inst_set;
943
    -- count up the characters in inst
944
    l := fld_len(inst);
945
      -- if this is a referance variable -- handle in add variable Proc
946
    if(inst(l) = ':') then
947
      match  := 1;
948
      ilv    := 1;
949
    else
950
      -- process list till null next
951
      while (seti.next_rec /= null) loop
952
        if(seti.instruction_l = l) then
953
          match  := 1;
954
          for j in 1 to l loop
955
            if(seti.instruction(j) /= inst(j)) then
956
              match  := 0;
957
            end if;
958
          end loop;
959
        end if;
960
        if(match = 0) then
961
          seti  := seti.next_rec;
962
        else
963
          exit;
964
        end if;
965
      end loop;
966
      -- check current one
967
      if(seti.instruction_l = l and match = 0) then
968
        match  := 1;
969
        for j in 1 to l loop
970
          if(seti.instruction(j) /= inst(j)) then
971
            match  := 0;
972
          end if;
973
        end loop;
974
      end if;
975
    end if;
976
 
977
    -- if we had a match, check the number of paramiters
978
    if(match = 1 and ilv = 0) then
979
      assert(seti.params = (token_num - 1))
980
        report LF & "Error: Undefined Instruction was found, incorrect number of fields passed!" & LF &
981
                    "This is found on line " & (integer'image(line_num)) & " in file " & name & LF
982
      severity failure;
983
    end if;
984
 
985
    -- if we find a duplicate, die
986
    assert(match = 1)
987
      report LF & "Error: Undefined Instruction on line " & (integer'image(line_num)) &
988
                  " found in input file " & name & LF
989
    severity failure;
990
  end check_valid_inst;
991
 
992
--------------------------------------------------------------------------------
993
--  add_variable
994
--    This procedure adds a variable to the variable list.  This is localy
995
--    available at this time.
996
procedure add_variable(variable var_list  :   inout  var_field_ptr;
997
                       variable p1        :  in text_field;  -- should be var name
998
                       variable p2        :  in text_field;  -- should be value
999
                       variable token_num :  in integer;
1000
                       variable sequ_num  :  in integer;
1001
                       variable line_num  :  in integer;
1002
                       variable name      :  in text_line;
1003
                       variable length    :  in integer) is
1004
 
1005
    variable temp_var:       var_field_ptr;
1006
    variable current_ptr:    var_field_ptr;
1007
    variable index:          integer := 1;
1008
 
1009
  begin
1010
    -- if this is NOT the first one
1011
    if(var_list /= null) then
1012
      current_ptr  := var_list;
1013
      index        := index + 1;
1014
      if(p1(length) /= ':') then  -- is not an inline variable
1015
        while(current_ptr.next_rec /= null) loop
1016
          -- if we have defined the current before then die
1017
          assert(current_ptr.var_name /= p1)
1018
            report LF & "Error: Attemping to add a duplicate Variable definition "
1019
                      & " on line " & (integer'image(line_num)) & " of file " & name
1020
          severity failure;
1021
 
1022
          current_ptr  :=  current_ptr.next_rec;
1023
          index  := index + 1;
1024
        end loop;
1025
        -- if we have defined the current before then die. This checks the last one
1026
        assert(current_ptr.var_name /= p1)
1027
          report LF & "Error: Attemping to add a duplicate Variable definition "
1028
                    & " on line " & (integer'image(line_num)) & " of file " & name
1029
        severity failure;
1030
 
1031
        temp_var              := new var_field;
1032
        temp_var.var_name     := p1;  -- direct write of text_field
1033
        temp_var.var_value    := stim_to_integer(p2,name,line_num); -- convert text_field to integer
1034
        temp_var.var_index    := index;
1035
        current_ptr.next_rec  :=  temp_var;
1036
      else
1037
        while(current_ptr.next_rec /= null) loop
1038
          -- if we have defined the current before then die
1039
          assert(current_ptr.var_name(1 to (length - 1)) /= p1(1 to (length - 1)))
1040
            report LF & "Error: Attemping to add a duplicate Inline Variable definition "
1041
                      & " on line " & (integer'image(line_num)) & " of file " & name
1042
          severity failure;
1043
 
1044
          current_ptr  :=  current_ptr.next_rec;
1045
          index  := index + 1;
1046
        end loop;
1047
        -- if we have defined the current before then die. This checks the last one
1048
        assert(current_ptr.var_name(1 to (length - 1)) /= p1(1 to (length - 1)))
1049
          report LF & "Error: Attemping to add a duplicate Inline Variable definition "
1050
                    & " on line " & (integer'image(line_num)) & " of file " & name
1051
        severity failure;
1052
 
1053
        temp_var              := new var_field;
1054
        temp_var.var_name(1 to (length - 1))     := p1(1 to (length - 1));
1055
        temp_var.var_value    := sequ_num;
1056
        temp_var.var_index    := index;
1057
        current_ptr.next_rec  :=  temp_var;
1058
      end if;
1059
    -- this is the first one
1060
    else
1061
      if(p1(length) /= ':') then  -- is not an inline variable
1062
        temp_var            := new var_field;
1063
        temp_var.var_name   := p1;  -- direct write of text_field
1064
        temp_var.var_index  := index;
1065
        temp_var.var_value  := stim_to_integer(p2,name,line_num); -- convert text_field to integer
1066
        var_list  :=  temp_var;
1067
      else
1068
        temp_var              := new var_field;
1069
        temp_var.var_name(1 to (length - 1))     := p1(1 to (length - 1));
1070
        temp_var.var_value    := sequ_num;
1071
        temp_var.var_index    := index;
1072
        var_list              :=  temp_var;
1073
      end if;
1074
    end if;
1075
  end add_variable;
1076
--------------------------------------------------------------------------------
1077
--  add_instruction
1078
--    This is the procedure that adds the instruction to the linked list of
1079
--    instructions.  Also Variable addition are called and or handled.
1080
--    the instruction sequence Link list.
1081
--     inputs:
1082
--               stim_line_ptr   is the pointer to the instruction List
1083
--               inst            is the instruction token
1084
--               p1              paramitor one, corrisponds to field one of stimulus
1085
--               p2              paramitor one, corrisponds to field two of stimulus
1086
--               p3              paramitor one, corrisponds to field three of stimulus
1087
--               p4              paramitor one, corrisponds to field four of stimulus
1088
--               p5              paramitor one, corrisponds to field three of stimulus
1089
--               p6              paramitor one, corrisponds to field four of stimulus
1090
--               str_ptr         pointer to string for print instruction
1091
--               token_num       the number of tokens, including instruction
1092
--               sequ_num        is the stimulus file line referance  ie program line number
1093
--               line_num        Line number in the text file
1094
--     outputs:
1095
--               none.  Error will terminate sim
1096
  procedure add_instruction(variable inst_list  :  inout stim_line_ptr;
1097
                            variable var_list   :  inout var_field_ptr;
1098
                            variable inst       :  in text_field;
1099
                            variable p1         :  in text_field;
1100
                            variable p2         :  in text_field;
1101
                            variable p3         :  in text_field;
1102
                            variable p4         :  in text_field;
1103
                            variable p5         :  in text_field;
1104
                            variable p6         :  in text_field;
1105
                            variable str_ptr    :  in stm_text_ptr;
1106
                            variable token_num  :  in integer;
1107
                            variable sequ_num   :  inout integer;
1108
                            variable line_num   :  in integer;
1109 10 sckoarn
                            variable file_name  :  in text_line;
1110
                            variable file_idx   :  in integer) is
1111 2 sckoarn
   variable temp_stim_line:  stim_line_ptr;
1112
   variable temp_current:    stim_line_ptr;
1113
   variable valid:           integer;
1114
   variable l:               integer;
1115
 begin
1116
   valid  := 1;
1117
   l := fld_len(inst);
1118
   temp_current  :=  inst_list;
1119
   -- take care of special cases
1120
   if(inst(1 to l) = "DEFINE_VAR") then
1121
     l := fld_len(p1);
1122
     --  Add the variable to the Variable pool, not considered an instruction
1123
     add_variable(var_list,p1,p2,token_num,sequ_num,line_num,file_name,l);
1124 10 sckoarn
     valid := 0;  --Removes this from the instruction list 
1125 2 sckoarn
   elsif(inst(l) = ':') then
1126
     add_variable(var_list,inst,p1,token_num,sequ_num,line_num,file_name,l);
1127
     valid := 0;
1128
   end if;
1129
 
1130
   if(valid = 1) then
1131
     -- prepare the new record
1132
     temp_stim_line  := new stim_line;
1133
     temp_stim_line.instruction   := inst;
1134
     temp_stim_line.inst_field_1  := p1;
1135
     temp_stim_line.inst_field_2  := p2;
1136
     temp_stim_line.inst_field_3  := p3;
1137
     temp_stim_line.inst_field_4  := p4;
1138
     temp_stim_line.inst_field_5  := p5;
1139
     temp_stim_line.inst_field_6  := p6;
1140
     temp_stim_line.txt           := str_ptr;
1141
     temp_stim_line.line_number   := sequ_num;
1142 10 sckoarn
     temp_stim_line.file_idx     := file_idx;
1143 2 sckoarn
     temp_stim_line.file_line     := line_num;
1144
 
1145
     -- if is not the first instruction
1146
     if(inst_list /= null) then
1147
       while(temp_current.next_rec /= null) loop
1148
         temp_current  := temp_current.next_rec;
1149
       end loop;
1150
       temp_current.next_rec  :=  temp_stim_line;
1151
       inst_list.num_of_lines :=  inst_list.num_of_lines + 1;
1152
     -- other wise is first instruction to be added
1153
     else
1154
       inst_list  :=  temp_stim_line;
1155
       inst_list.num_of_lines := 1;
1156
     end if;
1157
     sequ_num  :=  sequ_num + 1;
1158
--     print_inst(temp_stim_line);  -- for debug
1159
   end if;
1160
 
1161
 end add_instruction;
1162 10 sckoarn
------------------------------------------------------------------------------
1163
-- test_inst_sequ
1164
--  This procedure accesses the full instruction sequence and checks for valid
1165
--   variables.  This is prior to the simulation run start.
1166
  procedure test_inst_sequ(variable inst_sequ  :  in  stim_line_ptr;
1167
                           variable file_list  :  in  file_def_ptr;
1168
                           variable var_list   :  in  var_field_ptr
1169
                          ) is
1170
    variable temp_text_field:     text_field;
1171
    variable temp_var:            text_field;
1172
    variable inst_ptr:            stim_line_ptr;
1173
    variable valid:               integer;
1174
    variable line:                integer;  -- value of the file_line
1175
    variable file_name:           text_line;
1176
    variable v_p:                 integer;
1177
    variable inst       :         text_field;
1178
    variable txt        :         stm_text_ptr;
1179
    variable inst_len   :         integer;
1180
    variable fname      :         text_line;
1181
    variable file_line  :         integer;
1182
    variable temp_fn_prt:         file_def_ptr;
1183
    variable tmp_int    :         integer;
1184
 
1185
  begin
1186
    inst_ptr  :=  inst_sequ;
1187
    -- go through all the instructions
1188
    while(inst_ptr.next_rec /= null) loop
1189
      inst := inst_ptr.instruction;
1190
      inst_len := fld_len(inst_ptr.instruction);
1191
      file_line := inst_ptr.file_line;
1192
      line      := inst_ptr.file_line;
1193
      -- recover the file name this line came from
1194
      temp_fn_prt := file_list;
1195
      tmp_int   :=  inst_ptr.file_idx;
1196
      while (temp_fn_prt.next_rec /= null) loop
1197
        if(temp_fn_prt.rec_idx = tmp_int) then
1198
          exit;
1199
        end if;
1200
        temp_fn_prt  :=  temp_fn_prt.next_rec;
1201
      end loop;
1202
      for i in 1 to fname'high loop
1203
        file_name(i) :=  temp_fn_prt.file_name(i);
1204
      end loop;
1205
 
1206
      txt       := inst_ptr.txt;
1207
      -- load parameter one
1208
      temp_text_field  :=  inst_ptr.inst_field_1;
1209
      if(temp_text_field(1) /= nul) then
1210
        -- if this is a numaric  do nothing
1211
        if(temp_text_field(1) = 'x' or temp_text_field(1) = 'h' or
1212
           temp_text_field(1) = 'b' or is_digit(temp_text_field(1)) = true) then
1213
           null;
1214
        else  -- else is a variable, get the value or halt incase of error
1215
          access_variable(var_list,temp_text_field,v_p,valid);
1216
          assert(valid = 1)
1217
            report LF & "Error: First variable on stimulus line " & (integer'image(line))
1218
                      & " is not valid!!" & LF & "In file " & file_name
1219
          severity failure;
1220
        end if;
1221
      end if;
1222
      -- load parameter two
1223
      temp_text_field  :=  inst_ptr.inst_field_2;
1224
      if(temp_text_field(1) /= nul) then
1225
        -- if this is a numaric do nothing
1226
        if(temp_text_field(1) = 'x' or temp_text_field(1) = 'h' or
1227
           temp_text_field(1) = 'b' or is_digit(temp_text_field(1)) = true) then
1228
           null;
1229
        else  -- else is a variable, get the value or halt incase of error
1230
          access_variable(var_list,temp_text_field,v_p,valid);
1231
          assert(valid = 1)
1232
            report LF & "Error: Second variable on stimulus line " & (integer'image(line))
1233
                      & " is not valid!!" & LF & "In file " & file_name
1234
          severity failure;
1235
        end if;
1236
      end if;
1237
      -- load parameter three
1238
      temp_text_field  :=  inst_ptr.inst_field_3;
1239
      if(temp_text_field(1) /= nul) then
1240
        -- if this is a numaric do nothing
1241
        if(temp_text_field(1) = 'x' or temp_text_field(1) = 'h' or
1242
           temp_text_field(1) = 'b' or is_digit(temp_text_field(1)) = true) then
1243
           null;
1244
        else  -- else is a variable, get the value or halt incase of error
1245
          access_variable(var_list,temp_text_field,v_p,valid);
1246
          assert(valid = 1)
1247
            report LF & "Error: Third variable on stimulus line " & (integer'image(line))
1248
                      & " is not valid!!" & LF & "In file " & file_name
1249
          severity failure;
1250
        end if;
1251
      end if;
1252
      -- load parameter four
1253
      temp_text_field  :=  inst_ptr.inst_field_4;
1254
      if(temp_text_field(1) /= nul) then
1255
        -- if this is a numaric do nothing
1256
        if(temp_text_field(1) = 'x' or temp_text_field(1) = 'h' or
1257
           temp_text_field(1) = 'b'or is_digit(temp_text_field(1)) = true) then
1258
           null;
1259
        else  -- else is a variable, get the value or halt incase of error
1260
          access_variable(var_list,temp_text_field,v_p,valid);
1261
          assert(valid = 1)
1262
            report LF & "Error: Forth variable on stimulus line " & (integer'image(line))
1263
                      & " is not valid!!" & LF & "In file " & file_name
1264
          severity failure;
1265
        end if;
1266
      end if;
1267
      -- load parameter five
1268
      temp_text_field  :=  inst_ptr.inst_field_5;
1269
      if(temp_text_field(1) /= nul) then
1270
        -- if this is a numaric do nothing
1271
        if(temp_text_field(1) = 'x' or temp_text_field(1) = 'h' or
1272
          temp_text_field(1) = 'b' or is_digit(temp_text_field(1)) = true) then
1273
          null;
1274
        else  -- else is a variable, get the value or halt incase of error
1275
          access_variable(var_list,temp_text_field,v_p,valid);
1276
          assert(valid = 1)
1277
            report LF & "Error: Fifth variable on stimulus line " & (integer'image(line))
1278
                      & " is not valid!!" & LF & "In file " & file_name
1279
          severity failure;
1280
        end if;
1281
      end if;
1282
      -- load parameter six
1283
      temp_text_field  :=  inst_ptr.inst_field_6;
1284
      if(temp_text_field(1) /= nul) then
1285
        -- if this is a numaric field convert to integer
1286
        if(temp_text_field(1) = 'x' or temp_text_field(1) = 'h' or
1287
           temp_text_field(1) = 'b' or is_digit(temp_text_field(1)) = true) then
1288
           null;
1289
        else  -- else is a variable, get the value or halt incase of error
1290
          access_variable(var_list,temp_text_field,v_p,valid);
1291
          assert(valid = 1)
1292
            report LF & "Error: Sixth variable on stimulus line " & (integer'image(line))
1293
                      & " is not valid!!" & LF & "In file " & file_name
1294
          severity failure;
1295
        end if;
1296
      end if;
1297
      -- point to next record
1298
      inst_ptr := inst_ptr.next_rec;
1299
    end loop;
1300
 
1301
  end test_inst_sequ;
1302 2 sckoarn
--------------------------------------------------------------------------------
1303
--  The read include file procedure
1304
--    This is the main procedure for reading, parcing, checking and returning
1305
--    the instruction sequence Link list.
1306
  procedure read_include_file(variable name:       text_line;
1307
                              variable sequ_numb:  inout integer;
1308 10 sckoarn
                              variable file_list:  inout file_def_ptr;
1309 2 sckoarn
                              variable inst_set:   inout inst_def_ptr;
1310
                              variable var_list:   inout var_field_ptr;
1311
                              variable inst_sequ:  inout stim_line_ptr;
1312
                              variable status:     inout integer) is
1313
    variable l:          text_line; -- the line
1314
    variable l_num:      integer;   -- line number file
1315
    variable sequ_line:  integer;   -- line number program
1316
    variable t1:         text_field;
1317
    variable t2:         text_field;
1318
    variable t3:         text_field;
1319
    variable t4:         text_field;
1320
    variable t5:         text_field;
1321
    variable t6:         text_field;
1322
    variable t7:         text_field;
1323
    variable t_txt:      stm_text_ptr;
1324
    variable valid:      integer;
1325
    variable v_inst_ptr: inst_def_ptr;
1326
    variable v_var_prt:  var_field_ptr;
1327
    variable v_sequ_ptr: stim_line_ptr;
1328
    variable v_len:      integer;
1329
    variable v_stat:     file_open_status;
1330 10 sckoarn
    variable idx:        integer;
1331
    variable v_tmp:      text_line;
1332
 
1333
    variable v_tmp_fn_ptr: file_def_ptr;
1334
    variable v_new_fn:     integer;
1335
    variable v_tmp_fn:   file_def_ptr;
1336
    variable v_txt:      stm_text; --stm_text_ptr;
1337 2 sckoarn
 
1338
  begin
1339 10 sckoarn
    sequ_line     :=  sequ_numb;
1340
    v_tmp_fn_ptr  :=  file_list;
1341
    -- for linux systems, trailing spaces need to be removed
1342
    --    from file names
1343
    --  copy text string to temp
1344
    for i in 1 to c_stm_text_len loop
1345
      if(name(i) = nul) then
1346
        v_tmp(i) := name(i);
1347
        exit;
1348
      else
1349
        v_tmp(i) := name(i);
1350
      end if;
1351
    end loop;
1352
    --fix up any trailing white space in txt
1353
    idx  :=  0;
1354
    --    get to the end of the string
1355
    for i in 1 to c_stm_text_len loop
1356
      if(v_tmp(i) /= nul) then
1357
        idx  :=  idx + 1;
1358
      else
1359
        exit;
1360
      end if;
1361
    end loop;
1362
    --  now nul out spaces
1363
    for i in idx downto 1 loop
1364
      if(is_space(v_tmp(i)) = true) then
1365
        v_tmp(i) := nul;
1366
      else
1367
        exit;
1368
      end if;
1369
    end loop;
1370
    --  open include file
1371
    file_open(v_stat, include_file, v_tmp, read_mode);
1372 2 sckoarn
    if(v_stat /= open_ok) then
1373
      print("Error: Unable to open include file  " & name);
1374
      status   :=  1;
1375
      return;
1376
    end if;
1377
    l_num      :=  1;  -- initialize line number
1378
 
1379 10 sckoarn
    --  the file is opened, put it on the file name LL
1380
    while (v_tmp_fn_ptr.next_rec /= null) loop
1381
      v_tmp_fn_ptr :=  v_tmp_fn_ptr.next_rec;
1382
    end loop;
1383
    v_new_fn   :=  v_tmp_fn_ptr.rec_idx + 1;
1384
    v_tmp_fn            :=  new file_def;
1385
    v_tmp_fn_ptr.next_rec  :=  v_tmp_fn;
1386
    v_tmp_fn.rec_idx    := v_new_fn;
1387
 
1388
    --  nul the text line
1389
    v_tmp_fn.file_name  := (others => nul);
1390
    for i in 1 to name'high loop
1391
      v_tmp_fn.file_name(i)  := name(i);
1392
    end loop;
1393
    v_tmp_fn.next_rec  :=  null;
1394
 
1395
 
1396 2 sckoarn
    v_inst_ptr :=  inst_set;
1397
    v_var_prt  :=  var_list;
1398
    v_sequ_ptr :=  inst_sequ;
1399
 
1400
    -- while not the end of file read it
1401
    while(not endfile(include_file)) loop
1402
      file_read_line(include_file,l);
1403
      --  tokenize the line
1404
      tokenize_line(l,t1,t2,t3,t4,t5,t6,t7,t_txt,valid);
1405
      v_len  := fld_len(t1);
1406
      if(t1(1 to v_len) = "INCLUDE") then
1407 10 sckoarn
        print("Nested INCLUDE statement found in " & v_tmp & " on line " &
1408
              (integer'image(l_num)));
1409
        assert(false)
1410
          report LF & "Error: Nested INCLUDE statements are not supported at this time."
1411
        severity failure;
1412 2 sckoarn
 
1413
      -- if there was valid tokens
1414
      elsif(valid /= 0) then
1415
        check_valid_inst(t1, v_inst_ptr, valid, l_num, name);
1416 10 sckoarn
        add_instruction(v_sequ_ptr,v_var_prt,t1,t2,t3,t4,t5,t6,t7,t_txt,valid,
1417
                        sequ_line,l_num,name,v_new_fn);
1418 2 sckoarn
      end if;
1419
      l_num  :=  l_num + 1;
1420
    end loop; -- end loop read file
1421
    file_close(include_file);
1422
    sequ_numb  :=  sequ_line;
1423
    inst_set   :=  v_inst_ptr;
1424
    var_list   :=  v_var_prt;
1425
    inst_sequ  :=  v_sequ_ptr;
1426
  end read_include_file;
1427
 
1428
--------------------------------------------------------------------------------
1429
--  The read instruction file procedure
1430
--    This is the main procedure for reading, parcing, checking and returning
1431
--    the instruction sequence Link list.
1432
  procedure read_instruction_file(constant file_name:  string;
1433
                                  variable inst_set:   inout inst_def_ptr;
1434
                                  variable var_list:   inout var_field_ptr;
1435 10 sckoarn
                                  variable inst_sequ:  inout stim_line_ptr;
1436
                                  variable file_list:  inout file_def_ptr) is
1437 2 sckoarn
    variable l:          text_line; -- the line
1438
    variable l_num:      integer;   -- line number file
1439
    variable sequ_line:  integer;   -- line number program
1440
    variable t1:         text_field;
1441
    variable t2:         text_field;
1442
    variable t3:         text_field;
1443
    variable t4:         text_field;
1444
    variable t5:         text_field;
1445
    variable t6:         text_field;
1446
    variable t7:         text_field;
1447
    variable t_txt:      stm_text_ptr;
1448
    variable valid:      integer;
1449
    variable v_ostat:    integer;
1450
    variable v_inst_ptr: inst_def_ptr;
1451
    variable v_var_prt:  var_field_ptr;
1452
    variable v_sequ_ptr: stim_line_ptr;
1453
    variable v_len:      integer;
1454
    variable v_stat:     file_open_status;
1455
    variable v_name:     text_line;
1456
    variable v_iname:    text_line;
1457 10 sckoarn
    variable v_tmp_fn:   file_def_ptr;
1458
    variable v_fn_idx:   integer;
1459
    variable v_idx:      integer;
1460
 
1461 2 sckoarn
  begin
1462
    -- open the stimulus_file and check
1463
    file_open(v_stat, stimulus, file_name, read_mode);
1464
    assert(v_stat = open_ok)
1465
      report LF & "Error: Unable to open stimulus_file  " & file_name
1466
    severity failure;
1467
    -- copy file name to type text_line
1468
    for i in 1 to file_name'high loop
1469
      v_name(i)  := file_name(i);
1470
    end loop;
1471 10 sckoarn
    -- the first item on the file names link list
1472
    file_list           :=  null;
1473
    v_tmp_fn            :=  new file_def;
1474
    v_tmp_fn.rec_idx    := 1;
1475
    v_fn_idx            := 1;
1476
    v_idx               := 1;
1477
    --  nul the text line
1478
    v_tmp_fn.file_name  := (others => nul);
1479
    for i in 1 to file_name'high loop
1480
      v_tmp_fn.file_name(i)  := file_name(i);
1481
    end loop;
1482
    v_tmp_fn.next_rec  :=  null;
1483
 
1484 2 sckoarn
    l_num      :=  1;
1485
    sequ_line  :=  1;
1486
    v_ostat    :=  0;
1487
 
1488
    v_inst_ptr :=  inst_set;
1489
    v_var_prt  :=  var_list;
1490
    v_sequ_ptr :=  inst_sequ;
1491
 
1492
    -- while not the end of file read it
1493
    while(not endfile(stimulus)) loop
1494
      file_read_line(stimulus,l);
1495
      --  tokenize the line
1496
      tokenize_line(l,t1,t2,t3,t4,t5,t6,t7,t_txt,valid);
1497
      v_len  := fld_len(t1);
1498
      -- if there is an INCLUDE instruction
1499
      if(t1(1 to v_len) = "INCLUDE") then
1500 10 sckoarn
        -- if file name is in par2
1501 2 sckoarn
        if(valid = 2) then
1502
          v_iname  := (others => nul);
1503
          for i in 1 to max_field_len loop
1504
            v_iname(i) := t2(i);
1505
          end loop;
1506 10 sckoarn
        -- elsif the text string is not null
1507
        elsif(t_txt /= null) then
1508 2 sckoarn
          v_iname  := (others => nul);
1509
          for i in 1 to c_stm_text_len loop
1510
            v_iname(i) := t_txt(i);
1511 10 sckoarn
            if(t_txt(i) = nul) then
1512
              exit;
1513
            end if;
1514
          end loop;
1515
        else
1516
          assert(false)
1517
            report LF & "Error:  INCLUDE instruction has not file name included.  Found on" & LF &
1518
                        "line " & (integer'image(l_num)) & " in file " & file_name & LF
1519
          severity failure;
1520 2 sckoarn
        end if;
1521
        print("INCLUDE found: Loading file " & v_iname);
1522 10 sckoarn
        read_include_file(v_iname,sequ_line,v_tmp_fn,v_inst_ptr,v_var_prt,v_sequ_ptr,v_ostat);
1523 2 sckoarn
        -- if include file not found
1524
        if(v_ostat = 1) then
1525
          exit;
1526
        end if;
1527
      -- if there was valid tokens
1528
      elsif(valid /= 0) then
1529
        check_valid_inst(t1, v_inst_ptr, valid, l_num, v_name);
1530 10 sckoarn
        add_instruction(v_sequ_ptr,v_var_prt,t1,t2,t3,t4,t5,t6,t7,t_txt,valid,
1531
                        sequ_line,l_num,v_name,v_fn_idx);
1532 2 sckoarn
      end if;
1533
      l_num  :=  l_num + 1;
1534
    end loop; -- end loop read file
1535
 
1536
    file_close(stimulus);  -- close the file when done
1537
 
1538
    assert(v_ostat = 0)
1539 10 sckoarn
      report LF & "Include file specified on line " & (integer'image(l_num)) &
1540
                  " in file " &  file_name &
1541
                  " was not found! Test Terminated" & LF
1542 2 sckoarn
    severity failure;
1543
 
1544
    inst_set   :=  v_inst_ptr;
1545
    var_list   :=  v_var_prt;
1546
    inst_sequ  :=  v_sequ_ptr;
1547 10 sckoarn
    file_list  :=  v_tmp_fn;
1548
 
1549
    --  Now that all the stimulus is loaded, test for invalid variables
1550
    test_inst_sequ(inst_sequ, v_tmp_fn, var_list);
1551
 
1552 2 sckoarn
  end read_instruction_file;
1553
 
1554
------------------------------------------------------------------------------
1555
-- access_inst_sequ
1556
--  This procedure accesses the instruction sequence and returns the parameters
1557 10 sckoarn
--  as they exsist related to the variables state.
1558
--  INPUTS:   inst_sequ  link list of instructions from stimulus
1559
--            var_list   link list of variables
1560
--            file_list  link list of file names
1561
--            sequ_num   the sequence number to recover
1562
--
1563
--  OUTPUTS:  inst  instruction text
1564
--            p1    paramiter 1 in integer form
1565
--            p2    paramiter 2 in integer form
1566
--            p3    paramiter 3 in integer form
1567
--            p4    paramiter 4 in integer form
1568
--            p5    paramiter 5 in integer form
1569
--            p6    paramiter 6 in integer form
1570
--            txt   pointer to any text string of this sequence
1571
--            inst_len  the lenth of inst in characters
1572
--            fname  file name this sequence came from
1573
--            file_line  the line number in fname this sequence came from
1574
--            
1575 2 sckoarn
  procedure access_inst_sequ(variable inst_sequ  :  in  stim_line_ptr;
1576
                             variable var_list   :  in  var_field_ptr;
1577 10 sckoarn
                             variable file_list  :  in  file_def_ptr;
1578 2 sckoarn
                             variable sequ_num   :  in  integer;
1579
                             variable inst       :  out text_field;
1580
                             variable p1         :  out integer;
1581
                             variable p2         :  out integer;
1582
                             variable p3         :  out integer;
1583
                             variable p4         :  out integer;
1584
                             variable p5         :  out integer;
1585
                             variable p6         :  out integer;
1586
                             variable txt        :  out stm_text_ptr;
1587
                             variable inst_len   :  out integer;
1588
                             variable fname      :  out text_line;
1589 13 sckoarn
                             variable file_line  :  out integer;
1590
                             variable last_num   :  inout integer;
1591
                             variable last_ptr   :  inout stim_line_ptr
1592 2 sckoarn
                             ) is
1593
    variable temp_text_field:     text_field;
1594
    variable temp_var:            text_field;
1595
    variable inst_ptr:            stim_line_ptr;
1596
    variable valid:               integer;
1597
    variable line:                integer;  -- value of the file_line
1598
    variable file_name:           text_line;
1599 10 sckoarn
    variable tmp_int:             integer;
1600
    variable temp_fn_prt:         file_def_ptr;
1601 2 sckoarn
  begin
1602
   -- get to the instruction indicated by sequ_num
1603 13 sckoarn
   -- check to see if this sequence is before the last
1604
   --    so search from start
1605
    if(last_num  > sequ_num) then
1606
      inst_ptr  :=  inst_sequ;
1607
      while(inst_ptr.next_rec /= null) loop
1608
        if(inst_ptr.line_number = sequ_num) then
1609
          exit;
1610
        else
1611
          inst_ptr := inst_ptr.next_rec;
1612
        end if;
1613
      end loop;
1614
    -- else is equal or greater, so search forward
1615
    else
1616
      inst_ptr  :=  last_ptr;
1617
      while(inst_ptr.next_rec /= null) loop
1618
        if(inst_ptr.line_number = sequ_num) then
1619
          exit;
1620
        else
1621
          inst_ptr := inst_ptr.next_rec;
1622
        end if;
1623
      end loop;
1624
    end if;
1625
 
1626
    -- update the last sequence number and record pointer
1627
    last_num  :=  sequ_num;
1628
    last_ptr  :=  inst_ptr;
1629
 
1630 2 sckoarn
    -- output the instruction and its length
1631
    inst := inst_ptr.instruction;
1632
    inst_len := fld_len(inst_ptr.instruction);
1633
    file_line := inst_ptr.file_line;
1634
    line      := inst_ptr.file_line;
1635 10 sckoarn
    -- recover the file name this line came from
1636
    temp_fn_prt := file_list;
1637
    tmp_int   :=  inst_ptr.file_idx;
1638
    while (temp_fn_prt.next_rec /= null) loop
1639
      if(temp_fn_prt.rec_idx = tmp_int) then
1640
        exit;
1641
      end if;
1642
      temp_fn_prt  :=  temp_fn_prt.next_rec;
1643
    end loop;
1644
    for i in 1 to fname'high loop
1645
      file_name(i) :=  temp_fn_prt.file_name(i);
1646
    end loop;
1647
 
1648 2 sckoarn
    txt       := inst_ptr.txt;
1649
    -- load parameter one
1650
    temp_text_field  :=  inst_ptr.inst_field_1;
1651
    if(temp_text_field(1) /= nul) then
1652
      -- if this is a numaric field convert to integer
1653
      if(temp_text_field(1) = 'x' or temp_text_field(1) = 'h' or
1654
         temp_text_field(1) = 'b') then
1655
        p1 := stim_to_integer(temp_text_field,file_name,line);
1656
      elsif(is_digit(temp_text_field(1)) = true) then
1657
        p1 := stim_to_integer(temp_text_field,file_name,line);
1658
      else  -- else is a variable, get the value or halt incase of error
1659
        access_variable(var_list,temp_text_field,p1,valid);
1660
        assert(valid = 1)
1661
          report LF & "Error: First variable on stimulus line " & (integer'image(line))
1662
                    & " is not valid!!" & LF & "In file " & file_name
1663
        severity failure;
1664
      end if;
1665
    end if;
1666
    -- load parameter two
1667
    temp_text_field  :=  inst_ptr.inst_field_2;
1668
    if(temp_text_field(1) /= nul) then
1669
      -- if this is a numaric field convert to integer
1670
      if(temp_text_field(1) = 'x' or temp_text_field(1) = 'h' or
1671
         temp_text_field(1) = 'b') then
1672
        p2 := stim_to_integer(temp_text_field,file_name,line);
1673
      elsif(is_digit(temp_text_field(1)) = true) then
1674
        p2 := stim_to_integer(temp_text_field,file_name,line);
1675
      else  -- else is a variable, get the value or halt incase of error
1676
        access_variable(var_list,temp_text_field,p2,valid);
1677
        assert(valid = 1)
1678
          report LF & "Error: Second variable on stimulus line " & (integer'image(line))
1679
                    & " is not valid!!" & LF & "In file " & file_name
1680
        severity failure;
1681
      end if;
1682
    end if;
1683
    -- load parameter three
1684
    temp_text_field  :=  inst_ptr.inst_field_3;
1685
    if(temp_text_field(1) /= nul) then
1686
      -- if this is a numaric field convert to integer
1687
      if(temp_text_field(1) = 'x' or temp_text_field(1) = 'h' or
1688
         temp_text_field(1) = 'b') then
1689
        p3 := stim_to_integer(temp_text_field,file_name,line);
1690
      elsif(is_digit(temp_text_field(1)) = true) then
1691
        p3 := stim_to_integer(temp_text_field,file_name,line);
1692
      else  -- else is a variable, get the value or halt incase of error
1693
        access_variable(var_list,temp_text_field,p3,valid);
1694
        assert(valid = 1)
1695
          report LF & "Error: Third variable on stimulus line " & (integer'image(line))
1696
                    & " is not valid!!" & LF & "In file " & file_name
1697
        severity failure;
1698
      end if;
1699
    end if;
1700
    -- load parameter four
1701
    temp_text_field  :=  inst_ptr.inst_field_4;
1702
    if(temp_text_field(1) /= nul) then
1703
      -- if this is a numaric field convert to integer
1704
      if(temp_text_field(1) = 'x' or temp_text_field(1) = 'h' or
1705
         temp_text_field(1) = 'b') then
1706
        p4 := stim_to_integer(temp_text_field,file_name,line);
1707
      elsif(is_digit(temp_text_field(1)) = true) then
1708
        p4 := stim_to_integer(temp_text_field,file_name,line);
1709
      else  -- else is a variable, get the value or halt incase of error
1710
        access_variable(var_list,temp_text_field,p4,valid);
1711
        assert(valid = 1)
1712
          report LF & "Error: Forth variable on stimulus line " & (integer'image(line))
1713
                    & " is not valid!!" & LF & "In file " & file_name
1714
        severity failure;
1715
      end if;
1716
    end if;
1717
    -- load parameter five
1718
    temp_text_field  :=  inst_ptr.inst_field_5;
1719
    if(temp_text_field(1) /= nul) then
1720
      -- if this is a numaric field convert to integer
1721
      if(temp_text_field(1) = 'x' or temp_text_field(1) = 'h' or
1722
         temp_text_field(1) = 'b') then
1723
        p5 := stim_to_integer(temp_text_field,file_name,line);
1724
      elsif(is_digit(temp_text_field(1)) = true) then
1725
        p5 := stim_to_integer(temp_text_field,file_name,line);
1726
      else  -- else is a variable, get the value or halt incase of error
1727
        access_variable(var_list,temp_text_field,p5,valid);
1728
        assert(valid = 1)
1729
          report LF & "Error: Fifth variable on stimulus line " & (integer'image(line))
1730
                    & " is not valid!!" & LF & "In file " & file_name
1731
        severity failure;
1732
      end if;
1733
    end if;
1734
    -- load parameter six
1735
    temp_text_field  :=  inst_ptr.inst_field_6;
1736
    if(temp_text_field(1) /= nul) then
1737
      -- if this is a numaric field convert to integer
1738
      if(temp_text_field(1) = 'x' or temp_text_field(1) = 'h' or
1739
         temp_text_field(1) = 'b') then
1740
        p6 := stim_to_integer(temp_text_field,file_name,line);
1741
      elsif(is_digit(temp_text_field(1)) = true) then
1742
        p6 := stim_to_integer(temp_text_field,file_name,line);
1743
      else  -- else is a variable, get the value or halt incase of error
1744
        access_variable(var_list,temp_text_field,p6,valid);
1745
        assert(valid = 1)
1746
          report LF & "Error: Sixth variable on stimulus line " & (integer'image(line))
1747
                    & " is not valid!!" & LF & "In file " & file_name
1748
        severity failure;
1749
      end if;
1750
    end if;
1751
  end access_inst_sequ;
1752
 
1753
-------------------------------------------------------------------------
1754
-- dump inst_sequ
1755
--  This procedure dumps to the simulation window the current instruction
1756
--  sequence.  The whole thing will be dumped, which could be big.
1757
--   ** intended for testbench development debug **
1758 10 sckoarn
--  procedure dump_inst_sequ(variable inst_sequ  :  in  stim_line_ptr) is
1759
--    variable v_sequ  :  stim_line_ptr;
1760
--  begin
1761
--    v_sequ  :=  inst_sequ;
1762
--    while(v_sequ.next_rec /= null) loop
1763
--      print("-----------------------------------------------------------------");
1764
--      print("Instruction is " & v_sequ.instruction &
1765
--      "     Par1: "   & v_sequ.inst_field_1 &
1766
--      "     Par2: "   & v_sequ.inst_field_2 &
1767
--      "     Par3: "   & v_sequ.inst_field_3 &
1768
--      "     Par4: "   & v_sequ.inst_field_4);
1769
--      print("Line Number: " & to_str(v_sequ.line_number) & "     File Line Number: " & to_str(v_sequ.file_line) &
1770
--      "     File Name: " & v_sequ.file_name);
1771
--      
1772
--      v_sequ  :=  v_sequ.next_rec;
1773
--    end loop;
1774
--    -- get the last one
1775
--    print("-----------------------------------------------------------------");
1776
--    print("Instruction is " & v_sequ.instruction & "     Par1: "   & v_sequ.inst_field_1 &
1777
--    "     Par2: "   & v_sequ.inst_field_2 & "     Par3: "   & v_sequ.inst_field_3 &
1778
--    "     Par4: "   & v_sequ.inst_field_4);
1779
--    print("Line Number: " & to_str(v_sequ.line_number) & "     File Line Number: " & to_str(v_sequ.file_line) &
1780
--    "     File Name: " & v_sequ.file_name);
1781
--  end dump_inst_sequ;
1782 2 sckoarn
 
1783
-------------------------------------------------------------------------------
1784
-- Procedure to print messages to stdout
1785
  procedure print(s: in string) is
1786
    variable l: line;
1787
  begin
1788
    write(l, s);
1789
    writeline(output,l);
1790
  end print;
1791
 
1792
-------------------------------------------------------------------------------
1793
--  procedure to print to the stdout the txt pointer
1794
  procedure txt_print(variable ptr: in stm_text_ptr) is
1795
    variable txt_str      : stm_text;
1796
  begin
1797
 
1798
    if (ptr /= null) then
1799
      txt_str := (others => nul);
1800 10 sckoarn
      for i in 1 to c_stm_text_len loop
1801 2 sckoarn
        if (ptr(i) = nul) then
1802
          exit;
1803
        end if;
1804
        txt_str(i) := ptr(i);
1805
      end loop;
1806
      print(txt_str);
1807
    end if;
1808
  end txt_print;
1809
 
1810
-------------------------------------------------------------------------------
1811
--  procedure to print to the stdout the txt pointer, and
1812
--     sub any variables found
1813
  procedure txt_print_wvar(variable var_list : in var_field_ptr;
1814
                           variable ptr      : in stm_text_ptr;
1815
                           constant b        : in base) is
1816
 
1817
    variable i:          integer;
1818
    variable j:          integer;
1819
    variable k:          integer;
1820
    variable txt_str:    stm_text;
1821
    variable tmp_str:    stm_text;
1822
    variable v1:         integer;
1823
    variable valid:      integer;
1824
    variable tmp_field:  text_field;
1825
    variable tmp_i:      integer;
1826
 
1827
  begin
1828
    if(ptr /= null) then
1829
      i := 1;
1830
      j := 1;
1831
      txt_str := (others => nul);
1832 10 sckoarn
      while(i <= c_stm_text_len and j <= c_stm_text_len) loop
1833 2 sckoarn
        if(ptr(i) /= '$') then
1834
          txt_str(j) := ptr(i);
1835
          i := i + 1;
1836
          j := j + 1;
1837
        else
1838
          tmp_field := (others => nul);
1839
          tmp_i := 1;
1840
          tmp_field(tmp_i) := ptr(i);
1841
          i := i + 1;
1842
          tmp_i := tmp_i + 1;
1843
          -- parse to the next space
1844
          while(ptr(i) /= ' ' and ptr(i) /= nul) loop
1845
            tmp_field(tmp_i) := ptr(i);
1846
            i := i + 1;
1847
            tmp_i := tmp_i + 1;
1848
          end loop;
1849
          access_variable(var_list,tmp_field,v1,valid);
1850
          assert(valid = 1)
1851
            report LF & "Invalid Variable found in stm_text_ptr: ignoring."
1852
          severity warning;
1853
 
1854
          if(valid = 1) then
1855
 
1856
            txt_str :=  ew_str_cat(txt_str, ew_to_str(v1, b));
1857
            k := 1;
1858
            while(txt_str(k) /= nul) loop
1859
              k := k + 1;
1860
            end loop;
1861
            j := k;
1862
          end if;
1863
        end if;
1864
      end loop;
1865
      -- print the created string
1866
      print(txt_str);
1867
    end if;
1868
  end txt_print_wvar;
1869
 
1870
end tb_pkg;
1871
 

powered by: WebSVN 2.1.0

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