specmane

Specman e: How driver's items queue can be locked from a sequence?


In my verification environment, there are few sequences running simultaneously on the same driver (there is no matter when an item gets the bus in relation to other sequences' items).

BUT, now I need to add additional sequence, that will run simultaneously to other sequences, that executes atomic read-modify-write. My new sequence looks something like this:

// Atomic READ-MODIFY-WRITE
body() @driver.clock is only {

    do read_item keeping {
        .cmd                == RD; 
        .addr               == addr;
    };

    // Wait random time;

    do write_item keeping {
        .cmd                == WR;
        .addr               == addr;
        .data               == data;  
    };
};

The problem is that between the read_item and write_item, items from other sequences get the bus. Do you have any idea how the driver's item queue can be locked from a sequence? So I can prevent other sequences to add their items in between my read and write items?

Thank you for your help


Solution

  • You can use the grab(...) and ungrab(...) methods of any_sequence to get exclusive access to the sequence driver:

    // Atomic READ-MODIFY-WRITE
    body() @driver.clock is only {
    
        grab(driver);
    
        do read_item keeping {
            .cmd                == RD; 
            .addr               == addr;
        };
    
        // Wait random time;
    
        do write_item keeping {
            .cmd                == WR;
            .addr               == addr;
            .data               == data;  
        };
    
        ungrab(driver);
    };
    

    While the driver is grabbed, no other sequence can send items to the it.