It can happen than an else part is not defined. In such a case, when the 'if' condition is not met, then the signals just stay at their previous value.
But wait, do you mean X as a logic logic level such as 1, 0, Z?
If so then you are thinking on the wrong lines.
If you see in your sim something going to X, then stop there and analyze the source of the X and fix it. You don't write RTL code to work with X.
It can happen than an else part is not defined. In such a case, when the 'if' condition is not met, then the signals just stay at their previous value.
But wait, do you mean X as a logic logic level such as 1, 0, Z?
If so then you are thinking on the wrong lines.
If you see in your sim something going to X, then stop there and analyze the source of the X and fix it. You don't write RTL code to work with X.
No.... I mean what would you see in simulation? will the output hold the value even though the input is X? If the input is X, it would evaluate to 'else' but if there is no else, what happens.
Perhaps you have not understood the explanation, the fact is that in HDL languages terminology, in general the term X is used to represent an undeterminate value, instead of a variable as you have supposed done. Therefore, a X (unknown value) will be propagated toward the output.
Yes if the input to a flop is X, it will be passed to its output.
But you shouldn't be thinking what to do in RTL so as to handle X values.....as in #1.
The 1st place wherever you see X in a sim, just stop and find out from where the X first first occurs.
Most common reason for X is multi-driver problem, when a signal is driven from more than 1 sources. You should find such a place in your RTL and fix it.
Perhaps you have not understood the explanation, the fact is that in HDL languages terminology, in general the term X is used to represent an undeterminate value, instead of a variable as you have supposed done. Therefore, a X (unknown value) will be propagated toward the output.
This is incorrect for an HDL. An X in the expression of an if statement is treated the same as 0/false. When there is no else branch, nothing gets executed.
Some tools have implemented an X-propagation feature that evaluate both branches when the condition is X, and check if a variable would have been set differently, then sets it to X. However, this can be a very expensive computation, supporting only limited situations.
I understand that you are focused on x-propagation analysis. In general, if you do not have an else, there will be latch that will infer. X should propagate when latch is open in real implementation.
However, it is always advisable to use ternary operator for conditional statements to make your code more x-propagation friendly. Hope this helps.