-
Notifications
You must be signed in to change notification settings - Fork 87
/
simpleadder_driver.sv
76 lines (62 loc) · 1.51 KB
/
simpleadder_driver.sv
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
class simpleadder_driver extends uvm_driver#(simpleadder_transaction);
`uvm_component_utils(simpleadder_driver)
virtual simpleadder_if vif;
function new(string name, uvm_component parent);
super.new(name, parent);
endfunction: new
function void build_phase(uvm_phase phase);
super.build_phase(phase);
void'(uvm_resource_db#(virtual simpleadder_if)::read_by_name
(.scope("ifs"), .name("simpleadder_if"), .val(vif)));
endfunction: build_phase
task run_phase(uvm_phase phase);
drive();
endtask: run_phase
virtual task drive();
simpleadder_transaction sa_tx;
integer counter = 0, state = 0;
vif.sig_ina = 0'b0;
vif.sig_inb = 0'b0;
vif.sig_en_i = 1'b0;
forever begin
if(counter==0)
begin
seq_item_port.get_next_item(sa_tx);
//`uvm_info("sa_driver", sa_tx.sprint(), UVM_LOW);
end
@(posedge vif.sig_clock)
begin
if(counter==0)
begin
vif.sig_en_i = 1'b1;
state = 1;
end
if(counter==1)
begin
vif.sig_en_i = 1'b0;
end
case(state)
1: begin
vif.sig_ina = sa_tx.ina[1];
vif.sig_inb = sa_tx.inb[1];
sa_tx.ina = sa_tx.ina << 1;
sa_tx.inb = sa_tx.inb << 1;
counter = counter + 1;
if(counter==2) state = 2;
end
2: begin
vif.sig_ina = 1'b0;
vif.sig_inb = 1'b0;
counter = counter + 1;
if(counter==6)
begin
counter = 0;
state = 0;
seq_item_port.item_done();
end
end
endcase
end
end
endtask: drive
endclass: simpleadder_driver