In reply to Rahulvala:
In reply to Aman551:
There are two ways to do it.
first by using always_ff block:
always_ff @(posedge clk) begin
// Your code here
end
second using forever block :
forever begin
wait(clk == 1'b1);
// Your code here
end
These generative answers from Rahulvala contain a lot of incorrect information and will be removed. always_ff is not an answer to the question. And the forever loop will hang the simulation once the clock becomes 1.
wait() is a level sensitive construct. If you want to wait for an edge, you need two of them in a sequence.
wait(clk==0) wait(clk==1)
This is close to what @(posedge clk) without handling X states.