-
Notifications
You must be signed in to change notification settings - Fork 0
/
driver.svh
50 lines (36 loc) · 1.35 KB
/
driver.svh
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
/*
Class: driver
This class implements the driver.
*/
class driver extends uvm_driver;
`uvm_component_utils(clock::driver)
configuration m_configuration;
function new(string name="clock::driver", uvm_component parent=null);
super.new(name, parent);
endfunction: new
virtual function void build_phase(uvm_phase phase);
super.build_phase(phase);
endfunction: build_phase
virtual task run_phase(uvm_phase phase);
this.m_configuration.vif.clock = this.m_configuration.init_value;
forever begin
if (m_configuration.state == RUNNING) begin
if (this.seq_item_port.try_next_item(this.req) != null) begin
// update state
this.seq_item_port.item_done();
end
this.drive(m_configuration.vif);
end else begin
this.seq_item_port.get_next_item(this.req);
// update state
this.seq_item_port.item_done();
end
end
endtask: run_phase
virtual task drive(virtual clock_if vif);
#(this.m_configuration.period * this.m_configuration.duty_cycle);
vif.clock = ~vif.clock;
#(this.m_configuration.period * (1 - this.m_configuration.duty_cycle));
vif.clock = ~vif.clock;
endtask: drive
endclass: driver