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

Subversion Repositories uart2bus_testbench

[/] [uart2bus_testbench/] [trunk/] [tb/] [uvm_src/] [comps/] [uvm_algorithmic_comparator.svh] - Blame information for rev 16

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 16 HanySalah
//
2
//------------------------------------------------------------------------------
3
//   Copyright 2007-2011 Mentor Graphics Corporation
4
//   Copyright 2007-2011 Cadence Design Systems, Inc.
5
//   Copyright 2010 Synopsys, Inc.
6
//   All Rights Reserved Worldwide
7
//
8
//   Licensed under the Apache License, Version 2.0 (the
9
//   "License"); you may not use this file except in
10
//   compliance with the License.  You may obtain a copy of
11
//   the License at
12
//
13
//       http://www.apache.org/licenses/LICENSE-2.0
14
//
15
//   Unless required by applicable law or agreed to in
16
//   writing, software distributed under the License is
17
//   distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
18
//   CONDITIONS OF ANY KIND, either express or implied.  See
19
//   the License for the specific language governing
20
//   permissions and limitations under the License.
21
//------------------------------------------------------------------------------
22
 
23
// File: Algorithmic Comparator
24
//
25
// A common function of testbenches is to compare streams of transactions for
26
// equivalence. For example, a testbench may compare a stream of transactions
27
// from a DUT with expected results.
28
//
29
// The UVM library provides a base class called
30
//  and two
31
// derived classes, which are  for comparing
32
// streams of built-in types and  for comparing
33
// streams of class objects.
34
//
35
// The uvm_algorithmic_comparator also compares two streams of transactions;
36
// however, the transaction streams might be of different type objects. This
37
// device will use a user-written transformation function to convert one type
38
// to another before performing a comparison.
39
 
40
 
41
//------------------------------------------------------------------------------
42
//
43
// CLASS: uvm_algorithmic_comparator #(BEFORE,AFTER,TRANSFORMER)
44
//
45
// Compares two streams of data objects of different types, ~BEFORE~ and ~AFTER~.
46
//
47
// The algorithmic comparator is a wrapper around .
48
// Like the in-order comparator, the algorithmic comparator compares two streams
49
// of transactions, the ~BEFORE~ stream and the ~AFTER~ stream. It is often the case
50
// when two streams of transactions need to be compared that the two streams are
51
// in different forms. That is, the type of the ~BEFORE~ transaction stream is
52
// different than the type of the ~AFTER~ transaction stream.
53
//
54
// The uvm_algorithmic_comparator's ~TRANSFORMER~ type parameter specifies the
55
// class responsible for converting transactions of type ~BEFORE~ into those of
56
// type ~AFTER~. This transformer class must provide a transform() method with the
57
// following prototype:
58
//
59
//|    function AFTER transform (BEFORE b);
60
//
61
// Matches and mismatches are reported in terms of the ~AFTER~ transactions.
62
// For more information, see the
63
//  class.
64
//
65
//------------------------------------------------------------------------------
66
 
67
 
68
class uvm_algorithmic_comparator #( type BEFORE=int,
69
                                    type AFTER=int,
70
                                    type TRANSFORMER=int) extends uvm_component;
71
 
72
  const static string type_name = "uvm_algorithmic_comparator #(BEFORE,AFTER,TRANSFORMER)";
73
 
74
  typedef uvm_algorithmic_comparator #( BEFORE ,
75
                                        AFTER ,
76
                                        TRANSFORMER ) this_type;
77
 
78
  `uvm_component_param_utils(this_type)
79
 
80
 
81
  // Port: before_export
82
  //
83
  // The export to which a data stream of type BEFORE is sent via a connected
84
  // analysis port. Publishers (monitors) can send in an ordered stream of
85
  // transactions against which the transformed BEFORE transactions will
86
  // (be compared.
87
 
88
  uvm_analysis_imp #(BEFORE, this_type) before_export;
89
 
90
 
91
  // Port: after_export
92
  //
93
  // The export to which a data stream of type AFTER is sent via a connected
94
  // analysis port. Publishers (monitors) can send in an ordered stream of
95
  // transactions to be transformed and compared to the AFTER transactions.
96
 
97
  uvm_analysis_export #(AFTER) after_export;
98
 
99
 
100
  local uvm_in_order_class_comparator #(AFTER) comp;
101
  local TRANSFORMER m_transformer;
102
 
103
  // Function: new
104
  //
105
  // Creates an instance of a specialization of this class.
106
  // In addition to the standard uvm_component constructor arguments, ~name~
107
  // and ~parent~, the constructor takes a handle to a ~transformer~ object,
108
  // which must already be allocated (handles can't be ~null~) and must implement
109
  // the transform() method.
110
 
111
 function new(string name, uvm_component parent=null, TRANSFORMER transformer=null);
112
 
113
    super.new( name , parent );
114
 
115
    m_transformer = transformer;
116
    comp = new("comp", this );
117
 
118
    before_export = new("before_analysis_export" , this );
119
    after_export = new("after_analysis_export" , this );
120
  endfunction
121
 
122
  virtual function string get_type_name();
123
    return type_name;
124
  endfunction
125
 
126
  virtual function void connect_phase(uvm_phase phase);
127
    after_export.connect( comp.after_export );
128
  endfunction
129
 
130
  function void write( input BEFORE b );
131
    comp.before_export.write( m_transformer.transform( b ) );
132
  endfunction
133
 
134
endclass

powered by: WebSVN 2.1.0

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