data/full_repos/permissive/469509877/rtl/GapStateMachineLogic.v
data/verilator_xmls/6465671c-193f-4635-8025-f0735ffd2095.xml
module GapStateMachineLogic(
    input btnUDLR,
    input btnC,
    input GapWallDetect,
    input SlugRedDetect,
    input [3:0] Q,
    
    output load,
    output reset,
    output dir1,
    output dir2,
    output flash,
    output [3:0] D 
    );
    
    assign D[0] = (btnC) | (Q[0] & ~btnUDLR & ~btnC) | (Q[0] & btnUDLR & ~btnC  & SlugRedDetect);
    assign D[1] = (Q[0] & btnUDLR & ~btnC & ~SlugRedDetect) | (Q[1] & ~btnC & ~GapWallDetect & ~SlugRedDetect) | (Q[2] & ~btnC & GapWallDetect & ~SlugRedDetect);
    assign D[2] = (Q[1] & ~btnC & GapWallDetect & ~SlugRedDetect) | (Q[2] & ~btnC & ~GapWallDetect & ~SlugRedDetect);
    assign D[3] = ((Q[1] | Q[2]) & ~btnUDLR & ~btnC & SlugRedDetect) | ((Q[1] | Q[2]) & btnUDLR & ~btnC & SlugRedDetect) |   
                  (Q[3] & ~btnC);
        
    assign reset = btnC;
    assign load = (Q[0] & btnUDLR);
    assign dir1 = Q[1] & ~Q[3];
    assign dir2 = Q[2] & ~Q[3];
    assign flash = Q[3];
    
    
endmodule
module GapStateMachineLogic(
    input btnUDLR,
    input btnC,
    input GapWallDetect,
    input SlugRedDetect,
    input [3:0] Q,
    
    output load,
    output reset,
    output dir1,
    output dir2,
    output flash,
    output [3:0] D 
    );

    
    assign D[0] = (btnC) | (Q[0] & ~btnUDLR & ~btnC) | (Q[0] & btnUDLR & ~btnC  & SlugRedDetect);
    assign D[1] = (Q[0] & btnUDLR & ~btnC & ~SlugRedDetect) | (Q[1] & ~btnC & ~GapWallDetect & ~SlugRedDetect) | (Q[2] & ~btnC & GapWallDetect & ~SlugRedDetect);
    assign D[2] = (Q[1] & ~btnC & GapWallDetect & ~SlugRedDetect) | (Q[2] & ~btnC & ~GapWallDetect & ~SlugRedDetect);
    assign D[3] = ((Q[1] | Q[2]) & ~btnUDLR & ~btnC & SlugRedDetect) | ((Q[1] | Q[2]) & btnUDLR & ~btnC & SlugRedDetect) |   
                  (Q[3] & ~btnC);
        
    assign reset = btnC;
    assign load = (Q[0] & btnUDLR);
    assign dir1 = Q[1] & ~Q[3];
    assign dir2 = Q[2] & ~Q[3];
    assign flash = Q[3];
    
    
endmodule