M
mksuth
Guest
I'm busy transitioning from vhdl to verilog and I've read several
verilog guidelines which say
"do not mix blocking and non-blocking assignments in the same always
block". What exactly is the problem here?
For example, I would find it convenient to do something like this:
// ....
reg [ADDR_WIDTH-1:0] read_addr,
write_addr;
reg signed [ADDR_WIDTH :0] read_addr_tmp;
always @(posedge clk)
if (reset) begin
write_addr <= 0;
read_addr <= 0;
end else if (enable) begin
// write address
if (write_addr == RAM_DEPTH-1)
write_addr <= 0;
else
write_addr <= write_addr + 1;
// read address
read_addr_tmp = $signed({1'b0,write_addr}) + 2 - $signed
({1'b0,size});
if (read_addr_tmp < 0)
read_addr_tmp = read_addr_tmp + DEPTH;
else if (read_addr_tmp >= DEPTH)
read_addr_tmp = read_addr_tmp - DEPTH;
read_addr <= read_addr_tmp[ADDR_WIDTH-1:0];
end
Is there anything wrong with using blocking assignments to perform
intermediate calculations within sequential processes?
verilog guidelines which say
"do not mix blocking and non-blocking assignments in the same always
block". What exactly is the problem here?
For example, I would find it convenient to do something like this:
// ....
reg [ADDR_WIDTH-1:0] read_addr,
write_addr;
reg signed [ADDR_WIDTH :0] read_addr_tmp;
always @(posedge clk)
if (reset) begin
write_addr <= 0;
read_addr <= 0;
end else if (enable) begin
// write address
if (write_addr == RAM_DEPTH-1)
write_addr <= 0;
else
write_addr <= write_addr + 1;
// read address
read_addr_tmp = $signed({1'b0,write_addr}) + 2 - $signed
({1'b0,size});
if (read_addr_tmp < 0)
read_addr_tmp = read_addr_tmp + DEPTH;
else if (read_addr_tmp >= DEPTH)
read_addr_tmp = read_addr_tmp - DEPTH;
read_addr <= read_addr_tmp[ADDR_WIDTH-1:0];
end
Is there anything wrong with using blocking assignments to perform
intermediate calculations within sequential processes?