data/full_repos/permissive/160437780/Source/color.v
1: b"%Error: data/full_repos/permissive/160437780/Source/color.v:42: Cannot find file containing module: 'FreqCounter'\n    FreqCounter freq(\n    ^~~~~~~~~~~\n        ... Looked in:\n             data/full_repos/permissive/160437780/Source,data/full_repos/permissive/160437780/FreqCounter\n             data/full_repos/permissive/160437780/Source,data/full_repos/permissive/160437780/FreqCounter.v\n             data/full_repos/permissive/160437780/Source,data/full_repos/permissive/160437780/FreqCounter.sv\n             FreqCounter\n             FreqCounter.v\n             FreqCounter.sv\n             obj_dir/FreqCounter\n             obj_dir/FreqCounter.v\n             obj_dir/FreqCounter.sv\n%Error: data/full_repos/permissive/160437780/Source/color.v:50: Cannot find file containing module: 'FreqDiv'\n    FreqDiv Div(\n    ^~~~~~~\n%Error: Exiting due to 2 error(s)\n"
module color(
    output reg Selector1,
    output reg Selector2,
    output reg [2:0] ColorOut,
    output reg TestDone,
    output reg [7:0] RedDiv,
    output reg [7:0] BlueDiv,
    output reg [7:0] GreenDiv,
    input clk,
    input Pulse,
    input Run
    );
    
    initial
    begin
    ColorOut = 0;
    Selector1 = 1;
    Selector2 = 0;
    TestDone = 0;
     RedDiv = 0;
     BlueDiv = 0;
     GreenDiv = 0;   
    end
    
    wire [9:0] FreqMod;
    reg [9:0] ClearFreq = 0;
    reg StartCount = 0;
    reg StartDiv = 0;
    wire DoneFreq;
    wire DivDone;
    reg [3:0] State = 4'b0000;
    wire [7:0] Perc;
    reg [1:0] RedCount = 0;
    reg [1:0] GreenCount = 0;
    reg [1:0] BlueCount = 0;
    reg [1:0] YellowCount = 0;
    reg [1:0] UnknownCount = 0;
    
    FreqCounter freq(
        .CLK(clk),
        .Pulse(Pulse),
        .Start(StartCount),
        .Freq(FreqMod),
        .Finished(DoneFreq)
    );
    
    FreqDiv Div(
        .clk(clk),
        .Freq(FreqMod),
        .Clear(ClearFreq),
        .Start(StartDiv),
        .Perc(Perc),
        .Done(DivDone)
    );
    
    always @ (posedge clk) 
    begin
        if (~Run)
        begin
            ColorOut <= 4;
            RedCount <= 0;
            RedDiv <= 0;
            BlueCount <= 0;
            BlueDiv <= 0;
            GreenCount <= 0;
            GreenDiv <= 0;
            YellowCount <= 0;
            UnknownCount <= 0;
            TestDone <= 0;
            Selector1 <= 1;
            Selector2 <= 0;
            State <= 4'b0000;
        end
        else
        begin
        case(State)
            4'b0000:
            begin
               StartCount <= 1;
               if (DoneFreq == 1)
               begin
                    ClearFreq <= FreqMod;
                    StartCount <= 0;
                    StartDiv <= 0;
                    State <= 4'b0001;
                    Selector1 <= 1;
                    Selector2 <= 1;
               end
            end
            4'b0001:
            begin
                if (DoneFreq == 0)
                    State <= 4'b0010;
            end            
            4'b0010:
            begin
               StartCount <= 1;
               if (DoneFreq == 1)
               begin
                    StartDiv <= 1;
                    if (DivDone == 1)
                    begin
                         GreenDiv <= Perc;
                         StartCount <= 0;
                         StartDiv <= 0;
                         State <= 4'b0011;
                         Selector1 <= 0;
                         Selector2 <= 1;
                    end
               end
            end
            4'b0011:
            begin
                if (DivDone == 0 && DoneFreq == 0)
                    State <= 4'b0100;
            end
            4'b0100:
            begin
               StartCount <= 1;
               if (DoneFreq == 1)
               begin
                    StartDiv <= 1;
                    if (DivDone == 1)
                    begin
                        BlueDiv <= Perc;
                        StartCount <= 0;
                        StartDiv <= 0;
                        State <= 4'b0101;
                        Selector1 <= 0;
                        Selector2 <= 0;
                    end
               end
            end
            4'b0101:
            begin
                if (DivDone == 0 && DoneFreq == 0)
                    State <= 4'b0110;
            end
            4'b0110:
            begin
               StartCount <= 1;
               if (DoneFreq == 1)
               begin
                   StartDiv <= 1;
                   if (DivDone == 1)
                   begin
                        RedDiv <= Perc;
                        StartCount <= 0;
                        StartDiv <= 0;
                        State <= 4'b0111;
                        Selector1 <= 1;
                        Selector2 <= 0;
                   end
               end
            end
             4'b0111:
            begin
                if (DivDone == 0 && DoneFreq == 0)
                    State <= 4'b1000;
            end
            4'b1000:
            begin
                if ((BlueDiv >= 35 && BlueDiv <= 37) && (GreenDiv >= 24 && GreenDiv <= 25) && (RedDiv >= 32 && RedDiv <= 37))
                begin
                    RedCount <= RedCount + 1;
                    State <= 4'b1001; 
                end
                else if ((BlueDiv >= 40 && BlueDiv <= 42) && (GreenDiv >= 25 && GreenDiv <= 27) && (RedDiv >= 25 && RedDiv <= 28))
                begin
                    BlueCount <= BlueCount + 1;
                    State <= 4'b1001; 
                end
                else if ((BlueDiv >= 37 && BlueDiv <= 39) && (GreenDiv >= 25 && GreenDiv <= 27) && (RedDiv >= 28 && RedDiv <= 30))
                begin
                    GreenCount <= GreenCount + 1;
                    State <= 4'b1001; 
                end
                else if ((BlueDiv >= 35 && BlueDiv <= 36) && (GreenDiv >= 27 && GreenDiv <= 28) && (RedDiv >= 31 && RedDiv <= 33))
                begin
                    YellowCount <= YellowCount + 1;
                    State <= 4'b1001; 
                end
                else
                begin
                    UnknownCount <= UnknownCount + 1;
                    State <= 4'b1001; 
                end
            end
            4'b1001:
            begin
                if (RedCount == 3)
                begin
                    ColorOut <= 0;
                    State <= 4'b1010;
                end
                else if (BlueCount == 3)
                begin
                    ColorOut <= 1;
                    State <= 4'b1010;
                end
                else if (GreenCount == 3)
                begin
                    ColorOut <= 2;
                    State <= 4'b1010;
                end
                else if (YellowCount == 3)
                begin
                    ColorOut <= 3;
                    State <= 4'b1010;
                end
                else if (UnknownCount == 3)
                begin
                    ColorOut <= 4;
                    State <= 4'b1010;
                end
                else
                begin
                    State <= 4'b0000;
                end
            end
            4'b1010:
            begin
                TestDone <= 1;
            end
         endcase
         end
    end   
