data/full_repos/permissive/513467378/ATM.v
1: b'%Warning-WIDTH: data/full_repos/permissive/513467378/ATM.v:49: Operator ASSIGN expects 4 bits on the Assign RHS, but Assign RHS\'s VARREF \'i\' generates 32 bits.\n                                                             : ... In instance ATM.check_desaccount\n                index = i;\n                      ^\n                ... Use "/* verilator lint_off WIDTH */" and lint_on around source to disable this message.\n%Error: Exiting due to 1 warning(s)\n'
module ATM(clk,given_account_number,destination_account_number,Entered_opt,amount, error,balance);
  input clk;
  input [15:0] given_account_number;
  input [15:0] destination_account_number;
  input [1:0]Entered_opt;
  input [9:0] amount;
  output reg error;
  output reg [9:0] balance;
  reg [1:0] instate = 2'b00;
  reg [9:0] Balance [0:14];
  wire [3:0] myaccount_Index;
  wire [3:0] destination_Index;
  wire ifound;
  wire dfound;
  


  initial begin
     Balance[0] = 400;
     Balance[1] = 544;
     Balance[2] = 250;
     Balance[3] = 110;
     Balance[4] = 50;
     Balance[5] = 120;
     Balance[6] = 180;
     Balance[7] = 780;
     Balance[8] = 110;
     Balance[9] = 910;
     Balance[10] = 555;
     Balance[11] = 222;
     Balance[12] = 111;
     Balance[13] = 452;
     Balance[14] = 234;
  end
  
  

  get_data check_myaccount(given_account_number, myaccount_Index,ifound);
  get_data check_desaccount(destination_account_number, destination_Index,dfound);

  
  always @(posedge clk or ifound or Entered_opt) begin
    
	error = 1'b0;
    
    if(instate == 2'b00) begin
      instate=Entered_opt;
      $display("instate:   %d ",instate);
    end
    

    if(instate==2'b01) begin
        $display("Balancing Action");
        $display("Current 0:  %d",Balance[0]);
        $display("Current 1:  %d",Balance[1]);
        $display("Current 2:  %d",Balance[2]);
        $display("Current 3:  %d",Balance[3]);
        $display("Current 4:  %d",Balance[4]);
        $display("Current 5:  %d",Balance[5]);
        $display("Current 6:  %d",Balance[6]);
        $display("Current 7:  %d",Balance[7]);
        $display("Current 8:  %d",Balance[8]);

        balance=Balance[myaccount_Index];
        $display("Given account index:  %d",myaccount_Index);
        $display("So in that account you have: %d",balance);

    end
      

    if(instate==2'b10) begin
        if(amount<=Balance[myaccount_Index]) begin
            $display("Withdrawing Action");
            $display("needed money:  %d",amount);
            $display("from account number:  %d",myaccount_Index);
            $display("which has enough money :  %d",Balance[myaccount_Index]);
        Balance[myaccount_Index]=Balance[myaccount_Index]-amount;
        $display("after withdrawing you have:  %d",Balance[myaccount_Index]);
        end
        else begin
            error=1;
            $display("Hey Bro! unfortunately not enough money! :(");
            instate=2'b00;
            end

    end

    if(instate==2'b11) begin
        if ((amount<=Balance[myaccount_Index])) begin
            if (dfound==1) begin
                if (Balance[myaccount_Index]+Balance[destination_Index]<1023) begin
                    $display("Transfering Action");
                    $display("amount of money:  %d",amount);
                    $display("from account number :  %d",myaccount_Index);
                    $display("which has :  %d",Balance[myaccount_Index]);
                    $display("to account number :  %d",destination_Index);
                    $display("which has  %d",Balance[destination_Index]);
                    $display("current account number 1 balance:  %d",given_account_number);
                    $display("Current account No.2 balance :   %d",destination_account_number);
                    Balance[destination_Index]=Balance[destination_Index]+amount;
                    Balance[myaccount_Index]=Balance[myaccount_Index]-amount;
                    error=0;
                    instate=2'b00;
                end else begin
                    $display("too much money! overflow :|");
                    error=1;
                    instate=2'b00;
                end
            end else begin
                $display("You gonna transfer money to GOD gracias!");
                error=1;
                instate=2'b00;
            end
            
        end
        else begin
            $display("Sorry Bro!,not enough money");
            error=1;
            instate=2'b00;
        end
    end
    end

endmodule
module ATM(clk,given_account_number,destination_account_number,Entered_opt,amount, error,balance);

  input clk;
  input [15:0] given_account_number;
  input [15:0] destination_account_number;
  input [1:0]Entered_opt;
  input [9:0] amount;
  output reg error;
  output reg [9:0] balance;
  reg [1:0] instate = 2'b00;
  reg [9:0] Balance [0:14];
  wire [3:0] myaccount_Index;
  wire [3:0] destination_Index;
  wire ifound;
  wire dfound;
  


  initial begin
     Balance[0] = 400;
     Balance[1] = 544;
     Balance[2] = 250;
     Balance[3] = 110;
     Balance[4] = 50;
     Balance[5] = 120;
     Balance[6] = 180;
     Balance[7] = 780;
     Balance[8] = 110;
     Balance[9] = 910;
     Balance[10] = 555;
     Balance[11] = 222;
     Balance[12] = 111;
     Balance[13] = 452;
     Balance[14] = 234;
  end
  
  

  get_data check_myaccount(given_account_number, myaccount_Index,ifound);
  get_data check_desaccount(destination_account_number, destination_Index,dfound);

  
  always @(posedge clk or ifound or Entered_opt) begin
    
	error = 1'b0;
    
    if(instate == 2'b00) begin
      instate=Entered_opt;
      $display("instate:   %d ",instate);
    end
    

    if(instate==2'b01) begin
        $display("Balancing Action");
        $display("Current 0:  %d",Balance[0]);
        $display("Current 1:  %d",Balance[1]);
        $display("Current 2:  %d",Balance[2]);
        $display("Current 3:  %d",Balance[3]);
        $display("Current 4:  %d",Balance[4]);
        $display("Current 5:  %d",Balance[5]);
        $display("Current 6:  %d",Balance[6]);
        $display("Current 7:  %d",Balance[7]);
        $display("Current 8:  %d",Balance[8]);

        balance=Balance[myaccount_Index];
        $display("Given account index:  %d",myaccount_Index);
        $display("So in that account you have: %d",balance);

    end
      

    if(instate==2'b10) begin
        if(amount<=Balance[myaccount_Index]) begin
            $display("Withdrawing Action");
            $display("needed money:  %d",amount);
            $display("from account number:  %d",myaccount_Index);
            $display("which has enough money :  %d",Balance[myaccount_Index]);
        Balance[myaccount_Index]=Balance[myaccount_Index]-amount;
        $display("after withdrawing you have:  %d",Balance[myaccount_Index]);
        end
        else begin
            error=1;
            $display("Hey Bro! unfortunately not enough money! :(");
            instate=2'b00;
            end

    end

    if(instate==2'b11) begin
        if ((amount<=Balance[myaccount_Index])) begin
            if (dfound==1) begin
                if (Balance[myaccount_Index]+Balance[destination_Index]<1023) begin
                    $display("Transfering Action");
                    $display("amount of money:  %d",amount);
                    $display("from account number :  %d",myaccount_Index);
                    $display("which has :  %d",Balance[myaccount_Index]);
                    $display("to account number :  %d",destination_Index);
                    $display("which has  %d",Balance[destination_Index]);
                    $display("current account number 1 balance:  %d",given_account_number);
                    $display("Current account No.2 balance :   %d",destination_account_number);
                    Balance[destination_Index]=Balance[destination_Index]+amount;
                    Balance[myaccount_Index]=Balance[myaccount_Index]-amount;
                    error=0;
                    instate=2'b00;
                end else begin
                    $display("too much money! overflow :|");
                    error=1;
                    instate=2'b00;
                end
            end else begin
                $display("You gonna transfer money to GOD gracias!");
                error=1;
                instate=2'b00;
            end
            
        end
        else begin
            $display("Sorry Bro!,not enough money");
            error=1;
            instate=2'b00;
        end
    end
    end

endmodule