In my experience, driving a net from two separate processes (or always blocks) is a bad idea and will result in a multi-driver error in the tools.
However, one of my acquaintances claims that if the signal assignments are contained within if
statements that never assert at the same time, it should be possible to drive one signal from two always blocks.
As a test, I did this in Vivado 2014.4. Here is my very trivial test code:
// always block one
always @ (posedge clk) begin
if (rst) begin
RegA <= 0;
end
else begin
if (RegA_in_valid_1) begin
RegA <= RegA_in_1;
end
end
end
// Always block two
always @ (posedge clk) begin
if (rst == 0) begin
if (!RegA_in_valid_1 && RegA_in_valid_2)
RegA <= RegA_in_2;
end
end
As I expected, Vivado does produce errors:
[Synth 8-3352] multi-driven net RegA_out_OBUF[31] with 1st driver pin 'RegA_reg[31]__0/Q'
...
After this test, said acquaintance still claims that this code would synthesize in previous versions of Vivado without errors. This got me thinking - what does the synthesis tool use to determine if a net is multi driven? Does it use the respective sensitivity lists, or is this mechanism feasible (using conditional statements). I see my version of Vivado doesn't work, but what is the consensus in general?