data/full_repos/permissive/105948944/sources/currentSensing.v
1: b'%Error: data/full_repos/permissive/105948944/sources/currentSensing.v:76: Cannot find file containing module: \'signalSync\'\n    signalSync sync_currentOver0(\n    ^~~~~~~~~~\n        ... Looked in:\n             data/full_repos/permissive/105948944/sources,data/full_repos/permissive/105948944/signalSync\n             data/full_repos/permissive/105948944/sources,data/full_repos/permissive/105948944/signalSync.v\n             data/full_repos/permissive/105948944/sources,data/full_repos/permissive/105948944/signalSync.sv\n             signalSync\n             signalSync.v\n             signalSync.sv\n             obj_dir/signalSync\n             obj_dir/signalSync.v\n             obj_dir/signalSync.sv\n%Error: data/full_repos/permissive/105948944/sources/currentSensing.v:83: Cannot find file containing module: \'signalSync\'\n    signalSync sync_currentOver1(\n    ^~~~~~~~~~\n%Warning-WIDTH: data/full_repos/permissive/105948944/sources/currentSensing.v:124: Operator ASSIGNDLY expects 1 bits on the Assign RHS, but Assign RHS\'s CONST \'28\'h1e8480\' generates 28 bits.\n                                                                                 : ... In instance currentSensing\n                    max_current_period_reg <= 28\'d2000000;      \n                                           ^~\n                ... Use "/* verilator lint_off WIDTH */" and lint_on around source to disable this message.\n%Warning-WIDTH: data/full_repos/permissive/105948944/sources/currentSensing.v:126: Operator ASSIGNDLY expects 1 bits on the Assign RHS, but Assign RHS\'s CONST \'28\'h7a120\' generates 28 bits.\n                                                                                 : ... In instance currentSensing\n                    max_current_period_reg <= 28\'d500000;            \n                                           ^~\n%Warning-WIDTH: data/full_repos/permissive/105948944/sources/currentSensing.v:128: Operator GT expects 28 bits on the RHS, but RHS\'s VARREF \'max_current_period_reg\' generates 1 bits.\n                                                                                 : ... In instance currentSensing\n            if ( ( counter_currentOverlo_reg_0_0 > max_current_period_reg\n                                                 ^\n%Warning-WIDTH: data/full_repos/permissive/105948944/sources/currentSensing.v:129: Operator GT expects 28 bits on the RHS, but RHS\'s VARREF \'max_current_period_reg\' generates 1 bits.\n                                                                                 : ... In instance currentSensing\n                   || counter_currentOverlo_reg_0_1 > max_current_period_reg ) )begin\n                                                    ^\n%Error: data/full_repos/permissive/105948944/sources/currentSensing.v:142: Cannot find file containing module: \'counter_up\'\n    counter_up currentSens_counterUp(   \n    ^~~~~~~~~~\n%Error: Exiting due to 3 error(s), 4 warning(s)\n'
module currentSensing(
    input clock,
    input [1:0] currentSensA_B,
    input isTurning,
    output currentOverload
    

    );
    
    
    parameter [27:0] TENTH_of_PERIOD = 28'd1000000;
    
    parameter [27:0] PERIOD = ( TENTH_of_PERIOD << 3 ) + ( TENTH_of_PERIOD << 1);
    parameter [27:0] HALF_PERIOD = PERIOD >> 1;
    parameter [27:0]  QUARTER_PERIOD = PERIOD >> 2;
    parameter [27:0] t_13_PERC_PERIOD = PERIOD >> 2;
    
    parameter [27:0] T_2X_PERIOD = PERIOD << 1;
    parameter [27:0]  T_2X_and_HALF_PERIOD = T_2X_PERIOD + HALF_PERIOD;
    parameter [27:0] T_3X_PERIOD = PERIOD + T_2X_PERIOD;
    parameter [27:0] T_3X_and_HALF_PERIOD = T_3X_PERIOD + HALF_PERIOD;
    parameter [27:0] T_4X_PERIOD = PERIOD << 2;
    parameter [27:0] T_4X_and_QUARTER_PERIOD = T_4X_PERIOD + QUARTER_PERIOD;    
    parameter [27:0] T_5X_PERIOD = T_3X_PERIOD + T_2X_PERIOD;
    parameter [27:0] T_5X_AND_QUARTER_PERIOD = T_5X_PERIOD + QUARTER_PERIOD;
    parameter [27:0] T_5X_AND_HALF_PERIOD = T_5X_PERIOD + HALF_PERIOD;
    parameter [27:0] T_6X_PERIOD = T_3X_PERIOD << 2;
    parameter [27:0] T_7X_PERIOD = T_2X_PERIOD + T_5X_PERIOD;
    
    
    parameter MAX_CURRENT_PERIOD =  TENTH_of_PERIOD << 1;







    reg max_current_period_reg;
       
    reg [1:0] rebuiltSignal_reg;
    reg [27:0] rebuiltSignal_counter_reg;
    reg reset_counter_reg;
    wire [1:0] rising_edge_wire;
    wire [1:0] falling_edge_wire;
    
    reg [1:0] rebuild_Sense;
    
    reg [27:0] counter_currentOverlo_reg_0_0 = 0;
    reg [27:0] counter_currentOverlo_reg_0_1 = 0;
    
    reg currentOverloadOut = 0;
    wire [27:0] countedUpTo_wire;
    

    signalSync sync_currentOver0(
        .clock(clock),
        .asynchronous_signal(currentSensA_B[0]),
        .rising_edge(rising_edge_wire[0]),
        .falling_edge(falling_edge_wire[0])
    );
    
    signalSync sync_currentOver1(
        .clock(clock),
        .asynchronous_signal(currentSensA_B[1]),
        .rising_edge(rising_edge_wire[1]),
        .falling_edge(falling_edge_wire[1])
    );

    always@(posedge clock) begin
        if (rising_edge_wire[0])
            rebuild_Sense[0] <= 1;
        else if (falling_edge_wire[0])
            rebuild_Sense[0] <= 0;
        else
            rebuild_Sense[0] <= rebuild_Sense[0];
            
        if (rising_edge_wire[1])
            rebuild_Sense[1] <= 1;
        else if (falling_edge_wire[0])
            rebuild_Sense[1] <= 0;
        else
            rebuild_Sense[1] <= rebuild_Sense[1];
    end
    

    always@(negedge clock) begin
        if ( (countedUpTo_wire > 25 ) && (countedUpTo_wire < PERIOD ) ) begin
            if (rebuild_Sense[0])
                counter_currentOverlo_reg_0_0 <= counter_currentOverlo_reg_0_0 + 1;
            else begin
                counter_currentOverlo_reg_0_0 <= counter_currentOverlo_reg_0_0;
            end
            
            if (rebuild_Sense[1])
                counter_currentOverlo_reg_0_1 <= counter_currentOverlo_reg_0_1 + 1;
            else begin
                counter_currentOverlo_reg_0_1 <= counter_currentOverlo_reg_0_1;
            end
        end        
        else if ( (countedUpTo_wire > PERIOD ) && (countedUpTo_wire < (T_2X_PERIOD-500) ) ) begin
           ;
                 if (isTurning)
                    max_current_period_reg <= 28'd2000000;
                else
                    max_current_period_reg <= 28'd500000;
                 
            if ( ( counter_currentOverlo_reg_0_0 > max_current_period_reg
                   || counter_currentOverlo_reg_0_1 > max_current_period_reg ) )begin
                currentOverloadOut = 1'b1;
            end
            else
                currentOverloadOut = 1'b0;
        end
        else if (  (countedUpTo_wire > (T_2X_PERIOD-499) ) && ( countedUpTo_wire < T_2X_PERIOD ) ) begin
            counter_currentOverlo_reg_0_0 <= 0;
            counter_currentOverlo_reg_0_1 <= 0;
        end
    end
    

    counter_up currentSens_counterUp(
        .clock(clock), 
        .reset(1'b0),
        .counterPeriod(T_2X_PERIOD),
        .countedUpTo(countedUpTo_wire)
    );
    
    assign currentOverload = currentOverloadOut;
endmodule
module currentSensing(
    input clock,
    input [1:0] currentSensA_B,
    input isTurning,
    output currentOverload
    

    );

    
    
    parameter [27:0] TENTH_of_PERIOD = 28'd1000000;
    
    parameter [27:0] PERIOD = ( TENTH_of_PERIOD << 3 ) + ( TENTH_of_PERIOD << 1);
    parameter [27:0] HALF_PERIOD = PERIOD >> 1;
    parameter [27:0]  QUARTER_PERIOD = PERIOD >> 2;
    parameter [27:0] t_13_PERC_PERIOD = PERIOD >> 2;
    
    parameter [27:0] T_2X_PERIOD = PERIOD << 1;
    parameter [27:0]  T_2X_and_HALF_PERIOD = T_2X_PERIOD + HALF_PERIOD;
    parameter [27:0] T_3X_PERIOD = PERIOD + T_2X_PERIOD;
    parameter [27:0] T_3X_and_HALF_PERIOD = T_3X_PERIOD + HALF_PERIOD;
    parameter [27:0] T_4X_PERIOD = PERIOD << 2;
    parameter [27:0] T_4X_and_QUARTER_PERIOD = T_4X_PERIOD + QUARTER_PERIOD;    
    parameter [27:0] T_5X_PERIOD = T_3X_PERIOD + T_2X_PERIOD;
    parameter [27:0] T_5X_AND_QUARTER_PERIOD = T_5X_PERIOD + QUARTER_PERIOD;
    parameter [27:0] T_5X_AND_HALF_PERIOD = T_5X_PERIOD + HALF_PERIOD;
    parameter [27:0] T_6X_PERIOD = T_3X_PERIOD << 2;
    parameter [27:0] T_7X_PERIOD = T_2X_PERIOD + T_5X_PERIOD;
    
    
    parameter MAX_CURRENT_PERIOD =  TENTH_of_PERIOD << 1;







    reg max_current_period_reg;
       
    reg [1:0] rebuiltSignal_reg;
    reg [27:0] rebuiltSignal_counter_reg;
    reg reset_counter_reg;
    wire [1:0] rising_edge_wire;
    wire [1:0] falling_edge_wire;
    
    reg [1:0] rebuild_Sense;
    
    reg [27:0] counter_currentOverlo_reg_0_0 = 0;
    reg [27:0] counter_currentOverlo_reg_0_1 = 0;
    
    reg currentOverloadOut = 0;
    wire [27:0] countedUpTo_wire;
    

    signalSync sync_currentOver0(
        .clock(clock),
        .asynchronous_signal(currentSensA_B[0]),
        .rising_edge(rising_edge_wire[0]),
        .falling_edge(falling_edge_wire[0])
    );
    
    signalSync sync_currentOver1(
        .clock(clock),
        .asynchronous_signal(currentSensA_B[1]),
        .rising_edge(rising_edge_wire[1]),
        .falling_edge(falling_edge_wire[1])
    );

    always@(posedge clock) begin
        if (rising_edge_wire[0])
            rebuild_Sense[0] <= 1;
        else if (falling_edge_wire[0])
            rebuild_Sense[0] <= 0;
        else
            rebuild_Sense[0] <= rebuild_Sense[0];
            
        if (rising_edge_wire[1])
            rebuild_Sense[1] <= 1;
        else if (falling_edge_wire[0])
            rebuild_Sense[1] <= 0;
        else
            rebuild_Sense[1] <= rebuild_Sense[1];
    end
    

    always@(negedge clock) begin
        if ( (countedUpTo_wire > 25 ) && (countedUpTo_wire < PERIOD ) ) begin
            if (rebuild_Sense[0])
                counter_currentOverlo_reg_0_0 <= counter_currentOverlo_reg_0_0 + 1;
            else begin
                counter_currentOverlo_reg_0_0 <= counter_currentOverlo_reg_0_0;
            end
            
            if (rebuild_Sense[1])
                counter_currentOverlo_reg_0_1 <= counter_currentOverlo_reg_0_1 + 1;
            else begin
                counter_currentOverlo_reg_0_1 <= counter_currentOverlo_reg_0_1;
            end
        end        
        else if ( (countedUpTo_wire > PERIOD ) && (countedUpTo_wire < (T_2X_PERIOD-500) ) ) begin
           ;
                 if (isTurning)
                    max_current_period_reg <= 28'd2000000;
                else
                    max_current_period_reg <= 28'd500000;
                 
            if ( ( counter_currentOverlo_reg_0_0 > max_current_period_reg
                   || counter_currentOverlo_reg_0_1 > max_current_period_reg ) )begin
                currentOverloadOut = 1'b1;
            end
            else
                currentOverloadOut = 1'b0;
        end
        else if (  (countedUpTo_wire > (T_2X_PERIOD-499) ) && ( countedUpTo_wire < T_2X_PERIOD ) ) begin
            counter_currentOverlo_reg_0_0 <= 0;
            counter_currentOverlo_reg_0_1 <= 0;
        end
    end
    

    counter_up currentSens_counterUp(
        .clock(clock), 
        .reset(1'b0),
        .counterPeriod(T_2X_PERIOD),
        .countedUpTo(countedUpTo_wire)
    );
    
    assign currentOverload = currentOverloadOut;
endmodule