今天我们继续修改之前的例子,你会有意想不到的收获。程序源代码,和上一节文章一样。
症状3:
这里,我们没有显式调用类的randomize() 函数,而是定义了一个类函数。在函数中 ,重新约束了类内的随机变量。请看如下代码:
`timescale 1ns/1ps
`include "uvm_macros.svh"
import uvm_pkg::*;
class my_obj1 extends uvm_test;
`uvm_component_utils(my_obj1)
rand int src=4;
rand int dst;
constraint dst_c {
dst inside {[7:9]};
}
rand bit [3:0] crc = 4'b0111;
constraint crc_c {
crc inside {5,6,7,8};
}
function new(string name = "my_obj1" , uvm_component parent = null );
super.new(name, parent);
endfunction // new
extern virtual function print ();
extern virtual function pure_print ();
virtual task run_phase(uvm_phas