2011年6月26日 星期日

UVM Register(九)

一個簡單的uvm_reg_sequence的使用例

class blk_R_test_seq extends uvm_reg_sequence;

`uvm_object_utils(blk_R_test_seq)

function new(string name = "blk_R_test_seq");
super.new(name);
endfunction: new

reg_block_B model; // 設定對那一個uvm_reg_block作讀寫的動作

virtual task body();
uvm_status_e status; // uvm 內定的
uvm_reg_data_t data, rd_data;
int n;

// Initialize R with a random value then check against mirror
data[7:0] = $urandom(); //先亂數得到一個數值

write_reg(model.R, status, data); //將data寫入uvm_reg_block的R這個uvm_reg的變數
read_reg (model.R, status, rd_data); //uvm_reg_block的R這個uvm_reg的變數的值讀出

...


以下是所用的部份在uvm library內的資料

typedef enum {
UVM_IS_OK,
UVM_NOT_OK,
UVM_HAS_X
} uvm_status_e;

// Type: uvm_reg_data_t
//
// 2-state data value with <`UVM_REG_DATA_WIDTH> bits
//
typedef bit unsigned [`UVM_REG_DATA_WIDTH-1:0] uvm_reg_data_t ;


write_reg

virtual task write_reg( input uvm_reg rg,


output uvm_status_e status,


input uvm_reg_data_t value,


input uvm_path_e path = UVM_DEFAULT_PATH,

input uvm_reg_map map = null,

input int prior = -1,

input uvm_object extension = null,

input string fname = "",

input int lineno = 0 )

write_reg(model.regA, status, value); //其它的可不設

=== model.regA.write(status, value, .parent(this));

因為write_reg這個function就是在內部呼叫regA的write(),並填上所需的相關變數


read_reg

virtual task read_reg( input uvm_reg rg,


output uvm_status_e status,


output uvm_reg_data_t value,


input uvm_path_e path = UVM_DEFAULT_PATH,

input uvm_reg_map map = null,

input int prior = -1,

input uvm_object extension = null,

input string fname = "",

input int lineno = 0 )

read_reg(model.regA, status, value);
=== model.regA.read(status, value, .parent(this));

因為read_reg這個function就是在內部呼叫regA的read(),並填上所需的相關變數


許多的uvm_reg_sequence所用到的function都是內部再去呼叫
uvm_req或uvm_mem的function來用,只是經過一層包裝而已


以下是相關的列表
Convenience Write/Read APIThe following methods delegate to the corresponding method in the register or memory element.

write_regWrites the given register rg using uvm_reg::write, supplying ‘this’ as the parent argument.
read_regReads the given register rg using uvm_reg::read, supplying ‘this’ as the parent argument.
poke_regPokes the given register rg using uvm_reg::poke, supplying ‘this’ as the parent argument.
peek_regPeeks the given register rg using uvm_reg::peek, supplying ‘this’ as the parent argument.
update_regUpdates the given register rg using uvm_reg::update, supplying ‘this’ as the parent argument.
mirror_regMirrors the given register rg using uvm_reg::mirror, supplying ‘this’ as the parent argument.
write_memWrites the given memory mem using uvm_mem::write, supplying ‘this’ as the parent argument.
read_memReads the given memory mem using uvm_mem::read, supplying ‘this’ as the parent argument.
poke_memPokes the given memory mem using uvm_mem::poke, supplying ‘this’ as the parent argument.
peek_memPeeks the given memory mem using uvm_mem::peek, supplying ‘this’ as the parent argument.


沒有留言: