data/full_repos/permissive/449142214/Project files/Railway_cart_FSM.v
1: b'%Error: Cannot find file containing module: files,data/full_repos/permissive/449142214\n        ... Looked in:\n             data/full_repos/permissive/449142214/Project/files,data/full_repos/permissive/449142214\n             data/full_repos/permissive/449142214/Project/files,data/full_repos/permissive/449142214.v\n             data/full_repos/permissive/449142214/Project/files,data/full_repos/permissive/449142214.sv\n             files,data/full_repos/permissive/449142214\n             files,data/full_repos/permissive/449142214.v\n             files,data/full_repos/permissive/449142214.sv\n             obj_dir/files,data/full_repos/permissive/449142214\n             obj_dir/files,data/full_repos/permissive/449142214.v\n             obj_dir/files,data/full_repos/permissive/449142214.sv\n%Error: Cannot find file containing module: data/full_repos/permissive/449142214/Project\n%Error: Cannot find file containing module: files/Railway_cart_FSM.v\n%Error: Exiting due to 3 error(s)\n'
module Railway_cart_FSM(RIGHT,LEFT,DIR,AUTO,CLK,RESET,POS);

input RIGHT,LEFT,DIR,AUTO,CLK,RESET;
output reg [7:0]POS;


parameter SSTART = 3'b000, SRIGHT = 3'b001, SLEFT = 3'b010, SMOV_RIGHT = 3'b100, SMOV_LEFT = 3'b101; 
reg [2:0] present_state,next_state;


