data/full_repos/permissive/172995952/src/Navigation_state_machine.v
data/verilator_xmls/01ac7e56-f1da-4253-a0eb-77642adef011.xml
module Navigation_state_machine(
                            input CLK,
                            input BTNR,
                            input BTNL,
                            input BTND,
                            input BTNU,
                            input RESET,
                            output [1:0] NAV_STATE
    );
    
    parameter UP = 2'd0;
    parameter LEFT = 2'd1;
    parameter RIGHT = 2'd2;
    parameter DOWN = 2'd3;
    
    reg [1:0] Curr_state;
    reg [1:0] Next_state;
            

    assign NAV_STATE = Curr_state;
    

            
    always@(posedge CLK or posedge RESET)
       begin
          if (RESET) 
               Curr_state <= 0;
          else 
               Curr_state <= Next_state;
       end
    

    always@(Curr_state or BTNL or BTNU or BTNR or BTND or RESET) begin
                     
               case (Curr_state)

                     UP    :begin
                         if (BTNL)
                               Next_state <= 2'd1;
                         else if (BTNR)
                               Next_state <= 2'd2;
                         else
                             Next_state <= Curr_state;
                         end

                     LEFT    :begin
                         if (BTNU)
                             Next_state <= 2'd0;
                         else if (BTND)
                             Next_state <= 2'd3;
                         else 
                             Next_state <= Curr_state; 
                     end

                     RIGHT    :begin
                         if (BTNU)
                             Next_state <= 2'd0;
                         else if (BTND)
                             Next_state <= 2'd3;
                         else
                             Next_state <= Curr_state;
                     end

                     DOWN    :begin
                         if (BTNL)
                             Next_state <= 2'd1;
                         else if (BTNR)
                             Next_state <= 2'd2;
                         else
                             Next_state <= Curr_state;
                         end
              endcase              
        end          
    
    
endmodule
module Navigation_state_machine(
                            input CLK,
                            input BTNR,
                            input BTNL,
                            input BTND,
                            input BTNU,
                            input RESET,
                            output [1:0] NAV_STATE
    );

    
    parameter UP = 2'd0;
    parameter LEFT = 2'd1;
    parameter RIGHT = 2'd2;
    parameter DOWN = 2'd3;
    
    reg [1:0] Curr_state;
    reg [1:0] Next_state;
            

    assign NAV_STATE = Curr_state;
    

            
    always@(posedge CLK or posedge RESET)
       begin
          if (RESET) 
               Curr_state <= 0;
          else 
               Curr_state <= Next_state;
       end
    

    always@(Curr_state or BTNL or BTNU or BTNR or BTND or RESET) begin
                     
               case (Curr_state)

                     UP    :begin
                         if (BTNL)
                               Next_state <= 2'd1;
                         else if (BTNR)
                               Next_state <= 2'd2;
                         else
                             Next_state <= Curr_state;
                         end

                     LEFT    :begin
                         if (BTNU)
                             Next_state <= 2'd0;
                         else if (BTND)
                             Next_state <= 2'd3;
                         else 
                             Next_state <= Curr_state; 
                     end

                     RIGHT    :begin
                         if (BTNU)
                             Next_state <= 2'd0;
                         else if (BTND)
                             Next_state <= 2'd3;
                         else
                             Next_state <= Curr_state;
                     end

                     DOWN    :begin
                         if (BTNL)
                             Next_state <= 2'd1;
                         else if (BTNR)
                             Next_state <= 2'd2;
                         else
                             Next_state <= Curr_state;
                         end
              endcase              
        end          
    
    
endmodule