Hi,
Are there any disadvantages of using a clocking block inside an interface.
Thanks.
Hi,
Are there any disadvantages of using a clocking block inside an interface.
Thanks.
Putting the clocking block inside an interface is the recommended way. Below are snippets of code:
interface counter_if (input logic clk);
import counter_pkg::*;
logic[3:0] data_in;
logic ld;
logic[3:0] counter;
logic rst_n;
ct_scen_e kind_cp; // for debug only
clocking driver_cb @ (posedge clk);
output rst_n, data_in, ld, kind_cp;
input counter;
endclocking : driver_cb
clocking mon_cb @ (posedge clk);
input rst_n, data_in, ld, kind_cp;
input counter;
endclocking : mon_cb
modport drvr_if_mp (clocking driver_cb);
modport mon_if_mp (clocking mon_cb);
endinterface : counter_if
class counter_driver extends uvm_driver #(counter_xactn, counter_xactn);
virtual interface counter_if.drvr_if_mp vif;
/// ....
task load_task(int data);
this.vif.driver_cb.data_in <= data;
this.vif.driver_cb.rst_n <= 1'b1;
this.vif.driver_cb.ld <= 1'b1;
@(this.vif.driver_cb)this.vif.driver_cb.ld <= 1'b0;
endtask : load_task
endclass : counter_driver
class counter_env extends uvm_env;
//....
virtual function void connect_phase(uvm_phase phase); // connect();
agent0.assign_vif(top.if0);
endfunction : connect_phase
endclass : counter_env
Ben Cohen
http://www.systemverilog.us/ ben@systemverilog.us
As opposed to not using them at all, I assume?
The answer really depends on your knowledge of the Verilog scheduling mechanism - do you know how to code to prevent race conditions, and do you know how to deal with bidirectional buses from the testbench. If you don’t understand this, then clocking blocks simplify the problem. However, they do come with several additional guidelines that you need to follow
However, if you already understand how to code to prevent race conditions and deal with bidirectional buses, then clocking blocks are an additional level of complexity that can be avoided.
In reply to dave_59:
Thanks Dave for the answers.
In reply to ben@SystemVerilog.us:
Thanks Ben for the snippet.
In reply to KumarSunilB:
See Why non blocking while driving signals on interface - UVM - Verification Academy
and Assigning interface net-type signals from class - SystemVerilog - Verification Academy
Particularly this section
The best way to drive interface wires is to use clocking blocks.
- A clockvar whose clocking_direction is inout shall behave as if it were two clockvars, one input and one output, having the same name and the same clocking_signal.