always @ (posedge CLK,posedge RESET)
begin
    if(RESET == 1) 
        begin
        present_state = SSTART;
        POS = 8'b1100_0000;
        end
    else begin
            present_state = next_state;
            if(next_state == SMOV_RIGHT && POS != 8'b0000_0011) POS = POS >> 1;
            else if (next_state == SMOV_LEFT && POS != 8'b1100_0000) POS = POS << 1;
            else POS = POS;
    end
end    

always @ (present_state,RIGHT,LEFT,DIR)
begin
    case(present_state)
    SSTART: if (DIR == 0 && AUTO == 0)
            next_state = (RIGHT == 1)? SRIGHT : (LEFT == 1)? SLEFT : SSTART;
            else if (DIR == 0 && AUTO == 1)                                     
            next_state = SRIGHT;
            else if (DIR == 1 && AUTO == 0)                                    
            next_state = (RIGHT == 1)? SRIGHT : (LEFT == 1)? SLEFT : SSTART;
            else if (DIR == 1 && AUTO == 1)                                     
            next_state = SLEFT;
    SRIGHT: if (DIR == 0 && AUTO == 0)
            next_state = (RIGHT == 1)? SSTART : (LEFT == 1)? SMOV_RIGHT : SRIGHT;
            else if (DIR == 0 && AUTO == 1)                                         
            next_state =  SMOV_RIGHT;
            else if (DIR == 1 && AUTO == 0)                                       
            next_state = (RIGHT == 1)? SSTART : (LEFT == 1)? SLEFT : SRIGHT;
            else if (DIR == 1 && AUTO == 1)                                      
            next_state = SLEFT;
    SLEFT: if (DIR == 0 && AUTO == 0)
            next_state = (RIGHT == 1)? SRIGHT : (LEFT == 1)? SSTART : SLEFT;
            else if (DIR == 0 && AUTO == 1)                                    
            next_state = SRIGHT;
            else if (DIR == 1 && AUTO == 0)
            next_state = (RIGHT == 1)? SMOV_LEFT : (LEFT == 1)? SSTART : SLEFT;
            else if (DIR == 1 && AUTO == 1)
            next_state = SMOV_LEFT;
    SMOV_RIGHT: 
            if (DIR == 0 && AUTO == 0)
            next_state = (RIGHT == 1)? SRIGHT : (LEFT == 1)? SLEFT : SMOV_RIGHT;
            else if (DIR == 0 && AUTO == 1)
            next_state = SRIGHT;
            else if (DIR == 1 && AUTO == 0)
            next_state = (RIGHT == 1)? SRIGHT : (LEFT == 1)? SLEFT : SMOV_RIGHT;
            else if (DIR == 1 && AUTO == 1)
            next_state = SLEFT;
    SMOV_LEFT: if (DIR == 0 && AUTO == 0)
            next_state = (RIGHT == 1)? SRIGHT : (LEFT == 1)? SLEFT : SMOV_LEFT;
            else if (DIR == 0 && AUTO == 1)
            next_state = SRIGHT;
            else if (DIR == 1 && AUTO == 0)
            next_state = (RIGHT == 1)? SRIGHT : (LEFT == 1)? SLEFT : SMOV_LEFT;
            else if (DIR == 1 && AUTO == 1)
            next_state = SLEFT;
    endcase
end

endmodule
module Railway_cart_FSM(RIGHT,LEFT,DIR,AUTO,CLK,RESET,POS);


input RIGHT,LEFT,DIR,AUTO,CLK,RESET;
output reg [7:0]POS;


parameter SSTART = 3'b000, SRIGHT = 3'b001, SLEFT = 3'b010, SMOV_RIGHT = 3'b100, SMOV_LEFT = 3'b101; 
reg [2:0] present_state,next_state;


always @ (posedge CLK,posedge RESET)
begin
    if(RESET == 1) 
        begin
        present_state = SSTART;
        POS = 8'b1100_0000;
        end
    else begin
            present_state = next_state;
            if(next_state == SMOV_RIGHT && POS != 8'b0000_0011) POS = POS >> 1;
            else if (next_state == SMOV_LEFT && POS != 8'b1100_0000) POS = POS << 1;
            else POS = POS;
    end
end    

always @ (present_state,RIGHT,LEFT,DIR)
begin
    case(present_state)
    SSTART: if (DIR == 0 && AUTO == 0)
            next_state = (RIGHT == 1)? SRIGHT : (LEFT == 1)? SLEFT : SSTART;
            else if (DIR == 0 && AUTO == 1)                                     
            next_state = SRIGHT;
            else if (DIR == 1 && AUTO == 0)                                    
            next_state = (RIGHT == 1)? SRIGHT : (LEFT == 1)? SLEFT : SSTART;
            else if (DIR == 1 && AUTO == 1)                                     
            next_state = SLEFT;
    SRIGHT: if (DIR == 0 && AUTO == 0)
            next_state = (RIGHT == 1)? SSTART : (LEFT == 1)? SMOV_RIGHT : SRIGHT;
            else if (DIR == 0 && AUTO == 1)                                         
            next_state =  SMOV_RIGHT;
            else if (DIR == 1 && AUTO == 0)                                       
            next_state = (RIGHT == 1)? SSTART : (LEFT == 1)? SLEFT : SRIGHT;
            else if (DIR == 1 && AUTO == 1)                                      
            next_state = SLEFT;
    SLEFT: if (DIR == 0 && AUTO == 0)
            next_state = (RIGHT == 1)? SRIGHT : (LEFT == 1)? SSTART : SLEFT;
            else if (DIR == 0 && AUTO == 1)                                    
            next_state = SRIGHT;
            else if (DIR == 1 && AUTO == 0)
            next_state = (RIGHT == 1)? SMOV_LEFT : (LEFT == 1)? SSTART : SLEFT;
            else if (DIR == 1 && AUTO == 1)
            next_state = SMOV_LEFT;
    SMOV_RIGHT: 
            if (DIR == 0 && AUTO == 0)
            next_state = (RIGHT == 1)? SRIGHT : (LEFT == 1)? SLEFT : SMOV_RIGHT;
            else if (DIR == 0 && AUTO == 1)
            next_state = SRIGHT;
            else if (DIR == 1 && AUTO == 0)
            next_state = (RIGHT == 1)? SRIGHT : (LEFT == 1)? SLEFT : SMOV_RIGHT;
            else if (DIR == 1 && AUTO == 1)
            next_state = SLEFT;
    SMOV_LEFT: if (DIR == 0 && AUTO == 0)
            next_state = (RIGHT == 1)? SRIGHT : (LEFT == 1)? SLEFT : SMOV_LEFT;
            else if (DIR == 0 && AUTO == 1)
            next_state = SRIGHT;
            else if (DIR == 1 && AUTO == 0)
            next_state = (RIGHT == 1)? SRIGHT : (LEFT == 1)? SLEFT : SMOV_LEFT;
            else if (DIR == 1 && AUTO == 1)
            next_state = SLEFT;
    endcase
end

endmodule