# Clocking blocks causes multiple driving for signal

**URL:** <https://verificationacademy.com/forums/t/clocking-blocks-causes-multiple-driving-for-signal/32676>\
**Category:** SystemVerilog\
**Tags:** multiple-drivers, SystemVerilog, procedural-assignment, clocking-blocks, continuous-assignment\
**Created:** [December 22, 2016, 11:59am UTC](https://verificationacademy.com/forums/t/clocking-blocks-causes-multiple-driving-for-signal/32676 "2016-12-22T11:59:40Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![trogers](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/t/f17d59/32.png) [@trogers](https://verificationacademy.com/forums/u/trogers)\
**Post date:** [December 22, 2016, 11:59am UTC](https://verificationacademy.com/forums/t/clocking-blocks-causes-multiple-driving-for-signal/32676/1 "2016-12-22T11:59:40Z")

</div>

Hello everyone!

I’ve statred using clocking blocks in my designs, and they cause lots of gotcha’s =)  
in particular, this one confuses me a lot:

```verilog

interface some_if (input clk);
  logic signal;

  clocking cb (@posedge clk)
    output signal;
  endclocking
  
  modport driver (cb);

endinterface

```

Even if i have no driver in my agent for this interface, this clocking block causes an error (variable is driven via procedural & continious assignments, or smthng like this), because module, that i test has a driver for this signal. I actually understand, WHY it happens (implicit procedural assignment happens on that signal by the output clockvar associated with that signal), but i have no good idea, how to overcome this issue.  
i’ve seen papers like this one

> **[Using Wrapper Interface For Resolving Multiple Drivers](https://www.design-reuse.com/articles/38613/using-wrapper-interface-for-resolving-multiple-drivers.html)**
>
> The article demonstrates the issue of multiple driver created on an interface signal due to clocking blocks while integrating the DUT and the testbench. A wrapper interface has been introduced which will serve as a medium for connecting the DUT and...

in internet, but it looks very monstrously, and also, it makes impossible (as i can see it), using interface inside DUT itself (in article above DUT uses ADDR and READY not via interface, but as raw signals).  
Also there’s this one paper  
[https://verificationacademy.com/resources/technical-papers/the-missing-link-the-testbench-to-dut-connection](https://verificationacademy.com/resources/technical-papers/the-missing-link-the-testbench-to-dut-connection)  
and it looks pretty good, except for the last paragraph: clocking block is defined there just as in my example, and it seems to me, that it will end up with the same error (please, correct me, if I’m wrong).  
So what’s the solution? Is there any? Should I use CB’s at all, if they cause so many problems?  
Thank you for reading!

---

<div class="post-metadata">

**Author:** ![dave\_59](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/dave_59/32/4499_2.png) [@dave\_59](https://verificationacademy.com/forums/u/dave_59)\
**Post date:** [December 22, 2016, 3:40pm UTC](https://verificationacademy.com/forums/t/clocking-blocks-causes-multiple-driving-for-signal/32676/2 "2016-12-22T15:40:10Z")

</div>

_In reply to [trogers](https://verificationacademy.com/forums/t/clocking-blocks-causes-multiple-driving-for-signal/32676):_  
Declare signal as a   
wire.

---

<div class="post-metadata">

**Author:** ![trogers](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/t/f17d59/32.png) [@trogers](https://verificationacademy.com/forums/u/trogers)\
**Post date:** [December 23, 2016, 11:36am UTC](https://verificationacademy.com/forums/t/clocking-blocks-causes-multiple-driving-for-signal/32676/3 "2016-12-23T11:36:44Z")

</div>

so simple=)  
Thank you, Dave!

---

<div class="post-metadata">

**Author:** ![trogers](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/t/f17d59/32.png) [@trogers](https://verificationacademy.com/forums/u/trogers)\
**Post date:** [January 17, 2017, 9:30am UTC](https://verificationacademy.com/forums/t/clocking-blocks-causes-multiple-driving-for-signal/32676/4 "2017-01-17T09:30:26Z")

</div>

ok, so it’s not really that simple) declaring signal as a “wire” symply forbids any procedural assignments, so it’s not legal to drive signal in any “always” blocks. So, as i see it, if I use clocking block in my testbench, i have to edit my DUT, if it drives signals to the interface with “always” statement, to “assign” driving, right?  
Sorry for being so hair-splitting, but it just doesn’t seem to be a right thing, that i might need to change DUT in order to write testbench.

---

<div class="post-metadata">

**Author:** ![cgales](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/c/ccd318/32.png) [@cgales](https://verificationacademy.com/forums/u/cgales)\
**Post date:** [January 17, 2017, 2:18pm UTC](https://verificationacademy.com/forums/t/clocking-blocks-causes-multiple-driving-for-signal/32676/5 "2017-01-17T14:18:47Z")

</div>

_In reply to [trogers](https://verificationacademy.com/forums/t/clocking-blocks-causes-multiple-driving-for-signal/32676/4):_

It looks like you want to be able to use the interface in both a master mode, where ‘signal’ is an output from ‘some\_if’, and in a slave/monitor mode where the DUT is driving ‘signal’ into ‘some\_if’.

In this case, you need some additional control logic to configure ‘some\_if’:

```verilog

interface some_if (input clk);
  wire signal;
 
  bit signal_b;
  bit mode=1'b0; // 1 = Master; 0 = Slave

  assign signal = (mode==1'b1) ? signal_b : 1'bz;

  clocking cb (@posedge clk)
    output signal;
  endclocking
 
  modport driver (cb);
 
endinterface

```

From your driver, change ‘mode’ as appropriate, and set ‘signal\_b’ as the output value.

---

<div class="post-metadata">

**Author:** ![trogers](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/t/f17d59/32.png) [@trogers](https://verificationacademy.com/forums/u/trogers)\
**Post date:** [January 26, 2017, 7:53am UTC](https://verificationacademy.com/forums/t/clocking-blocks-causes-multiple-driving-for-signal/32676/6 "2017-01-26T07:53:00Z")

</div>

_In reply to [cgales](https://verificationacademy.com/forums/t/clocking-blocks-causes-multiple-driving-for-signal/32676/5):_

you mean, that i should write from DUT using “signal\_b” and “mode = 1”, and from TB using “signal” and “mode = 0”? that actually might work, i guess, although two signals will be required to interact with this signal from DUT-master(signal\_b) and DUT-slave(signal). Doesn’t look perfect too.

It seems to me, no matter what trick or technique i use, using interfaces in testbench ends up with PITA. I’ve read about using abstract classes to access signals from TB, can you tell me, if they have clocking blocks positive sides, such as determined time of sampling and driving signals?  
I din’t find much information about it in whitepaper, mentioned above (The Missing Link).

---

<div class="post-metadata">

**Author:** ![trogers](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/t/f17d59/32.png) [@trogers](https://verificationacademy.com/forums/u/trogers)\
**Post date:** [February 3, 2017, 7:04am UTC](https://verificationacademy.com/forums/t/clocking-blocks-causes-multiple-driving-for-signal/32676/7 "2017-02-03T07:04:43Z")

</div>

sorry for double posting, but i’m still looking for solution of this problem=) Clocking blocks and abstract classes look like very popular techniques for driving signals, but somehow there’s almost no infomation about their behaviour and gothas at the junction with DUT.  
So what is a painless way to drive signals? I’m sure, that every verification engineer found a way to avoid side-effects like imaginary multiple driving. Please, share with me=)
