| 1 |
16 |
HanySalah |
//------------------------------------------------------------
|
| 2 |
|
|
// Copyright 2007-2010 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 |
|
|
// TITLE: UVM HDL Backdoor Access support routines.
|
| 21 |
|
|
//
|
| 22 |
|
|
// These routines provide an interface to the DPI/PLI
|
| 23 |
|
|
// implementation of backdoor access used by registers.
|
| 24 |
|
|
//
|
| 25 |
|
|
// If you DON'T want to use the DPI HDL API, then compile your
|
| 26 |
|
|
// SystemVerilog code with the vlog switch
|
| 27 |
|
|
//: vlog ... +define+UVM_HDL_NO_DPI ...
|
| 28 |
|
|
//
|
| 29 |
|
|
|
| 30 |
|
|
|
| 31 |
|
|
`ifndef UVM_HDL__SVH
|
| 32 |
|
|
`define UVM_HDL__SVH
|
| 33 |
|
|
|
| 34 |
|
|
|
| 35 |
|
|
`ifndef UVM_HDL_MAX_WIDTH
|
| 36 |
|
|
`define UVM_HDL_MAX_WIDTH 1024
|
| 37 |
|
|
`endif
|
| 38 |
|
|
|
| 39 |
|
|
/*
|
| 40 |
|
|
* VARIABLE: UVM_HDL_MAX_WIDTH
|
| 41 |
|
|
* Sets the maximum size bit vector for backdoor access.
|
| 42 |
|
|
* This parameter will be looked up by the
|
| 43 |
|
|
* DPI-C code using:
|
| 44 |
|
|
* vpi_handle_by_name(
|
| 45 |
|
|
* "uvm_pkg::UVM_HDL_MAX_WIDTH", 0);
|
| 46 |
|
|
*/
|
| 47 |
|
|
parameter int UVM_HDL_MAX_WIDTH = `UVM_HDL_MAX_WIDTH;
|
| 48 |
|
|
|
| 49 |
|
|
|
| 50 |
|
|
typedef logic [UVM_HDL_MAX_WIDTH-1:0] uvm_hdl_data_t;
|
| 51 |
|
|
|
| 52 |
|
|
|
| 53 |
|
|
`ifndef UVM_HDL_NO_DPI
|
| 54 |
|
|
|
| 55 |
|
|
// Function: uvm_hdl_check_path
|
| 56 |
|
|
//
|
| 57 |
|
|
// Checks that the given HDL ~path~ exists. Returns 0 if NOT found, 1 otherwise.
|
| 58 |
|
|
//
|
| 59 |
|
|
import "DPI-C" context function int uvm_hdl_check_path(string path);
|
| 60 |
|
|
|
| 61 |
|
|
|
| 62 |
|
|
// Function: uvm_hdl_deposit
|
| 63 |
|
|
//
|
| 64 |
|
|
// Sets the given HDL ~path~ to the specified ~value~.
|
| 65 |
|
|
// Returns 1 if the call succeeded, 0 otherwise.
|
| 66 |
|
|
//
|
| 67 |
|
|
import "DPI-C" context function int uvm_hdl_deposit(string path, uvm_hdl_data_t value);
|
| 68 |
|
|
|
| 69 |
|
|
|
| 70 |
|
|
// Function: uvm_hdl_force
|
| 71 |
|
|
//
|
| 72 |
|
|
// Forces the ~value~ on the given ~path~. Returns 1 if the call succeeded, 0 otherwise.
|
| 73 |
|
|
//
|
| 74 |
|
|
import "DPI-C" context function int uvm_hdl_force(string path, uvm_hdl_data_t value);
|
| 75 |
|
|
|
| 76 |
|
|
|
| 77 |
|
|
// Function: uvm_hdl_force_time
|
| 78 |
|
|
//
|
| 79 |
|
|
// Forces the ~value~ on the given ~path~ for the specified amount of ~force_time~.
|
| 80 |
|
|
// If ~force_time~ is 0, is called.
|
| 81 |
|
|
// Returns 1 if the call succeeded, 0 otherwise.
|
| 82 |
|
|
//
|
| 83 |
|
|
task uvm_hdl_force_time(string path, uvm_hdl_data_t value, time force_time = 0);
|
| 84 |
|
|
if (force_time == 0) begin
|
| 85 |
|
|
void'(uvm_hdl_deposit(path, value));
|
| 86 |
|
|
return;
|
| 87 |
|
|
end
|
| 88 |
|
|
if (!uvm_hdl_force(path, value))
|
| 89 |
|
|
return;
|
| 90 |
|
|
#force_time;
|
| 91 |
|
|
void'(uvm_hdl_release_and_read(path, value));
|
| 92 |
|
|
endtask
|
| 93 |
|
|
|
| 94 |
|
|
|
| 95 |
|
|
// Function: uvm_hdl_release_and_read
|
| 96 |
|
|
//
|
| 97 |
|
|
// Releases a value previously set with .
|
| 98 |
|
|
// Returns 1 if the call succeeded, 0 otherwise. ~value~ is set to
|
| 99 |
|
|
// the HDL value after the release. For 'reg', the value will still be
|
| 100 |
|
|
// the forced value until it has been procedurally reassigned. For 'wire',
|
| 101 |
|
|
// the value will change immediately to the resolved value of its
|
| 102 |
|
|
// continuous drivers, if any. If none, its value remains as forced until
|
| 103 |
|
|
// the next direct assignment.
|
| 104 |
|
|
//
|
| 105 |
|
|
import "DPI-C" context function int uvm_hdl_release_and_read(string path, inout uvm_hdl_data_t value);
|
| 106 |
|
|
|
| 107 |
|
|
|
| 108 |
|
|
// Function: uvm_hdl_release
|
| 109 |
|
|
//
|
| 110 |
|
|
// Releases a value previously set with .
|
| 111 |
|
|
// Returns 1 if the call succeeded, 0 otherwise.
|
| 112 |
|
|
//
|
| 113 |
|
|
import "DPI-C" context function int uvm_hdl_release(string path);
|
| 114 |
|
|
|
| 115 |
|
|
|
| 116 |
|
|
// Function: uvm_hdl_read()
|
| 117 |
|
|
//
|
| 118 |
|
|
// Gets the value at the given ~path~.
|
| 119 |
|
|
// Returns 1 if the call succeeded, 0 otherwise.
|
| 120 |
|
|
//
|
| 121 |
|
|
import "DPI-C" context function int uvm_hdl_read(string path, output uvm_hdl_data_t value);
|
| 122 |
|
|
|
| 123 |
|
|
`else
|
| 124 |
|
|
|
| 125 |
|
|
function int uvm_hdl_check_path(string path);
|
| 126 |
|
|
uvm_report_fatal("UVM_HDL_CHECK_PATH",
|
| 127 |
|
|
$sformatf("uvm_hdl DPI routines are compiled off. Recompile without +define+UVM_HDL_NO_DPI"));
|
| 128 |
|
|
return 0;
|
| 129 |
|
|
endfunction
|
| 130 |
|
|
|
| 131 |
|
|
function int uvm_hdl_deposit(string path, uvm_hdl_data_t value);
|
| 132 |
|
|
uvm_report_fatal("UVM_HDL_DEPOSIT",
|
| 133 |
|
|
$sformatf("uvm_hdl DPI routines are compiled off. Recompile without +define+UVM_HDL_NO_DPI"));
|
| 134 |
|
|
return 0;
|
| 135 |
|
|
endfunction
|
| 136 |
|
|
|
| 137 |
|
|
function int uvm_hdl_force(string path, uvm_hdl_data_t value);
|
| 138 |
|
|
uvm_report_fatal("UVM_HDL_FORCE",
|
| 139 |
|
|
$sformatf("uvm_hdl DPI routines are compiled off. Recompile without +define+UVM_HDL_NO_DPI"));
|
| 140 |
|
|
return 0;
|
| 141 |
|
|
endfunction
|
| 142 |
|
|
|
| 143 |
|
|
task uvm_hdl_force_time(string path, uvm_hdl_data_t value, time force_time=0);
|
| 144 |
|
|
uvm_report_fatal("UVM_HDL_FORCE_TIME",
|
| 145 |
|
|
$sformatf("uvm_hdl DPI routines are compiled off. Recompile without +define+UVM_HDL_NO_DPI"));
|
| 146 |
|
|
endtask
|
| 147 |
|
|
|
| 148 |
|
|
function int uvm_hdl_release(string path, output uvm_hdl_data_t value);
|
| 149 |
|
|
uvm_report_fatal("UVM_HDL_RELEASE",
|
| 150 |
|
|
$sformatf("uvm_hdl DPI routines are compiled off. Recompile without +define+UVM_HDL_NO_DPI"));
|
| 151 |
|
|
return 0;
|
| 152 |
|
|
endfunction
|
| 153 |
|
|
|
| 154 |
|
|
function int uvm_hdl_read(string path, output uvm_hdl_data_t value);
|
| 155 |
|
|
uvm_report_fatal("UVM_HDL_READ",
|
| 156 |
|
|
$sformatf("uvm_hdl DPI routines are compiled off. Recompile without +define+UVM_HDL_NO_DPI"));
|
| 157 |
|
|
return 0;
|
| 158 |
|
|
endfunction
|
| 159 |
|
|
|
| 160 |
|
|
`endif
|
| 161 |
|
|
|
| 162 |
|
|
|
| 163 |
|
|
`endif
|