在使用UVM寄存器模型的时候,当整个模型建立完成以后,必须在root block中调用lock_model,这样整个模型才算建立完整,那么为什么要这么做呢,因为我们在建立模型的时候所有寄存器的地址均是相对地址,在进行前门访问,是以绝对地址进行的,因此lock_model帮助我们得到所有寄存器的绝对地址。忘记加了会显示报错
class ahbram_rgm extends uvm_reg_block;
`uvm_object_utils(rkv_ahbram_rgm)
uvm_reg_map map;
function new(string name = "ahbram_rgm ");
super.new(name, UVM_NO_COVERAGE);
endfunction
virtual function build();
map = create_map("map", 'h0, 4, UVM_LITTLE_ENDIAN);
lock_model();
endfunction
endclass
uvm_reg_block可以用来存储多喝寄存器、存储器和寄存器列表的
new:
function uvm_reg_block::new(string name="", int has_coverage=UVM_NO_COVERAGE);
super.new(name);
hdl_paths_pool = new("hdl_paths");
this.has_cover = has_coverage;
// Root block until registered with a parent
m_roots[this] = 0;
endfunction: new
create_map:
function uvm_reg_map uvm_reg_block::create_map(string name,
uvm_reg_addr_t base_addr,
int unsigned n_bytes,
uvm_endianness_e endian,
bit byte_addressing=1);
lock_model(); 模型一旦建立,不允许除了与硬件之间的交互之外的其他访问
map.add_reg方法存放的是reg的相关信息(尤其是addr信息,但是这个地址是reg相对于map的地址,也叫做reg的相对地址),如何获得reg的绝对地址
create_map("map1",'h10,2,UVM_LITTLE_ENDIAN);
map1.add_reg(reg1, 32'h20, "WR");
这个时候’h10是reg的相对地址,32’h20是map地址。
reg的绝对地址就是32’h20+32’h10
但是如果牵扯到hier的结构,也就是map2.add_submap(map1,32’h10);
并且map2是root map,地址时候0:
那么此时map1的绝对地址是32’h0+32’h10+32’h20+32’h10