|
发表于 2017-8-25 09:40:03
|
显示全部楼层
some example of req, resp in the driver/sequence:
my_sequence extends uvm_sequence #(my_sequence_item1, (my_sequence_item2); // type of req = my_sequence_item1, type of rsp = my_sequence_item2
.....
task body();
// Step 1 - Creation
req = my_sequence_item1::type_id::create("req"); // type of req = my_sequence_item1
// Step 2 - Ready - start_item()
start_item(req);
// Step 3 - Set
if(!req.randomize() with {address inside {[0:32'h4FFF_FFFF]};})
begin
`uvm_error("body", "randomization failure for req")
end
// Step 4 - Go - finish_item()
finish_item(req);
// Step 5 - Response - get_response()
get_response(rsp); // type of rsp = my_sequence_item2
endtask: body
endclass: my_sequence
class my_driver extends uvm_driver #(my_sequence_item);
my_interface vif;
.....
task run_phase(uvm_phase phase);
forever
begin
seq_item_port.get_next_item(req); // Blocking call returning the next transaction
@(posedge vif.clk);
vif.addr = req.address; // vif is the drivers Virtual Interface
//
// etc
//
// End of bus cycle
if(req.read_or_write == READ)
begin // Assign response data to the req fields
req.rdata = vif.rdata;
end
rsp = my_sequence_item2::type_id::create("rsp"); // type of rsp = my_sequence_item2
req.resp = vif.error; // Assign response to the req_item response field
seq_item_port.item_done(rsp); // Signal to the sequence that the driver has finished with the item
end
endtask: run
endclass: my_driver |
|