Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
12 years ago

multiple constant drivers for net erro

Hi,

I have this code

reg signed  final_additions ;  // two multiply results added together and registered
reg signed  final_result;  // sum of final_additions
wire signed  final_result_temp;
wire signed  coefficients ;     
 
genvar Counter_Result;
                generate
                for(Counter_Result = 0; Counter_Result < ((NUM_OF_TAPS/4)-1); Counter_Result=Counter_Result+1)
                begin : the_final_reult
                                always @ (posedge clk or posedge reset)
                                begin
                                                if (reset)
                                                begin
                                                                final_result_temp<= 0;
                                                end
                                                else if (clear == 1)
                                                begin
                                                                final_result_temp <= 0;
                                                end
                                                if (Counter_Result == 0)
                                                begin
                                                                final_result_temp <= final_additions;
                                                end
                                                else
                                                begin
                                                                final_result_temp <= final_result_temp+final_additions;
                                                end
                                end
                end
                endgenerate
                always @ (posedge clk or posedge reset)
                begin
                                if (reset)
                                begin
                                                final_result <= 0;
                                end
                                else if (clear == 1)
                                begin
                                                final_result <= 0;
                                end
                                else
                                begin
                                                final_result <= final_result_temp;
                                end
                end

When i launch the compilation i get this error:

Error (10028): Can't resolve multiple constant drivers for net "final_result[33]" at custom_FIR.v(255).

How can i correct this erros.

Thank you

16 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Lets me show a code that's work may be can help you to locate the probleme:

    generate
            if(NUM_OF_TAPS == 4)
                assign final_result_temp = final_additions;
            else if (NUM_OF_TAPS == 8)
                assign final_result_temp = final_additions + final_additions;
            else if (NUM_OF_TAPS == 16)
                assign final_result_temp = final_additions + final_additions + final_additions + final_additions;
        endgenerate  // after 16 taps this should addition should be done with registered stages
        
        always @ (posedge clk or posedge reset)
        begin
            if (reset)
            begin
                final_result <= 0;
            end
            else if (clear == 1)
            begin
                final_result <= 0;
            end
            else
            begin
                final_result <= final_result_temp;
            end
        end

    This code it work very well. The change that i need is to calculate the final_result_temp result using a genereic code. That's mean avoid the using of the if statement.

    I hope that this code is more comprehensible.

    Thanks
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    so basically you want to add in that order:

    taps = 4, add [0] only

    taps = 8, add [0] +[1]

    taps = 16, add [0]+[1]+[2]+[3]...etc

    but your first generate statement is not doing that.

    I suggest you run a hardware counter as integer say from 0 to taps/4-1 and so it adjusts to number of taps. Then set your logic such that count is used as index.

    that is something like this: sum <= sum+addition(count);

    thus the feedback loop will take care of it as the counter runs.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    see my edit. eventually your first loop counter is ok but you need to run counter in the design. so your final code was in the right direction i.e. the one you added counter in the logic.

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Thank you very much Kaz, it work now, i will check the result tomorrow on the board.

    Thanks
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    When i add a counter, i get same error related to the count.

    --- Quote End ---

    and where is the proof. show us your latest code showing error and what does error say.