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

  • Home
  • SEARCH
  • 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 6708915
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:49:03+00:00 2026-05-26T07:49:03+00:00

In my bench program, I have something like this (simplified): // bench.sv program tb

  • 0

In my bench program, I have something like this (simplified):

// bench.sv
program tb (input clk, ...);
  initial begin
    ...
    repeat (100) begin
      main_module_interface.write_index <= bench.write_index;
      // drive additional inputs
      ...

      @(clk);

      $display("%t : BENCH", $realtime);

In my main module, I have a generate loop to create my index_reg modules

// main_module.sv
generate
  for (genvar ix = 0; ix < 32; ix++) begin
    index_reg #(.WIDTH(32), .INDEX(ix)) r (
      .clk,
      .ind(writeIFC.write_index),
      ...
    );
  end
endgenerate

Then in my index_reg module, I have added the following debug code:

// index_reg.sv
always @ (posedge clk) begin
  if (INDEX == 10) begin
    $display("I see the clock");
  end
end

I would expect to see this output:

I see the clock
10 : BENCH
I see the clock
20 : BENCH
I see the clock
30 : BENCH
I see the clock
40 : BENCH
I see the clock
50 : BENCH
etc.

But sometimes, the "I see the clock" only shows up every other time. So I see

10 : BENCH
I see the clock
20 : BENCH
30 : BENCH
I see the clock
40 : BENCH
50 : BENCH
etc.

I can’t understand why that might happen. Can someone please point me in the right direction?

  • 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-26T07:49:04+00:00Added an answer on May 26, 2026 at 7:49 am

    Without seeing more of the code, here is my best guess.

    @(clk);
    

    That code is triggered on every clk edge, both posedge and negedge.

    always @ (posedge clk) begin
    

    That code is only triggered on posedge of clk, which is every other time.

    That may be why you see BENCH twice as often as I see the clock.

    If that doesn’t answer your question, provide a complete code example that anyone can compile and run.

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

Sidebar

Related Questions

The classical C program is something like: int main() { fprintf(stderr, hello world\n); }
I have a bunch of PDF files and my Perl program needs to do
I have been working on a childish little program: there are a bunch of
I'd like to use the Object Test Bench in VS2008. The docs - and
I have some .csv files which I'm using as part of a test bench.
In reference to this answer to a Stack Overflow question : what is bench-testing
My Python script (for todo lists) is started from the command line like this:
For about a year I have been thinking about writing a program that writes
I have NSUserDefaults storing a number of string variables for things like name, date
I have to automate a program that is outside of my control. The way

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.