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 1062909
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:42:11+00:00 2026-05-16T18:42:11+00:00

The following is some modelsim code: begin tb_in_top = 0; #5 tb_in_top = 4’b0000;#5

  • 0

The following is some modelsim code:

 begin
    tb_in_top = 0;
    #5 tb_in_top = 4'b0000;#5 tb_in_top = 4'b0001;
    #5 tb_in_top = 4'b0010;#5 tb_in_top = 4'b0011;
    #5 tb_in_top = 4'b0100;#5 tb_in_top = 4'b0101;
    #5 tb_in_top = 4'b0110;#5 tb_in_top = 4'b0111;
    #5 tb_in_top = 4'b1000;#5 tb_in_top = 4'b1001;
    #5 tb_in_top = 4'b1010;#5 tb_in_top = 4'b1011;
    #5 tb_in_top = 4'b1100;#5 tb_in_top = 4'b1101;
    #5 tb_in_top = 4'b1110;#5 tb_in_top = 4'b1111;
    #100 $finish;
  end

What does the #5 and #100 represent? Are those line numbers? Is there something wrong with this code?

  • 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-16T18:42:12+00:00Added an answer on May 16, 2026 at 6:42 pm

    It’s not "ModelSim" code any more than something is "Visual Studio" code. It’s Verilog.

    The # token signifies a delay in nanoseconds.

    So what this code means is:

    • At t = 0, set tb_in_top to all 0’s.
    • At t = 5 ns, set tb_in_top to the 4-bit binary value 0000.
    • At t = 10 ns, set tb_in_top to the 4-bit binary value 0001.
    • At t = 15 ns, set tb_in_top to the 4-bit binary value 0010.
    • At t = 20 ns, set tb_in_top to the 4-bit binary value 0011.

    (… keep counting up, incrementing tb_in_top by 1 every 5 ns …)

    • At t = 80 ns, set tb_in_top to the 4-bit binary value 1111.
    • At t = 180 ns, end the simulation.

    Yes, Verilog has for loops, and yes, that should be one.

    Addendum

    The for loop would look like:

    integer index;
    reg [3:0] tb_in_top;
    begin
        tb_in_top = 0;
        for(index = 0; index < 16; index = index + 1)
        begin
            #5 tb_in_top = tb_in_top + 4'h1;
        end
        #100 $finish;
    end
    

    Finally, note that Verilog that uses the # time-delay operation cannot be synthesized to logic; it can only be used for simulation.

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

Sidebar

Related Questions

How can I response a 403 status code? I was following some example which
I have some code that does the following: while(some condition) { char *line[WORDLEN]; //do
I am a newcomer to Silverlight and while I have been following some tutorials
I'm doing some research on multicore processors; specifically I'm looking at writing code for
I am using a large list of variables inside some definitions and classes (mainly
The learning curve for iPhone development has been less steep than I expected. After
I started creating JPA/hibernate mappings for a legacy database based on Oracle. At one
Last couple of months I've been wondering about all these password strength meters on
I have an array, $scans. I want to query MySQL with all the values

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.