I need to asynchronized reset and synchronized drive a signal in my environment. So, I write my testbench similar as the following.
However, I got a 1’bX after the second assignment ( u_test.syn() ). Does anybody have any idea about this? Why does a 1’bX occur? How to resolve this problem?
It is illegal to allow procedural assignments to a wire; your simulator should have flagged this as an error. Your example is a good illustration of why it should not be allowed.
A clocking block drive to a wire behaves like a continuous assignment from an internal clocking block variable to your output wire vdio_poe. Normally when there are multiple drivers on a wire, you only have one active driver, and all the other drivers are driving a 'z. If you have more than one active driver and they are driving different values, you use the wire resolution rules to come up with a resolved value. Normally, driving a '1 and a '0 simultaneously produces an 'x. But if you allow an instantaneous procedural assignment to a wire, how long is the “assignment” in effect? There is no good answer that generally works.
There are a number of solutions to your problem depending on your actual environment.
You could change the declaration of vdio_poe to a variable instead of a wire, assuming there are no other drivers of this signal.
As in real hardware, you could gate the asynchronous enable together with the synchronous enable inside your interface.