endmodule
module color(
    output reg Selector1,
    output reg Selector2,
    output reg [2:0] ColorOut,
    output reg TestDone,
    output reg [7:0] RedDiv,
    output reg [7:0] BlueDiv,
    output reg [7:0] GreenDiv,
    input clk,
    input Pulse,
    input Run
    );

    
    initial
    begin
    ColorOut = 0;
    Selector1 = 1;
    Selector2 = 0;
    TestDone = 0;
     RedDiv = 0;
     BlueDiv = 0;
     GreenDiv = 0;   
    end
    
    wire [9:0] FreqMod;
    reg [9:0] ClearFreq = 0;
    reg StartCount = 0;
    reg StartDiv = 0;
    wire DoneFreq;
    wire DivDone;
    reg [3:0] State = 4'b0000;
    wire [7:0] Perc;
    reg [1:0] RedCount = 0;
    reg [1:0] GreenCount = 0;
    reg [1:0] BlueCount = 0;
    reg [1:0] YellowCount = 0;
    reg [1:0] UnknownCount = 0;
    
    FreqCounter freq(
        .CLK(clk),
        .Pulse(Pulse),
        .Start(StartCount),
        .Freq(FreqMod),
        .Finished(DoneFreq)
    );
    
    FreqDiv Div(
        .clk(clk),
        .Freq(FreqMod),
        .Clear(ClearFreq),
        .Start(StartDiv),
        .Perc(Perc),
        .Done(DivDone)
    );
    
    always @ (posedge clk) 
    begin
        if (~Run)
        begin
            ColorOut <= 4;
            RedCount <= 0;
            RedDiv <= 0;
            BlueCount <= 0;
            BlueDiv <= 0;
            GreenCount <= 0;
            GreenDiv <= 0;
            YellowCount <= 0;
            UnknownCount <= 0;
            TestDone <= 0;
            Selector1 <= 1;
            Selector2 <= 0;
            State <= 4'b0000;
        end
        else
        begin
        case(State)
            4'b0000:
            begin
               StartCount <= 1;
               if (DoneFreq == 1)
               begin
                    ClearFreq <= FreqMod;
                    StartCount <= 0;
                    StartDiv <= 0;
                    State <= 4'b0001;
                    Selector1 <= 1;
                    Selector2 <= 1;
               end
            end
            4'b0001:
            begin
                if (DoneFreq == 0)
                    State <= 4'b0010;
            end            
            4'b0010:
            begin
               StartCount <= 1;
               if (DoneFreq == 1)
               begin
                    StartDiv <= 1;
                    if (DivDone == 1)
                    begin
                         GreenDiv <= Perc;
                         StartCount <= 0;
                         StartDiv <= 0;
                         State <= 4'b0011;
                         Selector1 <= 0;
                         Selector2 <= 1;
                    end
               end
            end
            4'b0011:
            begin
                if (DivDone == 0 && DoneFreq == 0)
                    State <= 4'b0100;
            end
            4'b0100:
            begin
               StartCount <= 1;
               if (DoneFreq == 1)
               begin
                    StartDiv <= 1;
                    if (DivDone == 1)
                    begin
                        BlueDiv <= Perc;
                        StartCount <= 0;
                        StartDiv <= 0;
                        State <= 4'b0101;
                        Selector1 <= 0;
                        Selector2 <= 0;
                    end
               end
            end
            4'b0101:
            begin
                if (DivDone == 0 && DoneFreq == 0)
                    State <= 4'b0110;
            end
            4'b0110:
            begin
               StartCount <= 1;
               if (DoneFreq == 1)
               begin
                   StartDiv <= 1;
                   if (DivDone == 1)
                   begin
                        RedDiv <= Perc;
                        StartCount <= 0;
                        StartDiv <= 0;
                        State <= 4'b0111;
                        Selector1 <= 1;
                        Selector2 <= 0;
                   end
               end
            end
             4'b0111:
            begin
                if (DivDone == 0 && DoneFreq == 0)
                    State <= 4'b1000;
            end
            4'b1000:
            begin
                if ((BlueDiv >= 35 && BlueDiv <= 37) && (GreenDiv >= 24 && GreenDiv <= 25) && (RedDiv >= 32 && RedDiv <= 37))
                begin
                    RedCount <= RedCount + 1;
                    State <= 4'b1001; 
                end
                else if ((BlueDiv >= 40 && BlueDiv <= 42) && (GreenDiv >= 25 && GreenDiv <= 27) && (RedDiv >= 25 && RedDiv <= 28))
                begin
                    BlueCount <= BlueCount + 1;
                    State <= 4'b1001; 
                end
                else if ((BlueDiv >= 37 && BlueDiv <= 39) && (GreenDiv >= 25 && GreenDiv <= 27) && (RedDiv >= 28 && RedDiv <= 30))
                begin
                    GreenCount <= GreenCount + 1;
                    State <= 4'b1001; 
                end
                else if ((BlueDiv >= 35 && BlueDiv <= 36) && (GreenDiv >= 27 && GreenDiv <= 28) && (RedDiv >= 31 && RedDiv <= 33))
                begin
                    YellowCount <= YellowCount + 1;
                    State <= 4'b1001; 
                end
                else
                begin
                    UnknownCount <= UnknownCount + 1;
                    State <= 4'b1001; 
                end
            end
            4'b1001:
            begin
                if (RedCount == 3)
                begin
                    ColorOut <= 0;
                    State <= 4'b1010;
                end
                else if (BlueCount == 3)
                begin
                    ColorOut <= 1;
                    State <= 4'b1010;
                end
                else if (GreenCount == 3)
                begin
                    ColorOut <= 2;
                    State <= 4'b1010;
                end
                else if (YellowCount == 3)
                begin
                    ColorOut <= 3;
                    State <= 4'b1010;
                end
                else if (UnknownCount == 3)
                begin
                    ColorOut <= 4;
                    State <= 4'b1010;
                end
                else
                begin
                    State <= 4'b0000;
                end
            end
            4'b1010:
            begin
                TestDone <= 1;
            end
         endcase
         end
    end   
endmodule