# Send words to Blackrock atomically

**URL:** <https://mworks.discourse.group/t/send-words-to-blackrock-atomically/77>\
**Category:** Support\
**Created:** [March 8, 2022, 3:16pm UTC](https://mworks.discourse.group/t/send-words-to-blackrock-atomically/77 "2022-03-08T15:16:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)\
**Post date:** [March 8, 2022, 3:16pm UTC](https://mworks.discourse.group/t/send-words-to-blackrock-atomically/77/1 "2022-03-08T15:16:48Z")

</div>

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:

```auto
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:

```auto
%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
%end

```

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

Cheers,  
Chris

---

<div class="post-metadata">

**Author:** ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)\
**Post date:** [March 8, 2022, 3:31pm UTC](https://mworks.discourse.group/t/send-words-to-blackrock-atomically/77/2 "2022-03-08T15:31:55Z")

</div>

Thanks Chris! We’ll try this out soon!  
Yasmine

---

<div class="post-metadata">

**Author:** ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)\
**Post date:** [July 19, 2022, 6:07pm UTC](https://mworks.discourse.group/t/send-words-to-blackrock-atomically/77/3 "2022-07-19T18:07:07Z")

</div>


