UVM: Driver-Sequencer Handshake Mechanism - EDA Playground
Warning! This exercise has been opened in another tab; autosave has been disabled. Close this tab or refresh to reactivate.

 Languages & Libraries

 Tools & Simulators

 Examples

209


54
 
1
`ifndef MY_DRIVER_SV
2
`define MY_DRIVER_SV
3
4
class my_driver extends uvm_driver#(my_transaction);
5
  
6
  `uvm_component_utils(my_driver)
7
  
8
  virtual my_if vif;
9
  
10
  //---------------
11
  //  constructor  
12
  //---------------
13
  function new(string name, uvm_component parent);
14
    super.new(name, parent);
15
  endfunction: new
16
  
17
  //---------------
18
  //  build phase  
19
  //---------------
20
  function void build_phase(uvm_phase phase);
21
    super.build_phase(phase);
22
    if (!uvm_config_db#(virtual my_if)::get(this, "", "vif", vif))
23
      `uvm_fatal(get_name(), "virtual interface not set")
24
  endfunction: build_phase
25
  
26
  //-------------
27
  //  run phase  
28
  //-------------
29
  virtual task run_phase(uvm_phase phase);
30
    @(negedge vif.rstn) vif.in <= 4'h0;
31
    @(posedge vif.rstn);
32
    
33
    forever begin
34
      `uvm_info(get_name(), "get_next_item", UVM_LOW)
35
      seq_item_port.get_next_item(req);
36
      
37
      `uvm_info(get_name(), "drive", UVM_LOW)
38
      drive();
39
      
40
      `uvm_info(get_name(), "item_done", UVM_LOW)
41
      seq_item_port.item_done();
42
    end
43
  endtask: run_phase
44
    
45
  //---------
46
  //  drive  
47
  //---------
48
  virtual task drive();
49
    @(negedge vif.clk) vif.in <= req.data;
50
  endtask: drive
51
  
52
endclass: my_driver
53
54
`endif
xxxxxxxxxx
1
19
 
1
//-----------------------------------------------------
2
//  Title      : Driver-Sequencer Handshake Mechanism  
3
//  Author     : IKS (Jung Ik Moon)                    
4
//  Description: For full description,                 
5
//               see https://goo.gl/cj6Nts             
6
//-----------------------------------------------------
7
module duv(
8
  input  wire       clk,
9
  input  wire       rstn,
10
  input  wire [3:0] in,
11
  output reg  [3:0] out
12
);
13
  
14
  always @(posedge clk or negedge rstn) begin
15
    if (!rstn) out <= 4'h0;
16
    else       out <= in;
17
  end
18
  
19
endmodule: duv
986 views and 1 likes     
A short description will be helpful for you to remember your playground's details
 
100:0