• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Functional Verification
  3. SV transaction sequence dependency constraint?

Stats

  • Locked Locked
  • Replies 5
  • Subscribers 64
  • Views 15075
  • Members are here 0
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

SV transaction sequence dependency constraint?

archive
archive over 18 years ago

Hi all, Is there any good methods to write SystemVerilog transaction sequence dependency constraint? For example, in below SV code, I want to always generate IDLE transaction after WRITE (i.e. WRITE after WRITE or READ after WRITE is illegal). //--- SV code start--- //define transactions typedef enum { WRITE=1,READ=2,IDLE=4} cmd_t; class Packet; ... rand cmd_t cmd; ... endclass Packet p; initial repert(20) begin p = new(); p.randomize(); end //--- SV code end--- Best regards, Davy


Originally posted in cdnusers.org by davyzhu
  • Cancel
Parents
  • archive
    archive over 18 years ago

    Davy,

    In cases like this, I've been using the "pre_randomize" function as follows...

    //--- SV code start---

    //define transactions
    typedef enum { WRITE=1,READ=2,IDLE=4} cmd_t;
    class Packet;
    ...
    rand cmd_t cmd;
    cmt_t last_cmd = IDLE;
    ...

    constraint c1 {last_cmd == WRITE -> cmd == IDLE;}

    function void pre_randomize();
    last_cmd = cmd;
    endfunction

    endclass

    Packet p;

    initial
    repeat(20) begin
    p = new();
    p.randomize();
    end //--- SV code end

    If someone knows a better way to do this, I'd like to hear about it.

    David Walker


    Originally posted in cdnusers.org by dbwalker0min
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Reply
  • archive
    archive over 18 years ago

    Davy,

    In cases like this, I've been using the "pre_randomize" function as follows...

    //--- SV code start---

    //define transactions
    typedef enum { WRITE=1,READ=2,IDLE=4} cmd_t;
    class Packet;
    ...
    rand cmd_t cmd;
    cmt_t last_cmd = IDLE;
    ...

    constraint c1 {last_cmd == WRITE -> cmd == IDLE;}

    function void pre_randomize();
    last_cmd = cmd;
    endfunction

    endclass

    Packet p;

    initial
    repeat(20) begin
    p = new();
    p.randomize();
    end //--- SV code end

    If someone knows a better way to do this, I'd like to hear about it.

    David Walker


    Originally posted in cdnusers.org by dbwalker0min
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Children
No Data

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information