求助:怎么写uvm_reg的sequence与test?
时间:10-02
整理:3721RD
点击:
各位:
我回来折腾UVM了。现在我的DUT是一个带apb接口的ram,该ram宽32bit,深1024。我想使用uvm_reg对DUT进行仿真。首先是写ralf文件,然后再用vcs提供的工具来生成uvm_reg_block的相关代码。
ralf文件内容如下:
我回来折腾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;
- }
- `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
- `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_envapb0;
- demo_configdemo_cfg;
- ral_sys_apb_basic_slaveregmodel;
- reg_to_apb_adapterreg_sqr_adapter;
- reg_to_apb_adaptermon_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
建议别折腾什么RGM的东西,直接用driver和monitor那一套搞就好了,不大一点的RAM,用RGM有点浪费。呵呵。就照着APB的时序写组件就好了。
我目前是用一个最简单的来练手,实际上我们要验的IP是对高清图像处理的,需要存储器的地方又多又大又杂,全从总线上的话太费时间了,想能不能通过RGM的后面直接往存储器里面灌图像数据。
另外,问一下,除了sequence和test,还需要改写一下apb_master_sequencer么?
I have never used UVM_REG. But I think you still need something like REG2APB/APB2REG to mapping your register sequence item to the APB sequence time and verse.
apb_adapter已经写好。准确的说是用了从cadence网站下的ref_flow中的apb环境,里面带有apb_adapter。