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 17

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

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

powered by: WebSVN 2.1.0

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