Jump to content

Register backdoor write getting overwritten at next clock edge


Recommended Posts

Backdoor write value deposited on the register variable appears to get overwritten on the next clock edge. See code below. If I move the write conditional into the always_ff block the backdoor access sticks. Where in the time slot does the backdoor DPI call get executed: prepone, observe, re-nba or postpone?

always_ff @(posedge clk) begin

reg_name <= reg_name_next;

end

always_comb begin

reg_name_next = reg_name;

if (write)

reg_name_next = write_data;

end

Link to comment
Share on other sites

The DPI gets called by the thread that calls the write() method and thus executes in the same region. And since it is a simple immediate variable assignment, it will get overwritten should/when other threads assign a different value.

What you have here is a classic race condition...

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...