0
\$\begingroup\$

Can't Resolve Multiple Constant Driver

Error (10028): Can't resolve multiple constant drivers for net "NumOfPixCF[31]" at Pixel_Tracking.v(30)

Error (10028): Can't resolve multiple constant drivers for net "NumOfPixCF[30]" at Pixel_Tracking.v(30)

Error (10028): Can't resolve multiple constant drivers for net "NumOfPixCF[29]" at Pixel_Tracking.v(30)

And so on.

Anyone knows how to solve this? I'm an amateur in Verilog coding.

module Pixel_Tracking(
    input[15:0] r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,
    input start,
    input clk,rst,
    output reg[5:0] Object_Shift=0
);

    reg[15:0] R1,R2,R3,R4,R5,R6,R7,R8,R9,R10;
    integer i=0;

    integer NumOfPixCF=0,NumOfPixNF=0;
    integer reposition = 0;
    reg[15:0] AreaCF = 0,AreaNF = 0;


    always@(posedge clk )
    begin
        if(rst)
            begin
                reposition <= 0;
                Object_Shift <= 0;
            end
        else
            begin
                for(i=0;i<=15;i=i+1)
                    begin
                        NumOfPixCF = NumOfPixCF + R1[i] + R2[i] + R3[i] + R4[i] + R5[i] + R6[i] + R7[i] + R8[i] + R9[i] + R10[i];
                        NumOfPixNF = NumOfPixNF + r1[i] + r2[i] + r3[i] + r4[i] + r5[i] + r6[i] + r7[i] + r8[i] + r9[i] + r10[i];
                    end
                if(NumOfPixCF > NumOfPixNF)
                    begin
                        Object_Shift <= 6'b000100; //Object moved away
                    end
                else if(NumOfPixCF < NumOfPixNF)
                    begin
                        Object_Shift <= 6'b001000; //Object moved forward
                    end
                else
                    begin
                        AreaCF = AreaCF + R1 + R2 + R3 + R4 + R5 + R6 + R7 + R8 + R9 + R10;
                        AreaNF = AreaNF + r1 + r2 + r3 + r4 + r5 + r6 + r7 + r8 + r9 + r10;
                        if(AreaCF < AreaNF) //Object moved to the right
                            begin
                                Object_Shift <= 6'b000010;
                                //reposition <= 1;
                            end
                        else if(AreaCF > AreaNF) //Object moved to the left
                            begin
                                Object_Shift <= 6'b000001;
                                //reposition <= 1;
                            end
                        else //Object did not move
                            begin
                                Object_Shift <= 6'b000000;
                            end
                    end
            end
        reposition <= ~reposition;
    end

    always@(reposition,start)
    begin
        if(start == 1)
            begin
                R1 <= r1;
                R2 <= r2;
                R3 <= r3;
                R4 <= r4;
                R5 <= r5;
                R6 <= r6;
                R7 <= r7;
                R8 <= r8;
                R9 <= r9;
                R10 <= r10;
            end

        if(reposition == -1)
            begin
                NumOfPixCF <= 0;
                NumOfPixNF <= 0;
                AreaCF <= 0;
                AreaNF <= 0;
            end
    end
endmodule
\$\endgroup\$
5
  • \$\begingroup\$ Did you do a search for "multiple constant drivers " drivers? I get 81 hits. Some are for VHDL but the cause of the error is the same in both languages. If you use "multiple constant drivers verilog" you get 7 hits. \$\endgroup\$
    – Oldfart
    Dec 19 '18 at 16:05
  • \$\begingroup\$ I'm not really knowledged at verilog but you're writing the NumOfPix from several combinational always blocks, I think you should avoid that. \$\endgroup\$
    – po.pe
    Dec 19 '18 at 16:07
  • \$\begingroup\$ Thanks for the answer but I've solved the issue. \$\endgroup\$
    – Andy Chang
    Dec 19 '18 at 16:11
  • \$\begingroup\$ Could you indent your code so it's reasonable to read? \$\endgroup\$
    – The Photon
    Dec 19 '18 at 16:25
  • \$\begingroup\$ You can post your answer for posterity sake, but, I think it is because you drive that signal in two places when reposition = -1(?) depending on what you are trying to accomplish, you could put the earlier drive in the else condition of your if... and, don't mix blocking and non-blocking when you do it. \$\endgroup\$
    – CapnJJ
    Dec 19 '18 at 17:04
0
\$\begingroup\$

How this should work? What do you mean?

        for(i=0;i<=15;i=i+1)
            begin
                NumOfPixCF = NumOfPixCF + R1[i] + R2[i] + R3[i] + R4[i] + R5[i] + R6[i] + R7[i] + R8[i] + R9[i] + R10[i];
                NumOfPixNF = NumOfPixNF + r1[i] + r2[i] + r3[i] + r4[i] + r5[i] + r6[i] + r7[i] + r8[i] + r9[i] + r10[i];
            end

Why are you using reposition and start in always?

always@(reposition,start) // ???
begin
    if(start == 1)
        begin
\$\endgroup\$

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