在UVM 环境中测试完成后从Mem中保存数据到文件tasksave_mem_data()string file_namedata.mem;bit[31:0]addr32h001;// addr width 32bit[31:0]addr_l;integer num_blocks6;bit[511:0]data[];//salve data width is 512int file;bit[7:0]byte_d;string line_s;string line_s_1;int k0;// use for data order formatdatanew[num_blocks];file$fopen(filename,w);if(file0)begin uvm_error(FILE_OPEN_ERR,$sformatf(body , Could not open file %s,filename))endfor(int i0;inum_blocks;i)begin addr_laddri*32h40;data[i]salve_agent.axi_slave_mem.read(addr_l);line_s;// chage the addr order from left to rightfor(int j0;j64;j)begin byte_ddata[i][j*8:8];line_s$sformatf(%s%h,line_s,byte_d);end// two line to oneif(k1)begin line_s_1$sformatf(%s%s,line_s_1,line_s);$fdisplay(file,%s,line_s_1);line_s_1;k0;endelsebegin k1;line_s_1$sformatf(%s%s,line_s_1,line_s);end end $fclose(file);endtask在上述接口中使用到了salve_agent.axi_slave_mem的read接口这里如果要获取salve_agent这个对象可以按照下面方式进行uvm_pkg::uvm_root rootuvm_pkg::uvm_root::get();uvm_pkg::uvm_component comproot.find(*env.axi_system_env.slave[0]);//根据dut接口中进行配置这里0是获取slave0assert($cast(salve_agent,comp));这里有几点需要注意1.地址位宽2.数据位宽3.输出数据的格式要求可以根据需求进行调整4.salve_agent.axi_slave_mem的read这里是关键如何获取接口在那个comp中获取。5.示例中有一个 two line to one的操作这里可以根据需要调整这里的调整需要根据data width来进行