# Implement transaction logic in driver or sequence class

**URL:** <https://verificationacademy.com/forums/t/implement-transaction-logic-in-driver-or-sequence-class/37379>\
**Category:** UVM\
**Tags:** UVM, sequence, driver\
**Created:** [March 31, 2020, 8:41pm UTC](https://verificationacademy.com/forums/t/implement-transaction-logic-in-driver-or-sequence-class/37379 "2020-03-31T20:41:40Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![abhishek.khule.seagate.com](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/a/8e7dd6/32.png) [@abhishek.khule.seagate.com](https://verificationacademy.com/forums/u/abhishek.khule.seagate.com)\
**Post date:** [March 31, 2020, 8:41pm UTC](https://verificationacademy.com/forums/t/implement-transaction-logic-in-driver-or-sequence-class/37379/1 "2020-03-31T20:41:40Z")

</div>

How to generate a transaction- In 25 clks I need to send 15 transaction. These transactions can be send randomly anytime within 25 clks. Should I implement logic in driver class or sequence class and how?

---

<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:** [March 31, 2020, 9:58pm UTC](https://verificationacademy.com/forums/t/implement-transaction-logic-in-driver-or-sequence-class/37379/2 "2020-03-31T21:58:23Z")

</div>

_In reply to [ak\_verifsj](https://verificationacademy.com/forums/t/implement-transaction-logic-in-driver-or-sequence-class/37379):_

If your interface is such that every transaction is one clock cycle, I would invent a dummy transaction and have your sequence send 25 transactions of which exactly 10 of them are randomly selected to be dummy transactions. You could even create a hiearchy of sequences to do this, but without knowing all the possible situations you need to cover, it’s hard to know what would be best for your situation.

---

<div class="post-metadata">

**Author:** ![abhishek.khule.seagate.com](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/a/8e7dd6/32.png) [@abhishek.khule.seagate.com](https://verificationacademy.com/forums/u/abhishek.khule.seagate.com)\
**Post date:** [March 31, 2020, 10:28pm UTC](https://verificationacademy.com/forums/t/implement-transaction-logic-in-driver-or-sequence-class/37379/3 "2020-03-31T22:28:49Z")

</div>

_In reply to [dave\_59](https://verificationacademy.com/forums/t/implement-transaction-logic-in-driver-or-sequence-class/37379/2):_

Hi dave, I think my wordings made the question little complicated. Rephrasing the questions - Consider scenario where I need to send data[31:0] on each clk. I need to send 15 data in 25 clks. On the remaining 10 clks driver should not drive anything on DUT.

---

<div class="post-metadata">

**Author:** ![warnerrs](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/w/858c86/32.png) [@warnerrs](https://verificationacademy.com/forums/u/warnerrs)\
**Post date:** [April 1, 2020, 6:33am UTC](https://verificationacademy.com/forums/t/implement-transaction-logic-in-driver-or-sequence-class/37379/4 "2020-04-01T06:33:07Z")

</div>

_In reply to [ak\_verifsj](https://verificationacademy.com/forums/t/implement-transaction-logic-in-driver-or-sequence-class/37379/3):_

> On the remaining 10 clks driver should not drive anything

Do you mean the bus should be floating Hi-Z?

---

<div class="post-metadata">

**Author:** ![chr\_sue](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/chr_sue/32/1199_2.png) [@chr\_sue](https://verificationacademy.com/forums/u/chr_sue)\
**Post date:** [April 1, 2020, 6:53am UTC](https://verificationacademy.com/forums/t/implement-transaction-logic-in-driver-or-sequence-class/37379/5 "2020-04-01T06:53:15Z")

</div>

_In reply to [ak\_verifsj](https://verificationacademy.com/forums/t/implement-transaction-logic-in-driver-or-sequence-class/37379/4):_

> _In reply to [dave\_59](https://verificationacademy.com/forums/t/implement-transaction-logic-in-driver-or-sequence-class/37379/4):_  
> Hi dave, I think my wordings made the question little complicated. Rephrasing the questions - Consider scenario where I need to send data[31:0] on each clk. I need to send 15 data in 25 clks. On the remaining 10 clks driver should not drive anything on DUT.

Your interface spec should say what are you doing when not sending data to the DUT. Maybe your interafce has an ‘idel’ state.  
BTW the sequencer does not send any transaction to the driver. The driver polls the transactions from the sequencer. In the driver there is all timing and nowhere else.

---

<div class="post-metadata">

**Author:** ![abhishek.khule.seagate.com](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/a/8e7dd6/32.png) [@abhishek.khule.seagate.com](https://verificationacademy.com/forums/u/abhishek.khule.seagate.com)\
**Post date:** [April 1, 2020, 3:51pm UTC](https://verificationacademy.com/forums/t/implement-transaction-logic-in-driver-or-sequence-class/37379/6 "2020-04-01T15:51:38Z")

</div>

_In reply to [warnerrs](https://verificationacademy.com/forums/t/implement-transaction-logic-in-driver-or-sequence-class/37379/5):_

> _In reply to [ak\_verifsj](https://verificationacademy.com/forums/t/implement-transaction-logic-in-driver-or-sequence-class/37379/5):_  
> Do you mean the bus should be floating Hi-Z?

It should not be floating but should be 'b0.

---

<div class="post-metadata">

**Author:** ![abhishek.khule.seagate.com](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/a/8e7dd6/32.png) [@abhishek.khule.seagate.com](https://verificationacademy.com/forums/u/abhishek.khule.seagate.com)\
**Post date:** [April 1, 2020, 3:55pm UTC](https://verificationacademy.com/forums/t/implement-transaction-logic-in-driver-or-sequence-class/37379/7 "2020-04-01T15:55:07Z")

</div>

_In reply to [chr\_sue](https://verificationacademy.com/forums/t/implement-transaction-logic-in-driver-or-sequence-class/37379/6):_

> _In reply to [ak\_verifsj](https://verificationacademy.com/forums/t/implement-transaction-logic-in-driver-or-sequence-class/37379/6):_  
> Your interface spec should say what are you doing when not sending data to the DUT. Maybe your interafce has an ‘idel’ state.  
> BTW the sequencer does not send any transaction to the driver. The driver polls the transactions from the sequencer. In the driver there is all timing and nowhere else.

Right now the only concern is where should I implement this particular logic of sending 15 valid data randomly anytime in 25 clks and drive 'b0 in remaining 10 clks. I want to know where should I implement the logic either in (driver/sequence) and how?

---

<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:** [April 1, 2020, 4:55pm UTC](https://verificationacademy.com/forums/t/implement-transaction-logic-in-driver-or-sequence-class/37379/8 "2020-04-01T16:55:23Z")

</div>

_In reply to [ak\_verifsj](https://verificationacademy.com/forums/t/implement-transaction-logic-in-driver-or-sequence-class/37379/7):_

Your question is difficult to answer because you haven’t provided any information about what it means to “drive” data versus “not drive” data. From your last response it seems like non-zero data is “driving”. If that’s the case, your driver does not need to know anything about what data its driving and can all be implemented by the sequence.

It’s still not clear if you need to send 15 non-zero random values followed by 10 zero values, or if you need to send 25 random values of which exactly 10 of them are 0.

---

<div class="post-metadata">

**Author:** ![abhishek.khule.seagate.com](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/a/8e7dd6/32.png) [@abhishek.khule.seagate.com](https://verificationacademy.com/forums/u/abhishek.khule.seagate.com)\
**Post date:** [April 1, 2020, 6:41pm UTC](https://verificationacademy.com/forums/t/implement-transaction-logic-in-driver-or-sequence-class/37379/9 "2020-04-01T18:41:12Z")

</div>

_In reply to [dave\_59](https://verificationacademy.com/forums/t/implement-transaction-logic-in-driver-or-sequence-class/37379/8):_

> _In reply to [ak\_verifsj](https://verificationacademy.com/forums/t/implement-transaction-logic-in-driver-or-sequence-class/37379/8):_  
> Your question is difficult to answer because you haven’t provided any information about what it means to “drive” data versus “not drive” data. From your last response it seems like non-zero data is “driving”. If that’s the case, your driver does not need to know anything about what data its driving and can all be implemented by the sequence.  
> It’s still not clear if you need to send 15 non-zero random values followed by 10 zero values, or if you need to send 25 random values of which exactly 10 of them are 0.

Hi dave, thats right; I need to send 25 random value with exactly 10 zero values. I simplified that values to be single data but in reality they are transaction with(addr, data,…etc)

---

<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:** [April 1, 2020, 7:05pm UTC](https://verificationacademy.com/forums/t/implement-transaction-logic-in-driver-or-sequence-class/37379/10 "2020-04-01T19:05:50Z")

</div>

_In reply to [ak\_verifsj](https://verificationacademy.com/forums/t/implement-transaction-logic-in-driver-or-sequence-class/37379/9):_

Look at the last example of my DVCon paper: [SystemVerilog Constraints: Appreciating What You Forgot in School to Get Better Results](https://verificationacademy.com/news/featured-presentations-dvcon-2020). You can change the constraint for HEADS to a 0 data value, or whatever represents a non-driving transaction.

---

<div class="post-metadata">

**Author:** ![abhishek.khule.seagate.com](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/a/8e7dd6/32.png) [@abhishek.khule.seagate.com](https://verificationacademy.com/forums/u/abhishek.khule.seagate.com)\
**Post date:** [April 1, 2020, 9:17pm UTC](https://verificationacademy.com/forums/t/implement-transaction-logic-in-driver-or-sequence-class/37379/11 "2020-04-01T21:17:37Z")

</div>

_In reply to [dave\_59](https://verificationacademy.com/forums/t/implement-transaction-logic-in-driver-or-sequence-class/37379/10):_

> _In reply to [ak\_verifsj](https://verificationacademy.com/forums/t/implement-transaction-logic-in-driver-or-sequence-class/37379/10):_  
> Look at the last example of my DVCon paper: [SystemVerilog Constraints: Appreciating What You Forgot in School to Get Better Results](https://verificationacademy.com/news/featured-presentations-dvcon-2020). You can change the constraint for HEADS to a 0 data value, or whatever represents a non-driving transaction.

Thanks that was a good suggestions. I did not think of weighted dist application here. I tried to code it but one count mismatch, I randomize 25 times and see valid==1 14 times only

```verilog
bit valid;
constraint c1{valid dist {1:= 15, 0:=10};}

```

Is this the correct way to use dist function to get valid==1 15 times for every valid==0 10times?

---

<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:** [April 1, 2020, 9:29pm UTC](https://verificationacademy.com/forums/t/implement-transaction-logic-in-driver-or-sequence-class/37379/12 "2020-04-01T21:29:17Z")

</div>

_In reply to [ak\_verifsj](https://verificationacademy.com/forums/t/implement-transaction-logic-in-driver-or-sequence-class/37379/11):_  
This is explained in the last example of the the paper.

```verilog
rand bit valid;
randc int scale;
constraint c {
        scale inside {[0:24]};
        if (scale < 15) -> valid == 1; else valid == 0; }

```

---

<div class="post-metadata">

**Author:** ![abhishek.khule.seagate.com](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/a/8e7dd6/32.png) [@abhishek.khule.seagate.com](https://verificationacademy.com/forums/u/abhishek.khule.seagate.com)\
**Post date:** [April 1, 2020, 9:45pm UTC](https://verificationacademy.com/forums/t/implement-transaction-logic-in-driver-or-sequence-class/37379/13 "2020-04-01T21:45:31Z")

</div>

_In reply to [dave\_59](https://verificationacademy.com/forums/t/implement-transaction-logic-in-driver-or-sequence-class/37379/12):_

Thanks a lot!
