Enable Not Working on Synchronous Subsystem

3 vues (au cours des 30 derniers jours)
Patrick Ozimek
Patrick Ozimek le 5 Avr 2022
I have a synchronous subsystem that I want to enable only under certain conditions to avoid things like divide by zero errors. Unfortunately, adding an enable input seems to have no effect.
I created a very simple example that shows this problem:
Here is the top level of the model where I feed a sine wave into the subsystem and only enable when the value is greater than zero:
And here is the Enabled Synchronous Subsystem where I am simply calculating the reciprocal of the input.
If I run this simulation, I get divide by zero errors and the ouput appears as if the subsystem is always enabled:
Hwever, if i remove the Synchronous State Control Block, the output behaves as I would expect:
Why is this happening? Is this behavior as expected? I want to use Synchronous State Control because I will be generating HDL code from my model.

Réponse acceptée

Bharath Venkataraman
Bharath Venkataraman le 6 Avr 2022
Modifié(e) : Bharath Venkataraman le 6 Avr 2022
The synchronous state control behaves exactly like the HDL would, doing a divide by zero because the reciprocal block is a combinatorial operation (which is not controlled by the enable in HDL).
As you have noticed, you can use the enabled subsystem without the synchronous state control for the behavior you desire.
Adding in a delay to the enabled subsystem will also help you model the behavior you want. Adding a register provides the state that is then controlled by the enable as you desire. Set the initial value of the delay block to a non-zero value.
You can also use a delay with enable to prevent feeding in a zero to the reciprocal block. Again, set the initial value of the delay block to a non-zero value.

Plus de réponses (0)

Catégories

En savoir plus sur Subsystems dans Help Center et File Exchange

Produits


Version

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by