Enable Not Working on Synchronous Subsystem
1 view (last 30 days)
Patrick Ozimek on 5 Apr 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.
Bharath Venkataraman on 6 Apr 2022
Edited: Bharath Venkataraman on 6 Apr 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.