0
votes

What is the difference between:

1

forever begin
    **@posedge(clk) begin**
        if(vif.sof == 1) begin
             //some code here
        end
    end
 end

2

forever begin
    **@posedge(clk);**
        if(vif.sof == 1) begin
           //some code here
        end
end

Does the begin..end that goes with @(posedge clk) make a difference ?

1

1 Answers

1
votes

event_controls like @ and # in procedural code are not statement by themselves; they are prefixes to the statements that follow. And a statement can be a simple statement, like an assignment, or a block like begin/end or fork/join. And a block is allowed wherever a single statement is allowed.

When you write @(posedge clk); it is really @(posedge clk) null_statement;

I should have given you enough information to answer your question, but here is another variation:

forever 
        @posedge(clk)
        if(vif.sof == 1) begin
           //some code here
        end

Now there is a big difference if a semicolon follows @(posedge clk) or not.