• 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. Verification IP
  3. How to implement a basic clean read-write sequence in Specman...

Stats

  • Replies 0
  • Subscribers 12
  • Views 123
  • Members are here 0

How to implement a basic clean read-write sequence in Specman? Is this approach correct?

AP202508036621
AP202508036621 1 month ago

Hi, I’m trying to write a simple read-write sequence in Specman using a BFM. I wrote the code below, but I’m unsure if it’s the correct and clean way to do it. I see many variations online, which confuses me.

The sequence grabs the driver, performs a write transaction, waits a random number of clocks, performs a read transaction at the same address, then releases the driver.

I don’t have access to Cadence tools to test this, so I would appreciate feedback on the correctness of the sequence, use of grab/ungrab, and any improvements or best practices you can suggest.

Also, how can I run or simulate this without a Cadence license?

Thanks in advance!

**Code:**

    // READ-WRITE Sequence
    struct my_item like any_sequence_item is {
        addr: byte;
        data: uint(bits:32);
        rd_wr: bit;
    };

    type seq_type : enum { READ, WRITE };

    sequence my_seq using item: item = my_item, created_driver = my_bfm_u;

    extend my_seq {
        !sequence_type: seq_type;
    };

    extend my_seq is {
        keep soft item.rd_wr == (sequence_type == WRITE) ? 1 : 0;
        clk is @my_driver.clk;

        body() @clk is {
            var rand_num: uint(bits:4);
            var last_addr: byte;

            for i from 0 to 10 {
                grab(my_driver);

                do WRITE my_seq keeping { last_addr == it.addr; };
                wait[rand_num] * clk;

                do READ my_seq keeping { it.addr == last_addr; };

                ungrab(my_driver);

                gen rand_num;
                wait[rand_num] * clk;
            };
        };
    };

    unit my_bfm_u is {
        smp: smp_u;
        clk is @smp.clk;

        run() @clk is also {
            drive_read_write();
        };

        drive_read_write() @clk is {
            item: my_item;

            while (TRUE) {
                item = my_seq.get_next_item();
                smp.addr = item.addr;
                smp.rd_wr = item.rd_wr;
                smp.data = item.data;
                emit my_seq.item_done;
            };
        };
    };

    unit my_agent_u is {
        smp: smp_u is instance;
        bfm: my_bfm_u is instance;
        keep bfm.smp == smp;

        monitor: monitor_u is instance;
        keep monitor.smp == smp;
    };
  • Sign in to reply
  • Cancel

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