Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6542913
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:17:01+00:00 2026-05-25T11:17:01+00:00

what is the difference between this two code snippets? always @(posedge clk) begin r3

  • 0

what is the difference between this two code snippets?

    always @(posedge clk) begin
            r3 <= @(posedge clk) 1;
            r2 <= @(posedge clk) 1;
            ready = 0;
            while (r2 <= n) begin
                r2 <= @(posedge clk) r2 + 1;     <--- never stops executing
            end
    end


    always @(posedge clk) begin
            r3 <= @(posedge clk) 1;
            r2 <= @(posedge clk) 1;
            ready = 0;
            while (r2 <= n) begin
                @(posedge clk) r2 <= r2 + 1;     <--- normally executes
            end
    end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T11:17:01+00:00Added an answer on May 25, 2026 at 11:17 am

    When the simulator executes r2 <= @(posedge clk) r2 + 1, it performs the following steps:

    • evaluate r2 + 1
    • schedule a non-blocking assignment (NBA) update event to be executed at the next posedge clk

    When the simulator executes @(posedge clk) r2 <= r2 + 1, it performs the following steps:

    • suspend the always process and schedule it to resume at the next posedge clk
    • when the process resumes, execute the r2 <= r2 + 1 NBA, by doing the following:
      • evaluate r2 + 1
      • schedule an NBA update event for the current time

    The first form parses as a non-blocking assignment, and executes in zero time. The delay only applies to the update event generated when the NBA executes. The second form parses as a statement delay control followed by an NBA. It does not execute in zero time because the delay applies to the execution of the statement rather than just the update event.

    The first form is an infinite loop because the body of the while loop executes in zero time and the events that will increment r2 are scheduled for a future time.

    With the second form, you will still want to be careful about boundary conditions when the loop terminates. After scheduling an update that sets r2 to n + 1, the condition will evaluate as true one more time before that update is applied.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What is the difference between the two pieces of code below? This returns the
What is the difference between this two codes? class SomeClass { SomeType val =
Is there any essential difference between this code: ThreadStart starter = new ThreadStart(SomeMethod); starter.Invoke();
Is there a performance difference between the following two pieces of code? if (myCondition)
What is the difference between the two pieces of pseudo-code? // Multiplying a matrix
I'm having some trouble understanding the difference between these two code segments: I allocate
What is the difference between the two pieces of code below? Will there be
I am wanting to find the distance between two different points. This I know
What is the difference between this: this.btnOk.Click += new System.EventHandler(this.btnOK_Click); and this? this.btnOk.Click +=
what would be the difference between this class Class1 { public string prop1 {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.