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

Subversion Repositories uart2bus_testbench

[/] [uart2bus_testbench/] [trunk/] [tb/] [uvm_src/] [dpi/] [uvm_regex.svh] - Blame information for rev 16

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 16 HanySalah
//----------------------------------------------------------------------
2
//   Copyright 2010-2011 Mentor Graphics Corporation
3
//   All Rights Reserved Worldwide
4
//
5
//   Licensed under the Apache License, Version 2.0 (the
6
//   "License"); you may not use this file except in
7
//   compliance with the License.  You may obtain a copy of
8
//   the License at
9
//
10
//       http://www.apache.org/licenses/LICENSE-2.0
11
//
12
//   Unless required by applicable law or agreed to in
13
//   writing, software distributed under the License is
14
//   distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
15
//   CONDITIONS OF ANY KIND, either express or implied.  See
16
//   the License for the specific language governing
17
//   permissions and limitations under the License.
18
//----------------------------------------------------------------------
19
 
20
 
21
 
22
`ifndef UVM_REGEX_NO_DPI
23
import "DPI-C" context function int uvm_re_match(string re, string str);
24
import "DPI-C" context function void uvm_dump_re_cache();
25
import "DPI-C" context function string uvm_glob_to_re(string glob);
26
 
27
`else
28
 
29
// The Verilog only version does not match regular expressions,
30
// it only does glob style matching.
31
function int uvm_re_match(string re, string str);
32
  int e, es, s, ss;
33
  string tmp;
34
  e  = 0; s  = 0;
35
  es = 0; ss = 0;
36
 
37
  if(re.len() == 0)
38
    return 0;
39
 
40
  // The ^ used to be used to remove the implicit wildcard, but now we don't
41
  // use implicit wildcard so this character is just stripped.
42
  if(re[0] == "^")
43
    re = re.substr(1, re.len()-1);
44
 
45
  //This loop is only needed when the first character of the re may not
46
  //be a *.
47
  while (s != str.len() && re.getc(e) != "*") begin
48
    if ((re.getc(e) != str.getc(s)) && (re.getc(e) != "?"))
49
      return 1;
50
    e++; s++;
51
  end
52
 
53
  while (s != str.len()) begin
54
    if (re.getc(e) == "*") begin
55
      e++;
56
      if (e == re.len()) begin
57
        return 0;
58
      end
59
      es = e;
60
      ss = s+1;
61
    end
62
    else if (re.getc(e) == str.getc(s) || re.getc(e) == "?") begin
63
      e++;
64
      s++;
65
    end
66
    else begin
67
      e = es;
68
      s = ss++;
69
    end
70
  end
71
  while (e < re.len() && re.getc(e) == "*")
72
    e++;
73
  if(e == re.len()) begin
74
    return 0;
75
  end
76
  else begin
77
    return 1;
78
  end
79
endfunction
80
 
81
function void uvm_dump_re_cache();
82
endfunction
83
 
84
function string uvm_glob_to_re(string glob);
85
  return glob;
86
endfunction
87
 
88
`endif

powered by: WebSVN 2.1.0

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