2
\$\begingroup\$

I have not across the statement @(posedge clk) before. I would like to know how this statement is different from the always @(posedge clk) block which I am familiar with.

If I use a sensitivity list in a task for a Finite State Machine synthesis without always block; How is this different from a task with always block and sensitivity list?

As I understand both @ and always @ have the same functionality as both of them are always sensitive to the changes in the sensitivity list. Are there any differences with respect to simulation or synthesis?

asked May 30, 2020 at 13:10
\$\endgroup\$

1 Answer 1

3
\$\begingroup\$

The always @(posedge clk) statement is actually a combination of two statements:

The always procedural block:

always ... begin
 //Body of 'always' block
end

And a sensitivity list:

@(posedge clk) - At the positive edge of clk
@(signal or signal) - Any change in listed signals
@* - Any change to any signal used as an input to the block

When using Verilog for testbenches/simulation (this is not just SystemVerilog behaviour), you can use the always block on its own, for example

always begin
 #5 clk = !clk; //Create a clock of period 10 units
end

You can also use the sensitivity list on its own, in the form of a Procedural Timing Control:

initial begin
 @(posedge clk); //Wait for a pos-edge of the clock
 reset = 1; //Assert reset
 repeat(2) @(posedge clk); //Wait for two pos-edge of clock
 reset = 0; /Adeassert reset
end

Essentially this allows you to perform a sequence of test events based on say, a clock edge.


As far as I'm aware you can't use the procedural timing control for synthesis - instead a state machine or similar would be built within an edge sensitive always block.

answered May 30, 2020 at 13:48
\$\endgroup\$
0

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.