-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapb_slv_driver.sv
More file actions
93 lines (80 loc) · 3.13 KB
/
Copy pathapb_slv_driver.sv
File metadata and controls
93 lines (80 loc) · 3.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
class apb_slv_driver extends uvm_driver#(apb_item);
//======================
// Factory registeration
//======================
`uvm_component_utils(apb_slv_driver)
//======================
// Constructor
//======================
function new(string name = "apb_slv_driver" , uvm_component parent=null);
super.new(name , parent);
endfunction
//=============================
// Handle to virtual interface
//=============================
virtual apb_interface apb_vif;
//=============================
// Handle to apb configuration
//=============================
apb_config apb_cfg;
//=============================
// Handle to apb sequence item
//=============================
apb_item pkt;
apb_item apb_rsp_item;
//======================
// Build phase
//======================
function void build_phase(uvm_phase phase);
super.build_phase(phase);
`uvm_info(get_type_name(), "__________Starting build phase__________", UVM_MEDIUM);
pkt = apb_item::type_id::create("pkt"); // creating apb_item
apb_rsp_item = apb_item::type_id::create("apb_rsp_item"); // creating apb response item
if(!(uvm_config_db#(virtual apb_interface)::get(this, "", "apb_vif", apb_vif))) begin
`uvm_error(get_type_name(), "Failed to get virtual interface");
end
else begin
`uvm_info(get_type_name(), "Virtual interface recieved successfully", UVM_HIGH);
end
if(!uvm_config_db#(apb_config)::get(null , "" , "apb_cfg" , apb_cfg)) begin
`uvm_fatal(get_type_name() , "Failed to recieve apb configuration")
end
else begin
`uvm_info(get_type_name() , "apb configuration successfully received" , UVM_HIGH);
end
`uvm_info(get_type_name(), "__________Ending build phase__________", UVM_MEDIUM);
endfunction
//======================
// Main phase
//======================
task main_phase(uvm_phase phase);
super.main_phase(phase);
`uvm_info(get_type_name(), "__________Starting main phase of apb_slave_driver__________", UVM_MEDIUM);
repeat(apb_cfg.packets) begin
seq_item_port.get_next_item(pkt);
apb_response_tx(pkt , apb_rsp_item);// driving apb resposne
pkt.print_apb_slv("APB_PACKET" , UVM_HIGH);
seq_item_port.item_done(apb_rsp_item);
end
`uvm_info(get_type_name(), "__________Ending main phase of apb_slave_driver__________", UVM_MEDIUM);
endtask
task apb_response_tx(apb_item pkt , apb_item rsp);
apb_item apb_rsp;
if(!$cast(apb_rsp , pkt.clone())) begin
`uvm_error(get_type_name() , "Failed to cast apb_rsp")
end
apb_rsp.set_id_info(pkt);
@(posedge apb_vif.clk iff apb_vif.resetn);
apb_vif.PREADY <= pkt.PREADY;
apb_vif.PSLVERR <= pkt.PSLVERR;
apb_vif.PRDATA <= pkt.PRDATA;
@(posedge apb_vif.clk);
apb_rsp.PADDR <= apb_vif.PADDR;
apb_rsp.PSELx <= apb_vif.PSELx;
apb_rsp.PENABLE <= apb_vif.PENABLE;
apb_rsp.PWRITE <= apb_vif.PWRITE;
apb_rsp.PWDATA <= apb_vif.PWDATA;
apb_rsp.PSTRB <= apb_vif.PSTRB;
rsp = apb_rsp;
endtask
endclass