标签:star task extern extends sse creat and 参考 pos
在运用uvm做实际项目的时候,因为针对RTL提出不同的需求进行不同的测试方案,很大一部分就是在激励的产生上,
有限制条件的激励相比漫无目的的仿真更加有效的找出RTL的bug。因此,同一份测试方案,不同的sequence往往代表着
不同的test_case。
第一,在这么多不同的case下,我们可以设置一个base_case,base_case将环境env,cfg等一些东西包进去;
第二,需要几个不同的sequence就写几个sequence,sequence之间没有联系,继承于uvm_sequence;
第三,在每个具体的执行case下,可以用asserte插入具体的配置参数,并且每个case设置自己独立的default_sequence;
第四,在终端指定不同的case_name跑不同的case;
下面给出具体的参考代码...
首先给出sequence的代码,注意不同的sequence只有具体内容不一样而已
1 class xx_sequence extends uvm_sequence #(xx_trans); 2 3 //define send trans and temp trans ,define cfg 4 xx_trans m_xx_trans; 5 xx_trans tmp_xx_trans; 6 xx_cfg m_xx_cfg; 7 //function & task 8 extern function new(string name = "xx_sequence"); 9 extern virtual task pre_body(); 10 extern virtual task body(); 11 extern virtual task post_body(); 12 13 extern task get_trans(); 14 extern task send_trans(); 15 16 `uvm_object_utils(xx_sequence) 17 endclass 18 19 function xx_trans::new 20 . 21 . 22 . 23 endfunction 24 25 task xx_trans::pre_body(); 26 m_xx_trans = new(); 27 xx_trans_tmp = new(); 28 //get cfg 29 uvm_config_db#(xx_cfg)::get(null,"full_path","xx_cfg",xx_cfg); 30 starting_phase.raise_objection(this); 31 endtask 32 33 task xx_trans::body(); 34 send_trans(); 35 endtask 36 37 task xx_trans::post_body(); 38 starting_phase.raise_objection(this); 39 endtask
下面给出base_test
1 class base_test extends uvm_test; 2 env m_env; 3 xx_cfg m_xx_cfg; 4 5 extern function new(string name,uvm component parent); 6 extern virtual function void build_phase(uvm_phase phase); 7 extern virtual function void set_cfg(); 8 9 `uvm_component_utils(base_test) 10 endclass 11 12 function base_test::new(string name,uvm component parent); 13 . 14 . 15 endfunction 16 17 function void base_test::build_phase(uvm_phase phase); 18 super.build_phase(phase); 19 m_env = env::type_id::create("m_env",this); 20 m_xx_cfg = ...; 21 set_cfg(); 22 //send config 23 uvm_config_db#(xx_cfg)::set(uvm_root::get(),"*","m_xx_cfg",m_xx_cfg); 24 endfunction
下面给出某一个具体的case
class xx_case extends base_test; xx_sequence m_xx_sequence; extern function new(string name ="xx_case",uvm_component parent); extern virtual function void build_phase(uvm_phase phase); extern function void set_cfg(); `uvm_component_utils(xx_case) endclass function xx_case::new ... . . endfunction function xx_case::build_phase(uvm_phase phase); super.build_phase(phase); m_xx_sequence = new("m_xx_sequence"); //set default sequence uvm_config_db#(uvm_object_wrapper)::set(null,"$full_path",xx_sequence::type_id::get()); endfunction function xx_case::xx_cfg(); ... endfunction
标签:star task extern extends sse creat and 参考 pos
原文地址:https://www.cnblogs.com/rongmouzhang/p/9488559.html