数字IC验证23906--同步元件barrier

文章目录

uvm__barrier介绍

  • 在SV模块中,多个线程的同步除了可以通过semaphore和mailbox来进行,也可以通过fork-join的结构控制语句块来控制整体的运行节奏。
  • 然而对于UVM环境中的多个独立组件,SV的这些方法都受到了作用域的局限。. UVM提供了一个新的类uvm_barrier来对
    多个组件进行同步协调,同时为了解决组件独立运作的封闭性需要,也定义了新的类uvm_barrier pool来全局管理这uvm_barrier对象。
  • uvm_barrier_pool同之前的uvm_event _pool—样,也是基于通用参数类uvm_object_string pool来定义的。
    typedef uvm_object_string_pool #(uvm_barrier) uvm_barrier_pool;
    typedef uvm_object_string _pool # (uvm_event# (uvm_object)) uvm_event _pool;
  • uvm_barrier可以设置一定的等待阈值(threshold),当有不少于该阈值的进程在等待该对象时,才会触发该事件,同时激活所有正在等待的进程,使其可以继续进行。
class env1 extends uvm_env;
	compl c1;
	comp2 c2;
	uvm_barrier b1;
	'uvm_component_utils (env1)...
	function void build_phase (uvm_phase phase) ;
		super.build_phase(phase);
		c1 = compl : :type_id: :create ( "c1", this );
		c2 = comp2: :type_id: :create ( "c2", this ) ;
		b1 = uvm_barrier_pool : : get_global ( "bl");
	endfunction: build_phase
	task run_phase (uvm_phase phase) ;
		b1.set_threshold (3) ;
		'uvm_info ("BSYNC",$sformatf ("env set bl threshold %d at %0t ps", bl.get_threshold ( ) , $time), UVM_LOW)
		#50ns;
		b1.set_threshold (2) ; //当有2个目标正在等待的时候,触发
		'uvm_info("BSYNC",$sformatf ("env set b1 threshold %d at $0t ps", b1.get_threshold ( ) , $time) , UVM_LOW)
	endtask
endclass
class comp1 extends uvm_component;
	uvm_barrier b1;
	`uvm_component_utils (comp1)...
	function void build_phase (uvm_phase phase) ;
		super.build_phase (phase) ;
		b1 = uvm_barrier_pool: :get_global ( "b1" );
	endfunction
	task run_phase (uvm_phase phase) ;#10ns;
		'uvm_info("BSYNC",$sformatf ( "cl wait for b1 at %0t ps", $time),UVM_LOW)
		b1.wait_for ( );
		'uvm_info ("BSYNC",$sformatf("cl is activated at %0t ps" ,$time),UVM_LOW)
	endtask
endclass
class comp2 extends uvm_component;
	uvm_barrier b1;
	`uvm_component_utils (comp2)
	...
	function void build_phase (uvm_phase phase) ;
		super.build_phase(phase);
		b1 = uvm_barrier_pool: :get_global ( "b1") ;
	endfunction
	task run_phase (uvm_phase phase) ;
		#20ns;
		'uvm_info("BSYNC",$sformatf ("c2 wait for b1 at 80t ps" , $time),UVM_LOW)
		b1.wait_for () ;
		'uvm_info("BSYNC",$sformatf("c2 is activated at $0t ps", $time),UVM_LOW)
	endtask
endclass



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值