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

Subversion Repositories uart2bus_testbench

[/] [uart2bus_testbench/] [trunk/] [tb/] [uvm_src/] [base/] [uvm_topdown_phase.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-2010 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
//------------------------------------------------------------------------------
24
//
25
// Class: uvm_topdown_phase
26
//
27
//------------------------------------------------------------------------------
28
// Virtual base class for function phases that operate top-down.
29
// The pure virtual function execute() is called for each component.
30
//
31
// A top-down function phase completes when the  method
32
// has been called and returned on all applicable components
33
// in the hierarchy.
34
 
35
virtual class uvm_topdown_phase extends uvm_phase;
36
 
37
 
38
  // Function: new
39
  //
40
  // Create a new instance of a top-down phase
41
  //
42
  function new(string name);
43
    super.new(name,UVM_PHASE_IMP);
44
  endfunction
45
 
46
 
47
  // Function: traverse
48
  //
49
  // Traverses the component tree in top-down order, calling  for
50
  // each component.
51
  //
52
  virtual function void traverse(uvm_component comp,
53
                                 uvm_phase phase,
54
                                 uvm_phase_state state);
55
    string name;
56
    uvm_domain phase_domain = phase.get_domain();
57
    uvm_domain comp_domain = comp.get_domain();
58
 
59
    if (m_phase_trace)
60
    `uvm_info("PH_TRACE",$sformatf("topdown-phase phase=%s state=%s comp=%s comp.domain=%s phase.domain=%s",
61
          phase.get_name(), state.name(), comp.get_full_name(),comp_domain.get_name(),phase_domain.get_name()),
62
          UVM_DEBUG)
63
 
64
    if (phase_domain == uvm_domain::get_common_domain() ||
65
        phase_domain == comp_domain) begin
66
        case (state)
67
          UVM_PHASE_STARTED: begin
68
            comp.m_current_phase = phase;
69
            comp.m_apply_verbosity_settings(phase);
70
            comp.phase_started(phase);
71
            end
72
          UVM_PHASE_EXECUTING: begin
73
            if (!(phase.get_name() == "build" && comp.m_build_done)) begin
74
              uvm_phase ph = this;
75
              comp.m_phasing_active++;
76
              if (comp.m_phase_imps.exists(this))
77
                ph = comp.m_phase_imps[this];
78
              ph.execute(comp, phase);
79
              comp.m_phasing_active--;
80
            end
81
            end
82
          UVM_PHASE_READY_TO_END: begin
83
            comp.phase_ready_to_end(phase);
84
            end
85
          UVM_PHASE_ENDED: begin
86
            comp.phase_ended(phase);
87
            comp.m_current_phase = null;
88
            end
89
          default:
90
            `uvm_fatal("PH_BADEXEC","topdown phase traverse internal error")
91
        endcase
92
    end
93
    if(comp.get_first_child(name))
94
      do
95
        traverse(comp.get_child(name), phase, state);
96
      while(comp.get_next_child(name));
97
  endfunction
98
 
99
 
100
  // Function: execute
101
  //
102
  // Executes the top-down phase ~phase~ for the component ~comp~.
103
  //
104
  virtual function void execute(uvm_component comp,
105
                                          uvm_phase phase);
106
    // reseed this process for random stability
107
    process proc = process::self();
108
    proc.srandom(uvm_create_random_seed(phase.get_type_name(), comp.get_full_name()));
109
 
110
    comp.m_current_phase = phase;
111
    exec_func(comp,phase);
112
  endfunction
113
 
114
endclass

powered by: WebSVN 2.1.0

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