0

I'm trying to implement the following code:

reg [7:0] next_busy;

always @* begin
    next_busy = busy; //default assignment

    if (condition determined by module input) begin
        next_busy[0]= 1'b1;
    end
end //always @*

always @(posedge clock) begin
    if (reset) begin
        busy <= 8'b0;
    end else begin
        busy <= next_busy;
    end
end //always @(posedge clock)

This works fine in simulation, but in synthesis there seems to be some sort of contention for the next_busy signal. That is, if busy isn't 1 (say the previous cycle had a reset), then it outputs an x (if input conditions are met). However, if busy was already 1 (and the input conditions are met), then next_busy gets assigned 1 correctly. So I'm just wondering is there a proper way of doing what I'm trying to do so that it also works in synthesis?

1
  • Your code looks fine to me. Where are you seeing the contention, in gate-level simulation? Are you assigning to next_busy anywhere else in that module? Are there any warning messages in the synthesis log that mention that signal.
    – Marty
    Oct 30, 2012 at 17:34

1 Answer 1

0

You typically include the reset in a sensitivity list for flip-flops. For active low resets always @(posedge clock or negedge reset)

In the example provided busy is not defined, assuming it is reg [7:0] busy;.

I would implement along the lines of:

reg [7:0] busy;

always @(posedge clock or negedge reset) begin
    if (reset == 1'b0) begin
        busy    <= 8'b0;
    end
    else if (condition determined by module input) begin
        busy[0] <= 1'b1; // busy <= 8'b1;
    end
    else begin
        busy    <= next_busy;
    end
end //always @(posedge clock)
2
  • The op might want synchronous resets?
    – Marty
    Oct 30, 2012 at 17:37
  • They might, but I would always include a reset for initialisation as well.
    – Morgan
    Oct 30, 2012 at 18:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.