AHB_SRAM UVM验证(4)完善驱动driver以及sequence - 建立基本测试(makefile)

完善driver

在上一节以及完成了transaction,本节完善lvc的组件driver

  • 完善driver中的run_phase
  • get_and_driver的task是接收item并驱动到dut的一个过程,在lvc_ahb_driver中加入,细节driver_transfer的驱动函数的在子类master_driver中加入。
`ifndef LVC_AHB_DRIVER_SV
`define LVC_AHB_DRIVER_SV
 
class lvc_ahb_driver #(type REQ = lvc_ahb_transaction, type RSP = REQ) extends uvm_driver #(REQ, RSP);
  `uvm_component_utils(lvc_ahb_driver)
 
  function new(string name = "lvc_ahb_driver", uvm_component parent = null);
    super.new(name, parent);
  endfunction
 
  function void build_phase(uvm_phase phase);
    super.build_phase(phase);
  endfunction
 
  function void connect_phase(uvm_phase phase);
    super.connect_phase(phase);
  endfunction
 
  task run_phase(uvm_phase phase);
    super.run_phase(phase);
	fork
		get_and_drive();
		reset_listener();
	join_none
  endtask

  virtual task get_and_drive();
  	forever begin
		seq_item_port.get_next_item(req);
		`uvm_info(get_type_name(),"sequnecer got next item",UVM_HIGH)
		drive_transfer(req);
		void'($cast(rsp,req.clone()));
		rsp.set_sequence_id(req.get_sequence_id());
		rsp.set_transaction_id(req.get_transaction_id());
		seq_item_port.item_done(rsp);
		`uvm_info(get_type_name(),"sequencer item_done_triggered",UVM_HIGH)
	end
  endtask : get_and_drive

  virtual task drive_transfer(REQ t);
  endtask

  virtual task reset_listener();
  endtask
 
endclass
 
 
`endif // LVC_AHB_DRIVER_SV

  • 子类的master_driver中添加具体的驱动细节。方便验证,将传输的方式限制为SINGLE,所以在case(t.burst_type)的时候,只有SINGLE一种。首先判断driver的是读还是写,跳转到不同的驱动函数中。
// child driver parant_driver get_and dirve's driver_transfer
`ifndef LVC_AHB_MASTER_DRIVER_SV
`define LVC_AHB_MASTER_DRIVER_SV

class lvc_ahb_master_driver extends lvc_ahb_driver;

	lvc_ahb_agent_configuration cfg;
	virtual lvc_ahb_if vif;
	`uvm_component_utils(lvc_ahb_master_driver)

	function new(string name = "lvc_ahb_master_driver", uvm_component parent = null);
		super.new(name,parent);
	endfunction

	function void build_phase(uvm_phase phase);
		super.build_phase(phase);
	endfunction

	function void connect_phase(uvm_phase phase);
		super.connect_phase(phase);
	endfunction

	task run_phase(uvm_phase phase);
		super.run_phase(phase);
	endtask

	virtual task drive_transfer(REQ t);
		// TODO implementation child class
		case(t.burst_type)
			SINGLE : begin do_atomic_trans(t); end
			INCR   : begin `uvm_error("TYPEERR", "burst type not supported yet") end
			WRAP4  : begin `uvm_error("TYPEERR", "burst type not supported yet") end
			INCR4  : begin `uvm_error("TYPEERR", "burst type not supported yet") end
			WRAP8  : begin `uvm_error("TYPEERR", "burst type not supported yet") end
			INCR8  : begin `uvm_error("TYPEERR", "burst type not supported yet") end
			WRAP16 : begin `uvm_error("TYPEERR", "burst type not supported yet") end
			INCR16 : begin `uvm_error("TYPEERR", "burst type not supported yet") end
			default: begin `uvm_error("TYPEERR", "burst type not defined") end		
		endcase
	endtask

	virtual task do_atomic_trans(REQ t);
		case(t.xact_type)
			READ   : do_read(t);
			WRITE  : do_write(t);
			IDLE_XACT : begin `uvm_error("TYPEERR", "trans type not supported yet") end
 			default: begin `uvm_error("TYPEERR", "trans type not defined") end	
		endcase
	endtask

	virtual task wait_for_bus_grant();
		@(vif.cb_mst iff vif.cb_mst.hgrant == 1'b1);</
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值