|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
各位:
我回来折腾UVM了。现在我的DUT是一个带apb接口的ram,该ram宽32bit,深1024。我想使用uvm_reg对DUT进行仿真。首先是写ralf文件,然后再用vcs提供的工具来生成uvm_reg_block的相关代码。
ralf文件内容如下:
- memory MY_RAM {
- size 1k;
- bits 32;
- access rw;
- }
- block apb_basic_block {
- bytes 4;
- memory MY_RAM @32'h0000_0000;
- }
- system apb_basic_slave {
- bytes 4;
- block apb_basic_block=slave_block;
- }
复制代码 而vcs生成的uvm_reg_block的相关代码如下:
- `ifndef RAL_APB_BASIC_SLAVE
- `define RAL_APB_BASIC_SLAVE
- import uvm_pkg::*;
- class ral_mem_MY_RAM extends uvm_mem;
- function new(string name ="MY_RAM");
- super.new(name,`UVM_REG_ADDR_WIDTH'h400,32,"RW",build_coverage(UVM_NO_COVERAGE));
- endfunction
- virtual function void build();
- end function :build
- `uvm_component_utils(ral_mem_MY_RAM)
- endclass
- class ral_block_apb_basic_block extends uvm_reg_block;
- rand ral_mem_MY_RAM MY_RAM;
- function new (string name ="apb_basic_block");
- super.new(name,build_coverage(UVM_NO_COVERAGE));
- endfunction
- virtual function void build();
- this.default_map=create_map("",0,4,UVM_LITTLE_ENDIAN);
- this.MY_RAM=ral_mem_MY_RAM::type_id::create("MY_RAM");
- this.MY_RAM.build();
- this.MY_RAM.configure(this,"");
- this.default_map.add_mem(this.MY_RAM,`UVM_REG_ADDR_WIDTH'h0,"RW",0);
- endfunction : build
- `uvm_object_utils(ral_block_apb_basic_block)
- endclass : ral_block_apb_basic_block
- class ral_sys_apb_basic_slave extends uvm_reg_block;
- rand ral_block_apb_basic_block slave_block;
- function new(string name="apb_basic_slave");
- super.new(name);
- endfunction
- function build();
- this.default_map=create_map("",0,4,UVM_LITTLE_ENDIAN);
- this.slave_block=ral_block_apb_basic_block::type_id::create("slave_block");
- this.slave_block.configure(this,"");
- this.slave_block.build();
- this.default_map.add_submap(this.slave_block.default_map,`uvm_REG_ADDR_WIDTH'h0);
- endfunction : build
- `uvm_component_utils(ral_sys_apb_basic_slave)
- endclass : ral_sys_apb_basic_slave
- `endif
复制代码 然后,建立一个environment来与apb_env放一块,这块是自己写的,代码如下:
- `ifndef REG_TB
- `define REG_TB
- `include "demo_cfg.sv"
- `include "reg_seq.sv"
- `include "ral_sys_apb_basic_slave.sv"
- class reg_tb extends uvm_env;
- `uvm_component_utils(reg_tb)
- apb_env apb0;
- demo_config demo_cfg;
- ral_sys_apb_basic_slave regmodel;
- reg_to_apb_adapter reg_sqr_adapter;
- reg_to_apb_adapter mon_reg_adapter;
- uvm_reg_prediector#(apb_transfer) reg_predictor;
- function new(string name,uvm_component parent);
- super.new(name,parent);
- endfunction
- virtual function build_phase(uvm_phase phase);
- super.build_phase(phase);
- demo_cfg=demo_config::type_id::create("demo_cfg");
- uvm_config_object::set(this,"apb0*","cfg",demo_cfg);
- uvm_config_object::set(this,"apb0.slave[0]*","cfg",demo_cfg.slave_configs[0]);
- apb0=apb_env::type_id::create("apb0");
- //for reg model
- regmodel=ral_sys_apb_basic_slave::type_id::create("regmodel");
- regmodel.configure(null,"top.u_dut");
- regmodel.build();
- regmodel.lock();
- regmodel.reset();
- reg_sqr_adapter=reg_to_apb_adapter::type_id::create("reg_sqr_adapter",,get_full_name());
- mon_reg_adapter=reg_to_apb_adapter::type_id::create("mon_reg_adapter",,get_full_name());
- reg_predictor=new("reg_predictor",this);
- endfunction : build_phase
- function void connect_phase(uvm_phase phase);
- regmodel.define_map.set_sequencer(apb0.master.sequencer,reg_sqr_adapter);
- regmodel.define_map.set_auto_predict(1);
- reg_predictor.map=regmodel.define_map;
- reg_predictor.adapter=mon_reg_adapter;
- apb0.slave.monitor.item_collected_port.connect(reg_predictor.bus_in);
- endfunction:connect_phase
- endclass :reg_tb
- `endif
复制代码 然后到写sequence和test的时候,我就不知道该怎么写了,有谁能指点一下,或者提供一个例子,或者指出上哪儿去找例子呀? |
|