Md. Shazzatur Rahman
Md. Shazzatur Rahman

Reputation: 45

@() inside an always block

Whether using @() inside an always block is a bad practice or in other words it is wrong? The example code is given below:

always@(negedge clk)begin

        @(valueI)begin
            deterministicEnable=0;
            iterate=iterate+1;
            deterministicEnable=1;
            j=0;
            $display("%h  %d   %d",valueI,$time,j);
        end

end

Upvotes: 0

Views: 94

Answers (2)

dave_59
dave_59

Reputation: 42698

It's not allowed by most RTL synthesis tools.

It's a bad practice in general. You have code that is synchronous to a falling edge of a clock. Then you wait for another change that may or may not be coincident with the previous clock. I don't know if that is important in your case.

Also, the assignment to deterministicEnable is a glitch that may or may not be visible to other processes.

Upvotes: 1

Matthew
Matthew

Reputation: 13977

It's wrong for synthesisable code. It's not wrong for your testbench.

Upvotes: 1

Related Questions