其他分享
首页 > 其他分享> > UVM入门与进阶学习笔记15——sequencer和driver

UVM入门与进阶学习笔记15——sequencer和driver

作者:互联网

目录


在这里插入图片描述

端口和方法

事务传输示例

class bus_trans extends uvm_sequence_item;
	rand int data;
	`uvm_object_utils_begin(bus_trans)
		`uvm_field_int(data, UVM_ALL_ON)
	`uvm_object_utils_end
	...
endclass
class flat_seq extends uvm_sequence;
	`uvm_object_utils(flat_seq)
	...
	task body();
		uvm_sequence_item tmp;
		bus_trans req, rsp;
		tmp = create_item(bus_trans::get_type(), m_sequencer, "req");
		void'($cast(req, tmp));
		start_item(req);
		req.randomize with {data == 10;};
		`uvm_info("SEQ", $sformatf("sent a item \n %s", req.sprint()), UVM_LOW)
		finish_item(req);
		get_response(tmp);
		void'($cast(rsp, tmp));
		`uvm_info("SEQ", $sformatf("got a item \n %s", rsp.sprint()), UVM_LOW)
	endtask
endclass
class sequencer extends uvm_sequencer;
	`uvm_component_utils(sequencer)
	...
endclass
class driver extends uvm_driver;
	`uvm_component_utils(driver)
	...
	task run_phase(uvm_phase phase);
		REQ tmp;
		bus_trans req, rsp;
		seq_item_port.get_next_item(tmp);
		void'($cast(req, tmp));
		`uvm_info("DRV", $sformatf("got a item \n %s", rsp.sprint()), UVM_LOW)
		void'($cast(rsp, req.clone()));
		rsp.set_sequence_id(req.get_sequence_id());
		rsp.data += 100;
		seq_item_port.item_done(rsp);
		`uvm_info("DRV", $sformatf("sent a item \n %s", rsp.sprint()), UVM_LOW)
	endtask
endclass
class env extends uvm_env;
	sequencer sqr;
	driver drv;
	`uvm_component_utils(env)
	...
	function void build_phase(uvm_phase phase);
		sqr = sequencer::type_id::create("sqr", this);
		drv = driver::type_id::create("drv", this);
	endfunction
	function void connect_phase(uvm_phase phase);
		drv.seq_item_port.connect(sqr.seq_item_export);
	endfunction
endclass
class test1 extends uvm_test;
	env e;
	`uvm_component_utils(test1)
	...
	function void build_phase(uvm_phase phase);
		e = env::type_id::create("e", this);
	endfunction
	task run_phase(uvm_phase phase);	
		flat_seq seq;
		phase.raise_objection(phase);
		seq = new();
		seq.start(e.sqr);
		phase.drop_objection(phase);
	endtask
endclass

输出结果:
在这里插入图片描述

事务传输过程分析(重点)

通信时序

在这里插入图片描述

握手建议

标签:15,进阶,seq,sequence,driver,item,uvm,sequencer
来源: https://blog.csdn.net/weixin_41979380/article/details/122617676