# Observables, Verilog style

**URL:** <https://discourse.julialang.org/t/observables-verilog-style/68537>\
**Category:** General Usage\
**Created:** [September 21, 2021, 4:15pm UTC](https://discourse.julialang.org/t/observables-verilog-style/68537 "2021-09-21T16:15:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bardo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bardo/32/21601_2.png) [@Bardo](https://discourse.julialang.org/u/Bardo)\
**Post date:** [September 21, 2021, 4:15pm UTC](https://discourse.julialang.org/t/observables-verilog-style/68537/1 "2021-09-21T16:15:53Z")

</div>

I was looking for an observable implementation similar to Verilog AMS or SystemVerilog.  
There you would have constructs like

```julia
always @(sig1 && posedge(sig2)) // when sig1 (analog) changes AND sig2 (digital) does trans 0->1
   a = funCB(b,c); // callback function
end

```

Compared to known implementations in Julia (React.jl or Observable.jl), there is a richer functionality: besides change, you can trigger on direction of change, and you can have shortcuts using observables.

I see two possibilities: implement from scratch or extend those above with some syntactic sugar using macros.  
With the latter I have even less experience.  
Any ideas?

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [September 21, 2021, 6:57pm UTC](https://discourse.julialang.org/t/observables-verilog-style/68537/2 "2021-09-21T18:57:18Z")

</div>

You can do conditions with `Observables.jl` but you can’t have two observables triggering at the same time. They can only ever trigger one after the other, so the `AND` condition doesn’t really make sense.

But for all other conditions you could do:

```julia
onany(observable_1, observable_2) do obs1_val, obs2_val
    if condition(obs1_val, obs2_val)
        callback_function()
    end
end

```

---

<div class="post-metadata">

**Author:** ![Bardo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bardo/32/21601_2.png) [@Bardo](https://discourse.julialang.org/u/Bardo)\
**Post date:** [September 21, 2021, 8:34pm UTC](https://discourse.julialang.org/t/observables-verilog-style/68537/3 "2021-09-21T20:34:07Z")

</div>

Thanks for the conditions hint.  
Yes, the combination of events results is often difficult. A clean up before firing callbacks would require a custom implementation.
