Assuming you are designing hardware and not non-synthesized testbench code, this not a good practice and likely won't do what you want anyways.
From a language perspective, this will compile and simulate. It will block waiting on the events within the always blocks and NOT restart on each posedge of the clock. I could not find a spec reference for this but it's what I observed in simulation. I'm curious what this would synthesize to if you even get it to synthesize with no errors.
If the signal from the other subsystem is already in the same clock domain (synchronous to clk
), then you can just check the state of it on each clock edge, and use this do something.
always @(posedge clk) begin: TEST
if (the_other_signal == 1'b1) begin
...
end
end
Some other things to consider:
- Maybe you only care about when the signal assert/deasserts. In that case you need to do an edge detection.
- If the signal is asynchronous to
clk
, then you have a clock domain crossing and you need to synchronize the incoming signal before you look at it.