Modeling both sequential and combinational logic within the same always block a good practice or is it recommended to code them in separate blocks.
always @(a or b)
y = a ^ b;
always @(posedge clk or negedge rst_n)
if (!rst_n) q <= 1'b0;
else
q <= y;
Or doing this:
always @(posedge clk or negedge rst_n)
if (!rst_n) q <= 1'b0;
else
q <= a ^ b;
I know both would result in same functionality.
But it is also said that mixing blocking and nonblocking assignments in the same always block is a poor coding style. Do we not use blocking for combinational logic and non-blocking for sequential logic.
Modeling both sequential and combinational logic within the same always block a good practice.
Mixing blocking and nonblocking assignments in the same always block is a poor coding style.
Then in that case above statements are contradicting isn't it?