I'm testing SystemVerilog code using verilator, and it looks like below.
output [31:0] data_out1;
reg [31:0] data_out1;
always @(rst_b or addr1 or data_in1 or write_mask1)
begin
if((write_mask1 != 32'b0) && (rst_b == 1'b1))
begin
data_out1 <= 32'hxxxxxxxx;
... do something ....
end
always @(posedge clk)
begin
if((write_mask1 != 32'b0) && (rst_b == 1'b1))
begin
data_out1 <= 32'hxxxxxxxx;
... do something ..
end
It has two always blocks, and in each block, data_out1 is assigned in non-blocking. But, it shows a "Blocked and non-blocking assignments to same variable" error.
I do not use blocking assignment, and I can't understand why such an error occurs. I would appreciate if anyone can help.
When I run verilator on your code snippet, I get messages like the following:
The 1st warning message indicates that verilator interprets your 1st
alwaysblock as combinational logic, not sequential logic, and it treats the nonblocking assignment operator (<=) as a blocking assignment.Since your 1st block does not use
@(posedge clk), it is treated as combinational logic.Also, you should not make assignments to the same signal from multiple blocks.
Lastly, you should not use nonblocking assignments to infer combinational logic.