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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T19:02:00+00:00 2026-05-14T19:02:00+00:00

I have the code module below always @(posedge Clk) begin ForwardA = 0; ForwardB

  • 0

I have the code module below

always @(posedge Clk) begin

ForwardA = 0;
ForwardB = 0;

//EX Hazard
if (EXMEMRegWrite == 1) begin
 if (EXMEMrd != 0)
    if (EXMEMrd == IDEXrs)
        ForwardA = 2'b10;
   if (EXMEMrd == IDEXrt && IDEXTest == 0)
        ForwardB = 2'b10;
end


//MEM Hazard

if (MEMWBRegWrite == 1) begin
 if (MEMWBrd != 0) begin
    if (!(EXMEMRegWrite == 1 && EXMEMrd != 0 && (EXMEMrd == IDEXrs)))
            if (MEMWBrd == IDEXrs)
                ForwardA = 2'b01;
    if (IDEXTest == 0) begin
        if (!(EXMEMRegWrite == 1 && EXMEMrd != 0 && (EXMEMrd == IDEXrt)))
            if (MEMWBrd == IDEXrt)
                ForwardB = 2'b01;
    end
 end
end

end

The problem is that the output, which is ForwardA and ForwardB is not updated not on the rising clock edge rather than on the next rising clock edge… why is this?? How do I resolve so that the output is updated on the same positive rising clock edge?

Here’s what I mean:
alt text http://img693.imageshack.us/img693/8660/timing.jpg

ForwardA is updated with 2 on the next rising clock edge and not on the same rising clock edge

  • 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-14T19:02:01+00:00Added an answer on May 14, 2026 at 7:02 pm

    I’d expect this operation. It’s all to do with how your input signals, MEMWBRegWrite etc., are being driven. You have to remember that if you launch something from a clock, then other clocked blocks won’t see it until the next clock edge, even though things may look coincident in your waveform viewer.

    It’s helpful to think of the reality of what’s happening. Once you launch something from a clock edge, this can’t happen right away, there’ll be a small delay. You won’t see these small delays in RTL sim waveforms, but they are there in the form of delta cycles.

            1             2             3
             ______        ______
    clk   __|      |______|      |______|
    
     q   ----<======A======X=======B======X====
    
     n1  -----<====A+1======X======B+1=====X=====        (combinatorial/logic)
     n2  ------------------X======A+1=====X=====B+1      (sequential/clocked)
    

    If you look at my quite brillant ascii art above, q is being set to ‘B’ on clock edge 2, but it takes time for this to propagate. Any @(posedge clk) blocks will see a value of ‘A’ for q on clock edge 2, it won’t see ‘B’ until the next edge, 3. Which is what it looks like you’re seeing.

    You can generate a signal almost straight away though, if that’s what you need. But to do this you’ll need to use combinatorial logic (n1 above).

     wire n1;
     assign n1 = q + 1;
    

    or

     reg n1;
     always @(*)
         n1 = q + 1;
    

    Using sequential logic (as you are):

     reg n2;
     always @(posedge clk)
         n2 <= q + 1;
    

    Note the ‘<=’. This is a nonblocking assignment – its recommended to use this for assigning to things you’ll want to be registers or flops in your design. Look at the Sunburst Design papers for a far better explaination.

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

Sidebar

Ask A Question

Stats

  • Questions 407k
  • Answers 408k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer This article explain how to use embedded resources in C#.… May 15, 2026 at 6:39 am
  • Editorial Team
    Editorial Team added an answer As far as I can remember (last time I tried,… May 15, 2026 at 6:39 am
  • Editorial Team
    Editorial Team added an answer One way (of many) to do this is to open… May 15, 2026 at 6:39 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.