Send words to Blackrock atomically

Hi Yasmine & Jack,

At our most recent meeting, we discussed how to send words to Blackrock atomically, so that word sends on different MWorks threads don’t get interleaved. Here’s what this looks like in MWEL code.

First, define a new variable, and attach the strobe off, set word, and strobe on assignments to it:

var vpixx_dout_blackrock_strobe = false
var vpixx_dout_blackrock_word16 = 0

var blackrock_sync_word = 0 {
    // Clear the strobe line, set the word value, then set the strobe to
    // trigger recording.  Doing this via variable-attached actions ensures
    // that all word sends are atomic and can't overlap with one another.
    vpixx_dout_blackrock_strobe = false
    vpixx_dout_blackrock_word16 = blackrock_sync_word
    vpixx_dout_blackrock_strobe = true

Then, in the macro vpixx_send_blackrock_sync_word, assign only to this new variable:

%define vpixx_send_blackrock_sync_word (value)
    // Ensure that value is an integer in the range [0, 65535]
    assert (
        condition = ((int)value == value) and (value >= 0) and (value <= 65535)
        stop_on_failure = true

    blackrock_sync_word = value

You could also just get rid of the macro and include the value-checking assertion in the actions attached to blackrock_sync_word.


Thanks Chris! We’ll try this out soon!