uvm_mem提供了mem write和read的方法,在write方法中,有offset形参,这个形参意指访问的location处于连续地址空间中的偏移。在通过uvm_reg_map转换成physical address时,会加上base_addr。
通常访问一段mem,我们会使用连续的地址进行访问,例如mem.write(0, data0) mem.write(1, data1)等,从0遍历到最大地址空间。
例如我例化一个128kb的ram
那么我能访问的地址空间是mem.write(0, data0) mem.write('h7fff, datax)。但是128kb的地址空间,如果按byte算的话是:0-'h1_ffff。这也是总线上能看到的地址范围。
那么如何将0-'h7fff的映射到物理地址0-'h1_ffff上呢?
那么uvm_reg_map中的configure函数,提供了byte_addressing形参。
按上图注释 byte_addressing的作用是将偏移地址乘以4(如果是32位总线)。
在uvm_cookbook中有如下解释:
For example,
if n_bytes=4 and byte_addressing=0, then an access to a register that is 64-bits wide and at offset 0 will result in two bus
accesses at addresses 0 and 1. With byte_addressing=1, that same access will result in two bus accesses at addresses 0 and 4.
那么我们在创建uvm_reg_map时,需要将byte_addressing设置为1(create_map()),这也是uvm1.1后各版本的默认值。但是在uvm1.0中,默认值是0。
注:在vcs仿真器中,如果使用synopsys vcs仿真器内置的uvm-1.2库的话,需要定义+define+如下的宏